void OGRESRIJSONReader::ReadLayers( OGRGeoJSONDataSource* poDS, GeoJSONSourceType eSourceType ) { CPLAssert( nullptr == poLayer_ ); if( nullptr == poGJObject_ ) { CPLDebug( "ESRIJSON", "Missing parsed ESRIJSON data. Forgot to call Parse()?" ); return; } OGRSpatialReference* poSRS = OGRESRIJSONReadSpatialReference( poGJObject_ ); const char* pszName = "ESRIJSON"; if( eSourceType == eGeoJSONSourceFile ) { pszName = poDS->GetDescription(); if( STARTS_WITH_CI(pszName, "ESRIJSON:") ) pszName += strlen("ESRIJSON:"); pszName = CPLGetBasename(pszName); } auto eGeomType = OGRESRIJSONGetGeometryType(poGJObject_); if( eGeomType == wkbNone && poSRS != nullptr ) { eGeomType = wkbUnknown; } poLayer_ = new OGRGeoJSONLayer( pszName, poSRS, eGeomType, poDS, nullptr ); if( poSRS != nullptr ) poSRS->Release(); if( !GenerateLayerDefn() ) { CPLError( CE_Failure, CPLE_AppDefined, "Layer schema generation failed." ); delete poLayer_; return; } OGRGeoJSONLayer *poThisLayer = ReadFeatureCollection( poGJObject_ ); if( poThisLayer == nullptr ) { delete poLayer_; return; } CPLErrorReset(); poLayer_->DetectGeometryType(); poDS->AddLayer(poLayer_); }
OGRGeoJSONLayer* OGRESRIJSONReader::ReadLayer( const char* pszName, OGRGeoJSONDataSource* poDS ) { CPLAssert( NULL == poLayer_ ); if( NULL == poGJObject_ ) { CPLDebug( "ESRIJSON", "Missing parset ESRIJSON data. Forgot to call Parse()?" ); return NULL; } poLayer_ = new OGRGeoJSONLayer( pszName, NULL, OGRESRIJSONGetGeometryType(poGJObject_), poDS ); if( !GenerateLayerDefn() ) { CPLError( CE_Failure, CPLE_AppDefined, "Layer schema generation failed." ); delete poLayer_; return NULL; } OGRGeoJSONLayer* poThisLayer = NULL; poThisLayer = ReadFeatureCollection( poGJObject_ ); if (poThisLayer == NULL) { delete poLayer_; return NULL; } OGRSpatialReference* poSRS = NULL; poSRS = OGRESRIJSONReadSpatialReference( poGJObject_ ); if (poSRS != NULL ) { poLayer_->SetSpatialRef( poSRS ); delete poSRS; } return poLayer_; }
void OGRESRIJSONReader::ReadLayers( OGRGeoJSONDataSource* poDS ) { CPLAssert( NULL == poLayer_ ); if( NULL == poGJObject_ ) { CPLDebug( "ESRIJSON", "Missing parset ESRIJSON data. Forgot to call Parse()?" ); return; } OGRSpatialReference* poSRS = NULL; poSRS = OGRESRIJSONReadSpatialReference( poGJObject_ ); poLayer_ = new OGRGeoJSONLayer( OGRGeoJSONLayer::DefaultName, poSRS, OGRESRIJSONGetGeometryType(poGJObject_), poDS ); if( poSRS != NULL ) poSRS->Release(); if( !GenerateLayerDefn() ) { CPLError( CE_Failure, CPLE_AppDefined, "Layer schema generation failed." ); delete poLayer_; return; } OGRGeoJSONLayer* poThisLayer = NULL; poThisLayer = ReadFeatureCollection( poGJObject_ ); if (poThisLayer == NULL) { delete poLayer_; return; } CPLErrorReset(); poDS->AddLayer(poLayer_); }