Skip to content
Permalink
Browse files

[pal] Fixes to geometry handling for point sets

  • Loading branch information
nyalldawson committed Jul 20, 2015
1 parent bd73b76 commit f6d225667efbb54fd62de13037a9e1f59a7f1a1b
Showing with 21 additions and 2 deletions.
  1. +21 −2 src/core/pal/pointset.cpp
@@ -149,14 +149,20 @@ namespace pal
type = ps.type;

holeOf = ps.holeOf;

if ( ps.mGeos )
{
mGeos = GEOSGeom_clone_r( geosContext(), ps.mGeos );
mOwnsGeom = true;
}
}

void PointSet::createGeosGeom() const
{
GEOSContextHandle_t geosctxt = geosContext();

bool needClose = false;
if ( x[0] != x[ nbPoints - 1] || y[0] != y[ nbPoints - 1 ] )
if ( type == GEOS_POLYGON && ( x[0] != x[ nbPoints - 1] || y[0] != y[ nbPoints - 1 ] ) )
{
needClose = true;
}
@@ -175,7 +181,20 @@ namespace pal
GEOSCoordSeq_setY_r( geosctxt, coord, nbPoints, y[0] );
}

mGeos = GEOSGeom_createPolygon_r( geosctxt, GEOSGeom_createLinearRing_r( geosctxt, coord ), 0, 0 );
switch ( type )
{
case GEOS_POLYGON:
mGeos = GEOSGeom_createPolygon_r( geosctxt, GEOSGeom_createLinearRing_r( geosctxt, coord ), 0, 0 );
break;

case GEOS_LINESTRING:
mGeos = GEOSGeom_createLineString_r( geosctxt, coord );
break;

case GEOS_POINT:
mGeos = GEOSGeom_createPoint_r( geosctxt, coord );
break;
}

mOwnsGeom = true;
}

0 comments on commit f6d2256

Please sign in to comment.
You can’t perform that action at this time.