From 9819ed511ac41017445394a6b2ce60ebe4c8c334 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Tue, 2 Feb 2016 11:09:52 +0100 Subject: [PATCH] Add string TID support to interlis 1 driver --- gdal/ogr/ogrsf_frmts/ili/ogr_ili1.h | 3 ++- gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp | 30 ++++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/gdal/ogr/ogrsf_frmts/ili/ogr_ili1.h b/gdal/ogr/ogrsf_frmts/ili/ogr_ili1.h index 59562b21a6c5..c085fec79502 100644 --- a/gdal/ogr/ogrsf_frmts/ili/ogr_ili1.h +++ b/gdal/ogr/ogrsf_frmts/ili/ogr_ili1.h @@ -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 ); diff --git a/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp b/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp index 3eebe7141371..d898e80cbcd6 100644 --- a/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp +++ b/gdal/ogr/ogrsf_frmts/ili/ogrili1layer.cpp @@ -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() */ /************************************************************************/ @@ -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) ? @@ -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) ); } }