diff --git a/.github/workflows/alpine/Dockerfile.ci b/.github/workflows/alpine/Dockerfile.ci index 291a18345ba0..1d77900b772b 100644 --- a/.github/workflows/alpine/Dockerfile.ci +++ b/.github/workflows/alpine/Dockerfile.ci @@ -57,6 +57,7 @@ RUN apk add \ py3-pyarrow-pyc \ py3-numpy \ py3-numpy-dev \ + py3-numpy-tests \ py3-pip \ py3-setuptools \ python3-dev \ diff --git a/.github/workflows/alpine_32bit/Dockerfile.ci b/.github/workflows/alpine_32bit/Dockerfile.ci index 935527a4a707..b16711eedee8 100644 --- a/.github/workflows/alpine_32bit/Dockerfile.ci +++ b/.github/workflows/alpine_32bit/Dockerfile.ci @@ -58,6 +58,7 @@ RUN apk add \ py3-pyarrow-pyc \ py3-numpy \ py3-numpy-dev \ + py3-numpy-tests \ py3-pip \ py3-setuptools \ python3-dev \ diff --git a/autotest/ogr/ogr_dxf.py b/autotest/ogr/ogr_dxf.py index b07e71d3d5c3..cc61c92f8d9c 100644 --- a/autotest/ogr/ogr_dxf.py +++ b/autotest/ogr/ogr_dxf.py @@ -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") @@ -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 + ) ############################################################################### diff --git a/ogr/ogrct.cpp b/ogr/ogrct.cpp index ae93f7163579..f04c993677c2 100644 --- a/ogr/ogrct.cpp +++ b/ogr/ogrct.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "cpl_conv.h" #include "cpl_error.h" @@ -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; @@ -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) @@ -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) diff --git a/ogr/ogrsf_frmts/dxf/ogrdxf_feature.cpp b/ogr/ogrsf_frmts/dxf/ogrdxf_feature.cpp index 8bb92b3aab50..36e395127f4e 100644 --- a/ogr/ogrsf_frmts/dxf/ogrdxf_feature.cpp +++ b/ogr/ogrsf_frmts/dxf/ogrdxf_feature.cpp @@ -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 { @@ -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;