OGRFeature *OGRAVCBinLayer::GetNextFeature() { if( bNeedReset ) ResetReading(); OGRFeature *poFeature = GetFeature( -3 ); // Skip universe polygon. if( poFeature != NULL && poFeature->GetFID() == 1 && psSection->eType == AVCFilePAL ) { OGRFeature::DestroyFeature( poFeature ); poFeature = GetFeature( -3 ); } while( poFeature != NULL && ((m_poAttrQuery != NULL && !m_poAttrQuery->Evaluate( poFeature ) ) || !FilterGeometry( poFeature->GetGeometryRef() ) ) ) { OGRFeature::DestroyFeature( poFeature ); poFeature = GetFeature( -3 ); } if( poFeature == NULL ) ResetReading(); return poFeature; }
FeatureInfo extractAllPoints(const QString& fname, OGRCoordinateTransformation *trans) { FeatureInfo ret = FeatureInfo(); DataSourcePtr ds(OGRSFDriverRegistrar::Open(fname.toLocal8Bit(), false)); if (ds == nullptr) { qWarning() << "Error opening file:" << fname; } else { size_t verts, objs; auto layer = ds->GetLayer(0); layer->ResetReading(); std::tie(verts, objs) = countGeometry(layer); qDebug() << "Points:" << verts << "Objects:" << objs; // Initialize the info ret.verts.reserve(verts); ret.starts.reserve(objs); ret.counts.reserve(objs); layer->ResetReading(); extractGeometry(layer, trans, ret); } return ret; }
int OGRCSVLayer::GetFeatureCount( int bForce ) { if (bInWriteMode || m_poFilterGeom != NULL || m_poAttrQuery != NULL) return OGRLayer::GetFeatureCount(bForce); if (nTotalFeatures >= 0) return nTotalFeatures; if (fpCSV == NULL) return 0; ResetReading(); char **papszTokens; nTotalFeatures = 0; while(TRUE) { papszTokens = OGRCSVReadParseLineL( fpCSV, chDelimiter, bDontHonourStrings ); if( papszTokens == NULL ) break; if( papszTokens[0] != NULL ) nTotalFeatures ++; CSLDestroy(papszTokens); } ResetReading(); return nTotalFeatures; }
int OGRHTFSoundingLayer::GetFeatureCount(int bForce) { if (m_poFilterGeom != NULL || m_poAttrQuery != NULL) return OGRHTFLayer::GetFeatureCount(bForce); if (nTotalSoundings != 0) return nTotalSoundings; ResetReading(); if (fpHTF == NULL) return 0; int nCount = 0; const char* pszLine; while( (pszLine = CPLReadLine2L(fpHTF, 1024, NULL)) != NULL) { if (pszLine[0] == ';') { /* comment */ ; } else if (pszLine[0] == 0) break; else if (strcmp(pszLine, "END OF SOUNDING DATA") == 0) break; else nCount ++; } ResetReading(); return nCount; }
void OGRGeoJSONSeqLayer::Init() { if( STARTS_WITH(m_poDS->GetDescription(), "/vsimem/") || !STARTS_WITH(m_poDS->GetDescription(), "/vsi") ) { VSIFSeekL(m_fp, 0, SEEK_END); m_nFileSize = VSIFTellL(m_fp); } ResetReading(); while( true ) { auto poObject = GetNextObject(); if( !poObject ) break; if( OGRGeoJSONGetType(poObject) == GeoJSONObject::eFeature ) { m_oReader.GenerateFeatureDefn(this, poObject); } json_object_put(poObject); m_nTotalFeatures ++; } ResetReading(); m_nFileSize = 0; m_nIter = 0; m_oReader.FinalizeLayerDefn( this, m_osFIDColumn ); }
void OGRGMELayer::SetSpatialFilter( OGRGeometry *poGeomIn) { if (poGeomIn == NULL) { osIntersects.clear(); OGRLayer::SetSpatialFilter( poGeomIn ); return; } switch( poGeomIn->getGeometryType() ) { case wkbPolygon: WindPolygonCCW((OGRPolygon *) poGeomIn); case wkbPoint: case wkbLineString: if( poGeomIn == NULL ) { osIntersects = ""; } else { char * pszWkt; poGeomIn->exportToWkt(&pszWkt); char * pszEscaped = CPLEscapeString(pszWkt, -1, CPLES_URL); osIntersects = CPLString(pszEscaped); CPLFree(pszEscaped); CPLFree(pszWkt); } ResetReading(); break; default: m_iGeomFieldFilter = 0; if( InstallFilter( poGeomIn ) ) ResetReading(); break; } }
OGRErr OGRLayer::GetExtent(OGREnvelope *psExtent, int bForce ) { OGRFeature *poFeature; OGREnvelope oEnv; GBool bExtentSet = FALSE; /* -------------------------------------------------------------------- */ /* If this layer has a none geometry type, then we can */ /* reasonably assume there are not extents available. */ /* -------------------------------------------------------------------- */ if( GetLayerDefn()->GetGeomType() == wkbNone ) { psExtent->MinX = 0.0; psExtent->MaxX = 0.0; psExtent->MinY = 0.0; psExtent->MaxY = 0.0; return OGRERR_FAILURE; } /* -------------------------------------------------------------------- */ /* If not forced, we should avoid having to scan all the */ /* features and just return a failure. */ /* -------------------------------------------------------------------- */ if( !bForce ) return OGRERR_FAILURE; /* -------------------------------------------------------------------- */ /* OK, we hate to do this, but go ahead and read through all */ /* the features to collect geometries and build extents. */ /* -------------------------------------------------------------------- */ ResetReading(); while( (poFeature = GetNextFeature()) != NULL ) { OGRGeometry *poGeom = poFeature->GetGeometryRef(); if (poGeom && !bExtentSet) { poGeom->getEnvelope(psExtent); bExtentSet = TRUE; } else if (poGeom) { poGeom->getEnvelope(&oEnv); if (oEnv.MinX < psExtent->MinX) psExtent->MinX = oEnv.MinX; if (oEnv.MinY < psExtent->MinY) psExtent->MinY = oEnv.MinY; if (oEnv.MaxX > psExtent->MaxX) psExtent->MaxX = oEnv.MaxX; if (oEnv.MaxY > psExtent->MaxY) psExtent->MaxY = oEnv.MaxY; } delete poFeature; } ResetReading(); return (bExtentSet ? OGRERR_NONE : OGRERR_FAILURE); }
OGRFeature *OGROGDILayer::GetFeature( GIntBig nFeatureId ) { ecs_Result *psResult; if (m_nTotalShapeCount != -1 && nFeatureId > m_nTotalShapeCount) return NULL; /* Unset spatial filter */ OGRGeometry* poOldFilterGeom = ( m_poFilterGeom != NULL ) ? m_poFilterGeom->clone() : NULL; if( poOldFilterGeom != NULL ) SetSpatialFilter(NULL); /* Reset reading if we are not the current layer */ /* WARNING : this does not allow interleaved reading of layers */ if( m_poODS->GetCurrentLayer() != this ) { m_poODS->SetCurrentLayer(this); ResetReading(); } else if ( nFeatureId < m_iNextShapeId ) ResetReading(); while(m_iNextShapeId != nFeatureId) { psResult = cln_GetNextObject(m_nClientID); if (ECSSUCCESS(psResult)) m_iNextShapeId++; else { // We probably reached EOF... keep track of shape count. m_nTotalShapeCount = m_iNextShapeId; if( poOldFilterGeom != NULL ) { SetSpatialFilter(poOldFilterGeom); delete poOldFilterGeom; } return NULL; } } // OK, we're ready to read the requested feature... OGRFeature* poFeature = GetNextRawFeature(); if( poOldFilterGeom != NULL ) { SetSpatialFilter(poOldFilterGeom); delete poOldFilterGeom; } return poFeature; }
OGRFeature *OGROGDILayer::GetFeature( long nFeatureId ) { ecs_Result *psResult; if (m_nTotalShapeCount != -1 && nFeatureId > m_nTotalShapeCount) return NULL; if (m_iNextShapeId > nFeatureId ) ResetReading(); while(m_iNextShapeId != nFeatureId) { psResult = cln_GetNextObject(m_nClientID); if (ECSSUCCESS(psResult)) m_iNextShapeId++; else { // We probably reached EOF... keep track of shape count. m_nTotalShapeCount = m_iNextShapeId; return NULL; } } // OK, we're ready to read the requested feature... return GetNextFeature(); }
OGRPLScenesLayer::OGRPLScenesLayer(OGRPLScenesDataset* poDS, const char* pszName, const char* pszBaseURL, json_object* poObjCount10) { this->poDS = poDS; osBaseURL = pszBaseURL; SetDescription(pszName); poFeatureDefn = new OGRFeatureDefn(pszName); poFeatureDefn->SetGeomType(wkbMultiPolygon); for(int i = 0; i < (int)sizeof(apsAttrs) / (int)sizeof(apsAttrs[0]); i++) { OGRFieldDefn oField(apsAttrs[i].pszName, apsAttrs[i].eType); poFeatureDefn->AddFieldDefn(&oField); } poFeatureDefn->Reference(); poSRS = new OGRSpatialReference(SRS_WKT_WGS84); poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poSRS); bEOF = FALSE; nFeatureCount = -1; nNextFID = 1; poGeoJSONDS = NULL; poGeoJSONLayer = NULL; poMainFilter = NULL; nPageSize = atoi(CPLGetConfigOption("PLSCENES_PAGE_SIZE", "1000")); bStillInFirstPage = FALSE; bAcquiredAscending = -1; bFilterMustBeClientSideEvaluated = FALSE; ResetReading(); if( poObjCount10 != NULL ) { json_object* poCount = json_object_object_get(poObjCount10, "count"); if( poCount != NULL ) nFeatureCount = MAX(0, json_object_get_int64(poCount)); OGRGeoJSONDataSource* poTmpDS = new OGRGeoJSONDataSource(); OGRGeoJSONReader oReader; oReader.SetFlattenNestedAttributes(true, '.'); oReader.ReadLayer( poTmpDS, "layer", poObjCount10 ); OGRLayer* poTmpLayer = poTmpDS->GetLayer(0); if( poTmpLayer ) { OGRFeatureDefn* poTmpFDefn = poTmpLayer->GetLayerDefn(); std::vector<CPLString> aosNewFields; for(int i=0;i<poTmpFDefn->GetFieldCount();i++) { if( poFeatureDefn->GetFieldIndex(poTmpFDefn->GetFieldDefn(i)->GetNameRef()) < 0 ) aosNewFields.push_back(poTmpFDefn->GetFieldDefn(i)->GetNameRef()); } std::sort(aosNewFields.begin(), aosNewFields.end(), OGRPLScenesLayerFieldNameComparator); for(int i=0;i<(int)aosNewFields.size();i++) { OGRFieldDefn oField(poTmpFDefn->GetFieldDefn(poTmpFDefn->GetFieldIndex(aosNewFields[i]))); poFeatureDefn->AddFieldDefn(&oField); } } delete poTmpDS; } }
OGRFeature *OGRCSVLayer::GetNextFeature() { OGRFeature *poFeature = NULL; if( bNeedRewindBeforeRead ) ResetReading(); /* -------------------------------------------------------------------- */ /* Read features till we find one that satisfies our current */ /* spatial criteria. */ /* -------------------------------------------------------------------- */ while( TRUE ) { poFeature = GetNextUnfilteredFeature(); if( poFeature == NULL ) break; if( (m_poFilterGeom == NULL || FilterGeometry( poFeature->GetGeometryRef() ) ) && (m_poAttrQuery == NULL || m_poAttrQuery->Evaluate( poFeature )) ) break; delete poFeature; } return poFeature; }
void OGRBNALayer::FastParseUntil ( int interestFID) { if (partialIndexTable) { ResetReading(); BNARecord* record; if (nFeatures > 0) { VSIFSeekL( fpBNA, offsetAndLineFeaturesTable[nFeatures-1].offset, SEEK_SET ); curLine = offsetAndLineFeaturesTable[nFeatures-1].line; /* Just skip the last read one */ int ok = FALSE; record = BNA_GetNextRecord(fpBNA, &ok, &curLine, TRUE, BNA_READ_NONE); BNA_FreeRecord(record); } while(1) { int ok = FALSE; int offset = (int) VSIFTellL(fpBNA); int line = curLine; record = BNA_GetNextRecord(fpBNA, &ok, &curLine, TRUE, BNA_READ_NONE); if (ok == FALSE) { failed = TRUE; return; } if (record == NULL) { /* end of file */ eof = TRUE; /* and we have finally build the whole index table */ partialIndexTable = FALSE; return; } if (record->featureType == bnaFeatureType) { nFeatures++; offsetAndLineFeaturesTable = (OffsetAndLine*)CPLRealloc(offsetAndLineFeaturesTable, nFeatures * sizeof(OffsetAndLine)); offsetAndLineFeaturesTable[nFeatures-1].offset = offset; offsetAndLineFeaturesTable[nFeatures-1].line = line; BNA_FreeRecord(record); if (nFeatures - 1 == interestFID) return; } else { BNA_FreeRecord(record); } } } }
OGRFeature *OGRFMELayerCached::ReadNextIndexFeature() { OGRFeature *poOGRFeature = NULL; FME_Boolean endOfQuery; if( poIndex == NULL ) return NULL; if( !bQueryActive ) ResetReading(); poDS->AcquireSession(); if( poIndex->fetch( *poFMEFeature, endOfQuery ) == 0 && !endOfQuery ) { poOGRFeature = poDS->ProcessFeature( this, poFMEFeature ); if( poOGRFeature != NULL ) { poOGRFeature->SetFID( ++nPreviousFeature ); m_nFeaturesRead++; } } poDS->ReleaseSession(); return poOGRFeature; }
void OGRSQLiteSelectLayerCommonBehaviour::SetSpatialFilter( int iGeomField, OGRGeometry * poGeomIn ) { if( iGeomField == 0 && poGeomIn == NULL && poLayer->GetLayerDefn()->GetGeomFieldCount() == 0 ) { /* do nothing */ } else if( iGeomField < 0 || iGeomField >= poLayer->GetLayerDefn()->GetGeomFieldCount() ) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid geometry field index : %d", iGeomField); return; } bAllowResetReadingEvenIfIndexAtZero = TRUE; int& m_iGeomFieldFilter = poLayer->GetIGeomFieldFilter(); m_iGeomFieldFilter = iGeomField; if( poLayer->InstallFilter( poGeomIn ) ) { BuildSQL(); ResetReading(); } }
OGRSEGP1Layer::OGRSEGP1Layer( const char* pszFilename, VSILFILE* fp, int nLatitudeCol ) { this->fp = fp; this->nLatitudeCol = nLatitudeCol; nNextFID = 0; bEOF = FALSE; poSRS = NULL; poFeatureDefn = new OGRFeatureDefn( CPLGetBasename(pszFilename) ); SetDescription( poFeatureDefn->GetName() ); poFeatureDefn->Reference(); poFeatureDefn->SetGeomType( wkbPoint ); for(int i=0;i<(int)(sizeof(SEGP1Fields)/sizeof(SEGP1Fields[0]));i++) { OGRFieldDefn oField( SEGP1Fields[i].pszName, SEGP1Fields[i].eType ); poFeatureDefn->AddFieldDefn( &oField ); } bUseEastingNorthingAsGeometry = CSLTestBoolean(CPLGetConfigOption("SEGP1_USE_EASTING_NORTHING", "NO")); ResetReading(); }
void OGRDWGLayer::SetBlockTable( OdDbBlockTableRecordPtr poNewBlock ) { m_poBlock = poNewBlock; ResetReading(); }
OGRFeature *OGROGDILayer::GetNextFeature() { OGRFeature *poFeature; /* Reset reading if we are not the current layer */ /* WARNING : this does not allow interleaved reading of layers */ if( m_poODS->GetCurrentLayer() != this ) { m_poODS->SetCurrentLayer(this); ResetReading(); } while( true ) { poFeature = GetNextRawFeature(); if( poFeature == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Do we need to apply an attribute test? */ /* -------------------------------------------------------------------- */ if( (m_poAttrQuery != NULL && !m_poAttrQuery->Evaluate( poFeature ) ) || (m_poFilterGeom != NULL && !FilterGeometry( poFeature->GetGeometryRef() ) ) ) { m_nFilteredOutShapes ++; delete poFeature; } else return poFeature; } }
OGRErr OGRSQLiteSelectLayerCommonBehaviour::SetAttributeFilter( const char *pszQuery ) { char*& m_pszAttrQuertyString = poLayer->GetAttrQueryString(); if( m_pszAttrQuertyString == NULL && pszQuery == NULL ) return OGRERR_NONE; CPLFree(m_pszAttrQuertyString); m_pszAttrQuertyString = (pszQuery) ? CPLStrdup(pszQuery) : NULL; bAllowResetReadingEvenIfIndexAtZero = TRUE; OGRFeatureQuery oQuery; CPLPushErrorHandler(CPLQuietErrorHandler); int bHasSpecialFields = (pszQuery != NULL && pszQuery[0] != '\0' && oQuery.Compile( poLayer->GetLayerDefn(), pszQuery ) == OGRERR_NONE && HasSpecialFields((swq_expr_node*)oQuery.GetSWQExpr(), poLayer->GetLayerDefn()->GetFieldCount()) ); CPLPopErrorHandler(); if( bHasSpecialFields || !BuildSQL() ) { return poLayer->BaseSetAttributeFilter(pszQuery); } ResetReading(); return OGRERR_NONE; }
void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer, int nSurfaceFieldIndex ) { CPLDebug( "OGR_ILI", "Joining surface layer %s with geometries", GetLayerDefn()->GetName()); OGRwkbGeometryType geomType = GetLayerDefn()->GetGeomFieldDefn(nSurfaceFieldIndex)->GetType(); poSurfaceLineLayer->ResetReading(); while (OGRFeature *linefeature = poSurfaceLineLayer->GetNextFeatureRef()) { //OBJE entries with same _RefTID are polygon rings of same feature //TODO: non-numeric _RefTID/FID is not supported yet! GIntBig reftid = linefeature->GetFieldAsInteger64(1); //_RefTID OGRFeature *feature = GetFeatureRef((int)reftid); if (feature) { OGRCurvePolygon *poly; if (feature->GetGeomFieldRef(nSurfaceFieldIndex)) { CPLDebug( "OGR_ILI", "Adding ring to FID " CPL_FRMT_GIB, reftid ); poly = (OGRCurvePolygon *)feature->GetGeomFieldRef(nSurfaceFieldIndex); } else { poly = (geomType == wkbPolygon) ? new OGRPolygon() : new OGRCurvePolygon(); feature->SetGeomFieldDirectly(nSurfaceFieldIndex, poly); } OGRMultiCurve *lines = (OGRMultiCurve*)linefeature->GetGeomFieldRef(0); for( int i = 0; i < lines->getNumGeometries(); i++ ) { OGRCurve *line = (OGRCurve*)lines->getGeometryRef(i); OGRCurve *ring = (geomType == wkbPolygon) ? OGRCurve::CastToLinearRing((OGRCurve*)line->clone()) : (OGRCurve*)line->clone(); poly->addRingDirectly(ring); } } else { CPLError(CE_Warning, CPLE_AppDefined, "Couldn't join feature FID " CPL_FRMT_GIB, reftid ); } } ResetReading(); poSurfaceLineLayer = 0; }
void OGRPGResultLayer::SetSpatialFilter( int iGeomField, OGRGeometry * poGeomIn ) { if( iGeomField < 0 || iGeomField >= GetLayerDefn()->GetGeomFieldCount() || GetLayerDefn()->GetGeomFieldDefn(iGeomField)->GetType() == wkbNone ) { if( iGeomField != 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid geometry field index : %d", iGeomField); } return; } m_iGeomFieldFilter = iGeomField; OGRPGGeomFieldDefn* poGeomFieldDefn = poFeatureDefn->myGetGeomFieldDefn(m_iGeomFieldFilter); if( InstallFilter( poGeomIn ) ) { if ( poGeomFieldDefn->ePostgisType == GEOM_TYPE_GEOMETRY || poGeomFieldDefn->ePostgisType == GEOM_TYPE_GEOGRAPHY ) { if( m_poFilterGeom != NULL) { char szBox3D_1[128]; char szBox3D_2[128]; OGREnvelope sEnvelope; m_poFilterGeom->getEnvelope( &sEnvelope ); if( poGeomFieldDefn->ePostgisType == GEOM_TYPE_GEOGRAPHY ) { if( sEnvelope.MinX < -180.0 ) sEnvelope.MinX = -180.0; if( sEnvelope.MinY < -90.0 ) sEnvelope.MinY = -90.0; if( sEnvelope.MaxX > 180.0 ) sEnvelope.MaxX = 180.0; if( sEnvelope.MaxY > 90.0 ) sEnvelope.MaxY = 90.0; } CPLsnprintf(szBox3D_1, sizeof(szBox3D_1), "%.18g %.18g", sEnvelope.MinX, sEnvelope.MinY); CPLsnprintf(szBox3D_2, sizeof(szBox3D_2), "%.18g %.18g", sEnvelope.MaxX, sEnvelope.MaxY); osWHERE.Printf("WHERE %s && %s('BOX3D(%s, %s)'::box3d,%d) ", OGRPGEscapeColumnName(poGeomFieldDefn->GetNameRef()).c_str(), (poDS->sPostGISVersion.nMajor >= 2) ? "ST_SetSRID" : "SetSRID", szBox3D_1, szBox3D_2, poGeomFieldDefn->nSRSId ); } else { osWHERE = ""; } BuildFullQueryStatement(); } ResetReading(); } }
// A Document list owns the documents, so is responsible for deleting them void DocumentList::Clear () { for (int i=0, n=_documents.size(); i<n; ++i) { delete _documents[i]; } _documents.clear (); ResetReading (); }
void OGRILI1Layer::JoinSurfaceLayer() { if (poSurfacePolyLayer == 0) return; CPLDebug( "OGR_ILI", "Joining surface layer %s with geometries", GetLayerDefn()->GetName()); GetLayerDefn()->SetGeomType(poSurfacePolyLayer->GetLayerDefn()->GetGeomType()); ResetReading(); while (OGRFeature *feature = GetNextFeatureRef()) { OGRFeature *polyfeature = poSurfacePolyLayer->GetFeatureRef(feature->GetFID()); if (polyfeature) { feature->SetGeometry(polyfeature->GetGeometryRef()); } } ResetReading(); poSurfacePolyLayer = 0; }
void OGROGDILayer::SetSpatialFilter( OGRGeometry * poGeomIn ) { if( !InstallFilter( poGeomIn ) ) return; ResetReading(); m_nTotalShapeCount = -1; }
OGRDXFBlocksLayer::OGRDXFBlocksLayer( OGRDXFDataSource *poDSIn ) : poDS(poDSIn), poFeatureDefn(new OGRFeatureDefn( "blocks" )) { ResetReading(); poFeatureDefn->Reference(); poDS->AddStandardFields( poFeatureDefn ); }
void OGRIngresTableLayer::SetSpatialFilter( OGRGeometry * poGeomIn ) { if( !InstallFilter( poGeomIn ) ) return; BuildWhere(); ResetReading(); }
int OGRLayer::GetFeatureCount( int bForce ) { OGRFeature *poFeature; int nFeatureCount = 0; if( !bForce ) return -1; ResetReading(); while( (poFeature = GetNextFeature()) != NULL ) { nFeatureCount++; delete poFeature; } ResetReading(); return nFeatureCount; }
OGRErr OGROGDILayer::SetAttributeFilter( const char *pszQuery ) { OGRErr eErr = OGRLayer::SetAttributeFilter(pszQuery); ResetReading(); m_nTotalShapeCount = -1; return eErr; }
void OGRSQLiteTableLayer::SetSpatialFilter( OGRGeometry * poGeomIn ) { if( InstallFilter( poGeomIn ) ) { BuildWhere(); ResetReading(); } }
OGRGMELayer::~OGRGMELayer() { SyncToDisk(); ResetReading(); if( poSRS ) poSRS->Release(); if( poFeatureDefn ) poFeatureDefn->Release(); }
void OGRWarpedLayer::SetSpatialFilter( int iGeomField, OGRGeometry *poGeom ) { if( iGeomField < 0 || iGeomField >= GetLayerDefn()->GetGeomFieldCount() ) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid geometry field index : %d", iGeomField); return; } m_iGeomFieldFilter = iGeomField; if( InstallFilter( poGeom ) ) ResetReading(); if( m_iGeomFieldFilter == m_iGeomField ) { if( poGeom == NULL || m_poReversedCT == NULL ) { m_poDecoratedLayer->SetSpatialFilter(m_iGeomFieldFilter, NULL); } else { OGREnvelope sEnvelope; poGeom->getEnvelope(&sEnvelope); if( CPLIsInf(sEnvelope.MinX) && CPLIsInf(sEnvelope.MinY) && CPLIsInf(sEnvelope.MaxX) && CPLIsInf(sEnvelope.MaxY) ) { m_poDecoratedLayer->SetSpatialFilterRect(m_iGeomFieldFilter, sEnvelope.MinX, sEnvelope.MinY, sEnvelope.MaxX, sEnvelope.MaxY); } else if( ReprojectEnvelope(&sEnvelope, m_poReversedCT) ) { m_poDecoratedLayer->SetSpatialFilterRect(m_iGeomFieldFilter, sEnvelope.MinX, sEnvelope.MinY, sEnvelope.MaxX, sEnvelope.MaxY); } else { m_poDecoratedLayer->SetSpatialFilter(m_iGeomFieldFilter, NULL); } } } else { m_poDecoratedLayer->SetSpatialFilter(m_iGeomFieldFilter, poGeom); } }