Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from OSGeo:master #194

Merged
merged 6 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/alpine/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ RUN apk add \
py3-pyarrow-pyc \
py3-numpy \
py3-numpy-dev \
py3-numpy-tests \
py3-pip \
py3-setuptools \
python3-dev \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/alpine_32bit/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ RUN apk add \
py3-pyarrow-pyc \
py3-numpy \
py3-numpy-dev \
py3-numpy-tests \
py3-pip \
py3-setuptools \
python3-dev \
Expand Down
33 changes: 31 additions & 2 deletions autotest/ogr/ogr_dxf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3881,7 +3881,7 @@ def test_ogr_dxf_53():
# Test frozen and off layers


def test_ogr_dxf_54():
def test_ogr_dxf_54(tmp_vsimem):

with gdal.config_option("DXF_MERGE_BLOCK_GEOMETRIES", "FALSE"):
ds = ogr.Open("data/dxf/frozen-off.dxf")
Expand All @@ -3897,7 +3897,36 @@ def test_ogr_dxf_54():
)
if isFeatureVisible == (h == "h"):
f.DumpReadable()
pytest.fail("Wrong visibility on feature %d" % number)
pytest.fail(
"Wrong visibility on feature %d (testing with layer 0 thawed)" % number
)

# Rewrite the test file, this time with layer 0 set as frozen
with open("data/dxf/frozen-off.dxf", "r") as file:
gdal.FileFromMemBuffer(
tmp_vsimem / "frozen-off-with-layer0-frozen.dxf",
file.read().replace(
"0\nLAYER\n 2\n0\n 70\n 0", "0\nLAYER\n 2\n0\n 70\n 1"
),
)

with gdal.config_option("DXF_MERGE_BLOCK_GEOMETRIES", "FALSE"):
ds = ogr.Open(
tmp_vsimem / "frozen-off-with-layer0-frozen.dxf",
)
lyr = ds.GetLayer(0)

# Repeat test - outcome should be the same
for number, h in enumerate(featureVisibility):
f = lyr.GetNextFeature()
isFeatureVisible = (
"#000000)" in f.GetStyleString() or "#ff0000)" in f.GetStyleString()
)
if isFeatureVisible == (h == "h"):
f.DumpReadable()
pytest.fail(
"Wrong visibility on feature %d (testing with layer 0 frozen)" % number
)


###############################################################################
Expand Down
20 changes: 4 additions & 16 deletions ogr/ogrct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <limits>
#include <list>
#include <mutex>
#include <thread>

#include "cpl_conv.h"
#include "cpl_error.h"
Expand Down Expand Up @@ -750,9 +749,6 @@ class OGRProjCT : public OGRCoordinateTransformation

double dfThreshold = 0.0;

PJ_CONTEXT *m_psLastContext = nullptr;
std::thread::id m_nLastContextThreadId{};

PjPtr m_pj{};
bool m_bReversePj = false;

Expand Down Expand Up @@ -1265,10 +1261,9 @@ OGRProjCT::OGRProjCT(const OGRProjCT &other)
m_osTargetSRS(other.m_osTargetSRS),
bWebMercatorToWGS84LongLat(other.bWebMercatorToWGS84LongLat),
nErrorCount(other.nErrorCount), dfThreshold(other.dfThreshold),
m_psLastContext(nullptr),
m_nLastContextThreadId(std::this_thread::get_id()), m_pj(other.m_pj),
m_bReversePj(other.m_bReversePj), m_bEmitErrors(other.m_bEmitErrors),
bNoTransform(other.bNoTransform), m_eStrategy(other.m_eStrategy),
m_pj(other.m_pj), m_bReversePj(other.m_bReversePj),
m_bEmitErrors(other.m_bEmitErrors), bNoTransform(other.bNoTransform),
m_eStrategy(other.m_eStrategy),
m_oTransformations(other.m_oTransformations),
m_iCurTransformation(other.m_iCurTransformation),
m_options(other.m_options)
Expand Down Expand Up @@ -2520,14 +2515,7 @@ int OGRProjCT::TransformWithErrorCodes(size_t nCount, double *x, double *y,
/* Select dynamically the best transformation for the data, if */
/* needed. */
/* -------------------------------------------------------------------- */
PJ_CONTEXT *ctx = m_psLastContext;
const auto nThisThreadId = std::this_thread::get_id();
if (!ctx || nThisThreadId != m_nLastContextThreadId)
{
m_nLastContextThreadId = nThisThreadId;
m_psLastContext = OSRGetProjTLSContext();
ctx = m_psLastContext;
}
auto ctx = OSRGetProjTLSContext();

PJ *pj = m_pj;
if (!bTransformDone && !pj)
Expand Down
18 changes: 9 additions & 9 deletions ogr/ogrsf_frmts/dxf/ogrdxf_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ OGRDXFFeature::GetColor(OGRDXFDataSource *const poDS,
(poBlockFeature &&
poBlockFeature->oStyleProperties.count("Hidden") > 0))
{
// Hidden objects should never be shown no matter what happens,
// so they can be treated as if they are on a frozen layer
iHidden = 2;
// Hidden objects should never be shown no matter what happens
iHidden = 1;
oStyleProperties["Hidden"] = "1";
}
else
{
Expand All @@ -166,13 +166,13 @@ OGRDXFFeature::GetColor(OGRDXFDataSource *const poDS,
if (pszBlockHidden && atoi(pszBlockHidden) == 2)
iHidden = 2;
}
}

// If this feature is on a frozen layer, make the object totally
// hidden so it won't reappear if we regenerate the style string again
// during block insertion
if (iHidden == 2)
oStyleProperties["Hidden"] = "1";
// If this feature is on a frozen layer (other than layer 0), make the
// object totally hidden so it won't reappear if we regenerate the style
// string again during block insertion
if (iHidden == 2 && !EQUAL(GetFieldAsString("Layer"), "0"))
oStyleProperties["Hidden"] = "1";
}

// Helpful constants
const int C_BYLAYER = 256;
Expand Down
Loading