diff --git a/gdal/apps/ogr2ogr.cpp b/gdal/apps/ogr2ogr.cpp index 0dc0f5a79bcf..0c814cc3290b 100644 --- a/gdal/apps/ogr2ogr.cpp +++ b/gdal/apps/ogr2ogr.cpp @@ -3396,16 +3396,16 @@ static int TranslateLayer( TargetLayerInfo* psInfo, /* Optimization to avoid duplicating the source geometry in the */ /* target feature : we steal it from the source feature for now... */ - OGRGeometry* poStealedGeometry = NULL; + OGRGeometry* poStolenGeometry = NULL; if( !bExplodeCollections && nSrcGeomFieldCount == 1 && nDstGeomFieldCount == 1 ) { - poStealedGeometry = poFeature->StealGeometry(); + poStolenGeometry = poFeature->StealGeometry(); } else if( !bExplodeCollections && psInfo->iRequestedSrcGeomField >= 0 ) { - poStealedGeometry = poFeature->StealGeometry( + poStolenGeometry = poFeature->StealGeometry( psInfo->iRequestedSrcGeomField); } @@ -3420,14 +3420,14 @@ static int TranslateLayer( TargetLayerInfo* psInfo, OGRFeature::DestroyFeature( poFeature ); OGRFeature::DestroyFeature( poDstFeature ); - OGRGeometryFactory::destroyGeometry( poStealedGeometry ); + OGRGeometryFactory::destroyGeometry( poStolenGeometry ); return FALSE; } - /* ... and now we can attach the stealed geometry */ - if( poStealedGeometry ) + /* ... and now we can attach the stolen geometry */ + if( poStolenGeometry ) { - poDstFeature->SetGeometryDirectly(poStealedGeometry); + poDstFeature->SetGeometryDirectly(poStolenGeometry); } if( bPreserveFID ) diff --git a/gdal/ogr/gml2ogrgeometry.cpp b/gdal/ogr/gml2ogrgeometry.cpp index b7a8f8dcf5ff..6aec8bc53475 100644 --- a/gdal/ogr/gml2ogrgeometry.cpp +++ b/gdal/ogr/gml2ogrgeometry.cpp @@ -769,6 +769,16 @@ OGRGeometry *GML2OGRGeometry_XMLNode( const CPLXMLNode *psNode, else poLS = NULL; + // try to join multiline string to one linestring + if( poLS && wkbFlatten(poLS->getGeometryType()) == wkbMultiLineString ) + { + OGRGeometry *poG = OGRGeometryFactory::forceToLineString( poLS, false ); + if( poG && wkbFlatten( poG->getGeometryType() ) == wkbLineString ) + { + poLS = (OGRLineString *) poG; + } + } + if( poLS == NULL || wkbFlatten(poLS->getGeometryType()) != wkbLineString ) { diff --git a/gdal/ogr/ogrsf_frmts/nas/ogrnaslayer.cpp b/gdal/ogr/ogrsf_frmts/nas/ogrnaslayer.cpp index 47fb1730ab13..8d4cb433450a 100644 --- a/gdal/ogr/ogrsf_frmts/nas/ogrnaslayer.cpp +++ b/gdal/ogr/ogrsf_frmts/nas/ogrnaslayer.cpp @@ -248,9 +248,15 @@ OGRFeature *OGRNASLayer::GetNextFeature() /* -------------------------------------------------------------------- */ /* Wow, we got our desired feature. Return it. */ /* -------------------------------------------------------------------- */ - delete poNASFeature; + if( poGeom && poOGRFeature->SetGeometryDirectly( poGeom ) != OGRERR_NONE ) + { + int iId = poNASFeature->GetClass()->GetPropertyIndex( "gml_id" ); + const GMLProperty *poIdProp = poNASFeature->GetProperty(iId); + CPLError( CE_Warning, CPLE_AppDefined, "NAS: could not set geometry (gml_id:%s)", + poIdProp && poIdProp->nSubProperties>0 && poIdProp->papszSubProperties[0] ? poIdProp->papszSubProperties[0] : "(null)" ); + } - poOGRFeature->SetGeometryDirectly( poGeom ); + delete poNASFeature; return poOGRFeature; }