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 *OGRUnionLayer::GetFeature( GIntBig nFeatureId ) { OGRFeature* poFeature = NULL; if( !bPreserveSrcFID ) { poFeature = OGRLayer::GetFeature(nFeatureId); } else { int iGeomFieldFilterSave = m_iGeomFieldFilter; OGRGeometry* poGeomSave = m_poFilterGeom; m_poFilterGeom = NULL; SetSpatialFilter(NULL); for(int i=0;i<nSrcLayers;i++) { iCurLayer = i; ConfigureActiveLayer(); OGRFeature* poSrcFeature = papoSrcLayers[i]->GetFeature(nFeatureId); if( poSrcFeature != NULL ) { poFeature = TranslateFromSrcLayer(poSrcFeature); delete poSrcFeature; break; } } SetSpatialFilter(iGeomFieldFilterSave, poGeomSave); delete poGeomSave; ResetReading(); } return poFeature; }
void OGRLayer::SetSpatialFilterRect( double dfMinX, double dfMinY, double dfMaxX, double dfMaxY ) { OGRLinearRing oRing; OGRPolygon oPoly; oRing.addPoint( dfMinX, dfMinY ); oRing.addPoint( dfMinX, dfMaxY ); oRing.addPoint( dfMaxX, dfMaxY ); oRing.addPoint( dfMaxX, dfMinY ); oRing.addPoint( dfMinX, dfMinY ); oPoly.addRing( &oRing ); SetSpatialFilter( &oPoly ); }
void OGRUnionLayer::SetSpatialFilter( OGRGeometry * poGeomIn ) { SetSpatialFilter(0, poGeomIn); }
void OGRWarpedLayer::SetSpatialFilter( OGRGeometry * poGeom ) { SetSpatialFilter( 0, poGeom ); }