OGRFeature *OGRIDBLayer::GetNextRawFeature() { if( GetQuery() == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* If we are marked to restart then do so, and fetch a record. */ /* -------------------------------------------------------------------- */ ITRow * row = poCurr->NextRow(); if ( ! row ) { delete poCurr; poCurr = NULL; return NULL; } iNextShapeId++; m_nFeaturesRead++; /* -------------------------------------------------------------------- */ /* Create a feature from the current result. */ /* -------------------------------------------------------------------- */ int iField; OGRFeature *poFeature = new OGRFeature( poFeatureDefn ); const ITTypeInfo * poRowType = poCurr->RowType(); int nFieldCount = poRowType->ColumnCount(); for ( iField = 0; iField < nFieldCount; iField++ ) { /* -------------------------------------------------------------------- */ /* Handle FID column */ /* -------------------------------------------------------------------- */ if ( pszFIDColumn != NULL && EQUAL( poRowType->ColumnName( iField ), pszFIDColumn ) ) poFeature->SetFID( atoi( row->Column( iField )->Printable() ) ); /* -------------------------------------------------------------------- */ /* Handle geometry */ /* -------------------------------------------------------------------- */ if( pszGeomColumn != NULL && EQUAL( poRowType->ColumnName( iField ), pszGeomColumn ) ) { OGRGeometry *poGeom = NULL; OGRErr eErr = OGRERR_NONE; ITValue * v = row->Column( iField ); if( ! v->IsNull() && ! bGeomColumnWKB ) { const char *pszGeomText = v->Printable(); if ( pszGeomText != NULL ) eErr = OGRGeometryFactory::createFromWkt((char **) &pszGeomText, poSRS, &poGeom); } else if( ! v->IsNull() && bGeomColumnWKB ) { ITDatum *rv = 0; if ( v->QueryInterface( ITDatumIID, (void **) &rv ) == IT_QUERYINTERFACE_SUCCESS ) { int nLength = rv->DataLength(); unsigned char * wkb = (unsigned char *)rv->Data(); eErr = OGRGeometryFactory::createFromWkb( wkb, poSRS, &poGeom, nLength); rv->Release(); } } v->Release(); if ( eErr != OGRERR_NONE ) { const char *pszMessage; switch ( eErr ) { case OGRERR_NOT_ENOUGH_DATA: pszMessage = "Not enough data to deserialize"; break; case OGRERR_UNSUPPORTED_GEOMETRY_TYPE: pszMessage = "Unsupported geometry type"; break; case OGRERR_CORRUPT_DATA: pszMessage = "Corrupt data"; default: pszMessage = "Unrecognized error"; } CPLError(CE_Failure, CPLE_AppDefined, "GetNextRawFeature(): %s", pszMessage); } if( poGeom != NULL ) { poFeature->SetGeometryDirectly( poGeom ); } continue; } /* -------------------------------------------------------------------- */ /* Transfer regular data fields. */ /* -------------------------------------------------------------------- */ int iOGRField = poFeatureDefn->GetFieldIndex( poRowType->ColumnName( iField ) ); if( iOGRField < 0 ) continue; const char * pszColData = row->Column( iField )->Printable(); if( ! pszColData ) continue; if( poFeatureDefn->GetFieldDefn(iOGRField)->GetType() == OFTBinary ) poFeature->SetField( iOGRField, poRowType->ColumnType( iField )->Size(), (GByte *) pszColData ); else poFeature->SetField( iOGRField, pszColData ); } row->Release(); return poFeature; }