Skip to content

Commit

Permalink
[pal] Fixes to geometry handling for point sets
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 20, 2015
1 parent bd73b76 commit f6d2256
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/core/pal/pointset.cpp
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit f6d2256

Please sign in to comment.