OGRFeature *OGRShapeLayer::FetchShape(int iShapeId) { OGRFeature *poFeature; if (m_poFilterGeom != NULL && hSHP != NULL ) { SHPObject *psShape; psShape = SHPReadObject( hSHP, iShapeId ); // do not trust degenerate bounds or bounds on null shapes. if( psShape == NULL || psShape->dfXMin == psShape->dfXMax || psShape->dfYMin == psShape->dfYMax || psShape->nSHPType == SHPT_NULL ) { poFeature = SHPReadOGRFeature( hSHP, hDBF, poFeatureDefn, iShapeId, psShape ); } else if( m_sFilterEnvelope.MaxX < psShape->dfXMin || m_sFilterEnvelope.MaxY < psShape->dfYMin || psShape->dfXMax < m_sFilterEnvelope.MinX || psShape->dfYMax < m_sFilterEnvelope.MinY ) { SHPDestroyObject(psShape); poFeature = NULL; } else { poFeature = SHPReadOGRFeature( hSHP, hDBF, poFeatureDefn, iShapeId, psShape ); } } else { poFeature = SHPReadOGRFeature( hSHP, hDBF, poFeatureDefn, iShapeId, NULL ); } return poFeature; }
OGRFeature *OGRShapeLayer::GetFeature( long nFeatureId ) { OGRFeature *poFeature = NULL; poFeature = SHPReadOGRFeature( hSHP, hDBF, poFeatureDefn, nFeatureId, NULL); if( poFeature != NULL ) { if( poFeature->GetGeometryRef() != NULL ) poFeature->GetGeometryRef()->assignSpatialReference( poSRS ); m_nFeaturesRead++; return poFeature; } /* * Reading shape feature failed. */ return NULL; }