Skip to content

Commit 48a6a33

Browse files
author
rouault
committed
ILI1: add string TID support (patch by m-kuhn, OSGeo/gdal#91)
git-svn-id: https://svn.osgeo.org/gdal/trunk/gdal@33325 f0d54148-0727-0410-94bb-9a71ac55c965
1 parent 4c181ad commit 48a6a33

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

ogr/ogrsf_frmts/ili/ogr_ili1.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class OGRILI1Layer : public OGRLayer
7070
void ResetReading();
7171
OGRFeature * GetNextFeature();
7272
OGRFeature * GetNextFeatureRef();
73-
OGRFeature * GetFeatureRef( long nFID );
73+
OGRFeature * GetFeatureRef( long nFid );
74+
OGRFeature * GetFeatureRef( const char* );
7475

7576
GIntBig GetFeatureCount( int bForce = TRUE );
7677

ogr/ogrsf_frmts/ili/ogrili1layer.cpp

+26-4
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ OGRFeature *OGRILI1Layer::GetFeatureRef( long nFID )
145145
return NULL;
146146
}
147147

148+
OGRFeature *OGRILI1Layer::GetFeatureRef( const char *fid )
149+
150+
{
151+
OGRFeature *poFeature;
152+
153+
ResetReading();
154+
while( (poFeature = GetNextFeatureRef()) != NULL )
155+
{
156+
if( !strcmp( poFeature->GetFieldAsString(0), fid ) )
157+
return poFeature;
158+
}
159+
160+
return NULL;
161+
}
162+
148163
/************************************************************************/
149164
/* GetFeatureCount() */
150165
/************************************************************************/
@@ -489,9 +504,16 @@ void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer,
489504
poSurfaceLineLayer->ResetReading();
490505
while (OGRFeature *linefeature = poSurfaceLineLayer->GetNextFeatureRef()) {
491506
//OBJE entries with same _RefTID are polygon rings of same feature
492-
//TODO: non-numeric _RefTID/FID is not supported yet!
493-
GIntBig reftid = linefeature->GetFieldAsInteger64(1); //_RefTID
494-
OGRFeature *feature = GetFeatureRef((int)reftid);
507+
OGRFeature *feature;
508+
if (poFeatureDefn->GetFieldDefn(0)->GetType() == OFTString)
509+
{
510+
feature = GetFeatureRef(linefeature->GetFieldAsString(1));
511+
}
512+
else
513+
{
514+
GIntBig reftid = linefeature->GetFieldAsInteger64(1);
515+
feature = GetFeatureRef((int)reftid);
516+
}
495517
if (feature) {
496518
if (!feature->GetGeomFieldRef(nSurfaceFieldIndex)) {
497519
OGRCurvePolygon *newpoly = (geomType == wkbPolygon) ?
@@ -548,7 +570,7 @@ void OGRILI1Layer::JoinSurfaceLayer( OGRILI1Layer* poSurfaceLineLayer,
548570
}
549571
} else {
550572
CPLError( CE_Warning, CPLE_AppDefined,
551-
"Couldn't join feature FID " CPL_FRMT_GIB, reftid );
573+
"Couldn't join feature FID " CPL_FRMT_GIB, linefeature->GetFieldAsInteger64(1) );
552574
}
553575
}
554576

0 commit comments

Comments
 (0)