Skip to content

Commit b143404

Browse files
committed
TopoJSON: do not advertize Z capabilities
1 parent 76b71cb commit b143404

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

ogr/ogrsf_frmts/geojson/ogr_geojson.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ class OGRGeoJSONLayer final : public OGRMemLayer
132132
m_bSupportsMGeometries = bSupportsMGeometries;
133133
}
134134

135+
void SetSupportsZGeometries(bool bSupportsZGeometries)
136+
{
137+
m_bSupportsZGeometries = bSupportsZGeometries;
138+
}
139+
135140
private:
136141
OGRGeoJSONDataSource *poDS_;
137142
OGRGeoJSONReader *poReader_;
@@ -141,6 +146,7 @@ class OGRGeoJSONLayer final : public OGRMemLayer
141146
GIntBig nTotalFeatureCount_;
142147
GIntBig nFeatureReadSinceReset_ = 0;
143148
bool m_bSupportsMGeometries = false;
149+
bool m_bSupportsZGeometries = true;
144150

145151
//! Write options used by ICreateFeature() in append scenarios
146152
OGRGeoJSONWriteOptions oWriteOptions_;
@@ -303,6 +309,11 @@ class OGRGeoJSONDataSource final : public GDALDataset
303309
m_bSupportsMGeometries = bSupportsMGeometries;
304310
}
305311

312+
void SetSupportsZGeometries(bool bSupportsZGeometries)
313+
{
314+
m_bSupportsZGeometries = bSupportsZGeometries;
315+
}
316+
306317
virtual CPLErr FlushCache(bool bAtClosing) override;
307318

308319
CPLErr Close() override;
@@ -339,6 +350,8 @@ class OGRGeoJSONDataSource final : public GDALDataset
339350
CPLString osJSonFlavor_;
340351

341352
bool m_bSupportsMGeometries = false;
353+
bool m_bSupportsZGeometries = true;
354+
342355
//
343356
// Private utility functions
344357
//

ogr/ogrsf_frmts/geojson/ogrgeojsondatasource.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ int OGRGeoJSONDataSource::TestCapability(const char *pszCap)
755755
else if (EQUAL(pszCap, ODsCMeasuredGeometries))
756756
return m_bSupportsMGeometries;
757757
else if (EQUAL(pszCap, ODsCZGeometries))
758-
return TRUE;
758+
return m_bSupportsZGeometries;
759759

760760
return FALSE;
761761
}

ogr/ogrsf_frmts/geojson/ogrgeojsonlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ int OGRGeoJSONLayer::TestCapability(const char *pszCap)
507507
else if (EQUAL(pszCap, OLCMeasuredGeometries))
508508
return m_bSupportsMGeometries;
509509
else if (EQUAL(pszCap, OLCZGeometries))
510-
return TRUE;
510+
return m_bSupportsZGeometries;
511511
else if (EQUAL(pszCap, OLCStringsAsUTF8))
512512
return TRUE;
513513
else if (EQUAL(pszCap, OLCFastGetExtent) ||

ogr/ogrsf_frmts/geojson/ogrtopojsonreader.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ ParseObjectMain(const char *pszId, json_object *poObj,
495495
OGRGeoJSONLayer *poLayer =
496496
new OGRGeoJSONLayer(pszId ? pszId : "TopoJSON", nullptr,
497497
wkbUnknown, poDS, nullptr);
498+
poLayer->SetSupportsZGeometries(false);
498499
OGRFeatureDefn *poDefn = poLayer->GetLayerDefn();
499500

500501
const auto nGeometries =
@@ -569,6 +570,9 @@ ParseObjectMain(const char *pszId, json_object *poObj,
569570
{
570571
*ppoMainLayer = new OGRGeoJSONLayer(
571572
"TopoJSON", nullptr, wkbUnknown, poDS, nullptr);
573+
574+
(*ppoMainLayer)->SetSupportsZGeometries(false);
575+
572576
apoFieldDefn.emplace_back(
573577
std::make_unique<OGRFieldDefn>("id", OFTString));
574578
oMapFieldNameToIdx["id"] = 0;
@@ -629,6 +633,8 @@ void OGRTopoJSONReader::ReadLayers(OGRGeoJSONDataSource *poDS)
629633
return;
630634
}
631635

636+
poDS->SetSupportsZGeometries(false);
637+
632638
ScalingParams sParams;
633639
sParams.dfScale0 = 1.0;
634640
sParams.dfScale1 = 1.0;

0 commit comments

Comments
 (0)