From 20ff89719d1953221a908c59f3c3c1ef786d6bdf Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 12 Dec 2024 15:41:05 +0100 Subject: [PATCH 1/3] GeoJSON: do not generate an empty layer name when reading from /vsistdin/ Fixes #11484 --- autotest/ogr/ogr_geojson.py | 10 ++++++++++ ogr/ogrsf_frmts/geojson/ogr_geojson.h | 10 ++++++++++ ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/autotest/ogr/ogr_geojson.py b/autotest/ogr/ogr_geojson.py index e89af09b9d8e..61e25654c9a9 100755 --- a/autotest/ogr/ogr_geojson.py +++ b/autotest/ogr/ogr_geojson.py @@ -2914,6 +2914,16 @@ def test_ogr_geojson_58(tmp_vsimem): ds = None +############################################################################### +# Test using the name member of FeatureCollection + + +def test_ogr_geojson_empty_name(): + + with ogr.Open('{ "type": "FeatureCollection", "name": "", "features": []}') as ds: + assert ds.GetLayer(0).GetName() == "OGRGeoJSON" + + ############################################################################### # Test using the description member of FeatureCollection diff --git a/ogr/ogrsf_frmts/geojson/ogr_geojson.h b/ogr/ogrsf_frmts/geojson/ogr_geojson.h index 61a1b46e2913..f80991ac8ec3 100644 --- a/ogr/ogrsf_frmts/geojson/ogr_geojson.h +++ b/ogr/ogrsf_frmts/geojson/ogr_geojson.h @@ -48,6 +48,16 @@ class OGRGeoJSONLayer final : public OGRMemLayer static const char *const DefaultName; static const OGRwkbGeometryType DefaultGeometryType; + static const char *GetValidLayerName(const char *pszName) + { + if (pszName == nullptr || pszName[0] == 0) + { + // Can happen for example if reading from /vsistdin/ + pszName = OGRGeoJSONLayer::DefaultName; + } + return pszName; + } + OGRGeoJSONLayer(const char *pszName, OGRSpatialReference *poSRS, OGRwkbGeometryType eGType, OGRGeoJSONDataSource *poDS, OGRGeoJSONReader *poReader); diff --git a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp index fd88e5f5a1c2..7a01b7bce2bc 100644 --- a/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp +++ b/ogr/ogrsf_frmts/geojson/ogrgeojsonreader.cpp @@ -419,6 +419,7 @@ bool OGRGeoJSONReader::FirstPassReadLayer(OGRGeoJSONDataSource *poDS, if (STARTS_WITH_CI(pszName, "GeoJSON:")) pszName += strlen("GeoJSON:"); pszName = CPLGetBasename(pszName); + pszName = OGRGeoJSONLayer::GetValidLayerName(pszName); OGRGeoJSONLayer *poLayer = new OGRGeoJSONLayer( pszName, nullptr, OGRGeoJSONLayer::DefaultGeometryType, poDS, this); @@ -930,9 +931,8 @@ void OGRGeoJSONReader::ReadLayer(OGRGeoJSONDataSource *poDS, pszName = CPLGetBasename(pszDesc); } } - if (pszName == nullptr) - pszName = OGRGeoJSONLayer::DefaultName; } + pszName = OGRGeoJSONLayer::GetValidLayerName(pszName); OGRGeoJSONLayer *poLayer = new OGRGeoJSONLayer( pszName, nullptr, OGRGeoJSONLayer::DefaultGeometryType, poDS, nullptr); From 733a50e5629efaa3892d8803f1f0d61bc321e6b6 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 12 Dec 2024 16:25:20 +0100 Subject: [PATCH 2/3] autotest/gdrivers/tiledb_write.py: skip test_tiledb_write_overviews() on 'build-windows-conda' target Refs #11485 --- autotest/gdrivers/tiledb_write.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autotest/gdrivers/tiledb_write.py b/autotest/gdrivers/tiledb_write.py index c75a73b0095d..8e785641de77 100755 --- a/autotest/gdrivers/tiledb_write.py +++ b/autotest/gdrivers/tiledb_write.py @@ -451,6 +451,10 @@ def test_tiledb_write_create_group(tmp_path): assert ds.RasterYSize == 2 +@pytest.mark.skipif( + gdaltest.is_travis_branch("build-windows-conda"), + reason="Fails with tiledb 2.27. Seehttps://github.com/OSGeo/gdal/issues/11485", +) def test_tiledb_write_overviews(tmp_path): # This dataset name must be kept short, otherwise strange I/O errors will From aae18ed5e393949498072ad1269856d445869314 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 12 Dec 2024 17:54:15 +0100 Subject: [PATCH 3/3] CI cppcheck_master: workaround issue with cppcheck master --- .github/workflows/code_checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code_checks.yml b/.github/workflows/code_checks.yml index 88e8d9cf5622..36a5da9ac7ad 100644 --- a/.github/workflows/code_checks.yml +++ b/.github/workflows/code_checks.yml @@ -80,6 +80,7 @@ jobs: run: | git clone https://github.com/danmar/cppcheck cd cppcheck + git checkout 690aab586136cf596b84ef04a61337813609d716 # FIXME: Workaround https://github.com/danmar/cppcheck/pull/6906#issuecomment-2539097133 mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=Release