Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add string TID support to interlis 1 driver #91

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion gdal/ogr/ogrsf_frmts/ili/ogr_ili1.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class OGRILI1Layer : public OGRLayer
void ResetReading();
OGRFeature * GetNextFeature();
OGRFeature * GetNextFeatureRef();
OGRFeature * GetFeatureRef( long nFID );
OGRFeature * GetFeatureRef( long nFid );
OGRFeature * GetFeatureRef( const char* );

GIntBig GetFeatureCount( int bForce = TRUE );

Expand Down
30 changes: 26 additions & 4 deletions gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ OGRFeature *OGRILI1Layer::GetFeatureRef( long nFID )
return NULL;
}

OGRFeature *OGRILI1Layer::GetFeatureRef( const char *fid )

{
OGRFeature *poFeature;

ResetReading();
while( (poFeature = GetNextFeatureRef()) != NULL )
{
if( !strcmp( poFeature->GetFieldAsString(0), fid ) )
return poFeature;
}

return NULL;
}

/************************************************************************/
/* GetFeatureCount() */
/************************************************************************/
Expand Down Expand Up @@ -489,9 +504,16 @@ void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer,
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);
OGRFeature *feature;
if (poFeatureDefn->GetFieldDefn(0)->GetType() == OFTString)
{
feature = GetFeatureRef(linefeature->GetFieldAsString(1));
}
else
{
GIntBig reftid = linefeature->GetFieldAsInteger64(1);
feature = GetFeatureRef((int)reftid);
}
if (feature) {
if (!feature->GetGeomFieldRef(nSurfaceFieldIndex)) {
OGRCurvePolygon *newpoly = (geomType == wkbPolygon) ?
Expand Down Expand Up @@ -548,7 +570,7 @@ void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer,
}
} else {
CPLError( CE_Warning, CPLE_AppDefined,
"Couldn't join feature FID " CPL_FRMT_GIB, reftid );
"Couldn't join feature FID " CPL_FRMT_GIB, linefeature->GetFieldAsInteger64(1) );
}
}

Expand Down