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

NAS: fix polygon with composite curves #27

Closed
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
14 changes: 7 additions & 7 deletions gdal/apps/ogr2ogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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 )
Expand Down
10 changes: 10 additions & 0 deletions gdal/ogr/gml2ogrgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
10 changes: 8 additions & 2 deletions gdal/ogr/ogrsf_frmts/nas/ogrnaslayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down