static GDALDataset* OGRGeoJSONDriverOpen( GDALOpenInfo* poOpenInfo ) { GeoJSONSourceType nSrcType; if( OGRGeoJSONDriverIdentifyInternal(poOpenInfo, nSrcType) == FALSE ) return NULL; OGRGeoJSONDataSource* poDS = new OGRGeoJSONDataSource(); /* -------------------------------------------------------------------- */ /* Processing configuration options. */ /* -------------------------------------------------------------------- */ // TODO: Currently, options are based on environment variables. // This is workaround for not yet implemented Andrey's concept // described in document 'RFC 10: OGR Open Parameters'. poDS->SetGeometryTranslation( OGRGeoJSONDataSource::eGeometryPreserve ); const char* pszOpt = CPLGetConfigOption("GEOMETRY_AS_COLLECTION", NULL); if( NULL != pszOpt && STARTS_WITH_CI(pszOpt, "YES") ) { poDS->SetGeometryTranslation( OGRGeoJSONDataSource::eGeometryAsCollection ); } poDS->SetAttributesTranslation( OGRGeoJSONDataSource::eAttributesPreserve ); pszOpt = CPLGetConfigOption("ATTRIBUTES_SKIP", NULL); if( NULL != pszOpt && STARTS_WITH_CI(pszOpt, "YES") ) { poDS->SetAttributesTranslation( OGRGeoJSONDataSource::eAttributesSkip ); } /* -------------------------------------------------------------------- */ /* Open and start processing GeoJSON datasource to OGR objects. */ /* -------------------------------------------------------------------- */ if( !poDS->Open( poOpenInfo, nSrcType ) ) { delete poDS; poDS = NULL; } if( poDS != NULL && poDS->HasOtherPages() ) { const char* pszFSP = CSLFetchNameValue(poOpenInfo->papszOpenOptions, "FEATURE_SERVER_PAGING"); bool bHasResultOffset = CPLURLGetValue( poOpenInfo->pszFilename, "resultOffset").size() > 0; if( (!bHasResultOffset && (pszFSP == NULL || CPLTestBool(pszFSP))) || (bHasResultOffset && pszFSP != NULL && CPLTestBool(pszFSP)) ) { return new OGRESRIFeatureServiceDataset(poOpenInfo->pszFilename, poDS); } } return poDS; }
int OGRESRIFeatureServiceDataset::LoadPage() { CPLString osNewURL = CPLURLAddKVP(osURL, "resultOffset", CPLSPrintf(CPL_FRMT_GIB, nLastOffset)); OGRGeoJSONDataSource* poDS = NULL; poDS = new OGRGeoJSONDataSource(); GDALOpenInfo oOpenInfo(osNewURL, GA_ReadOnly); if( !poDS->Open( &oOpenInfo, GeoJSONGetSourceType( &oOpenInfo ) ) || poDS->GetLayerCount() == 0 ) { delete poDS; poDS= NULL; return FALSE; } delete poCurrent; poCurrent = poDS; return TRUE; }