From: Sandro Santilli Date: Fri, 1 Jul 2011 10:10:27 +0000 (+0000) Subject: Properly convert typed empties coming from GEOS. X-Git-Tag: 2.0.0alpha1~1306 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f6de6b26ea9d5d07f4066576c54b757228e8a091;p=postgis Properly convert typed empties coming from GEOS. git-svn-id: http://svn.osgeo.org/postgis/trunk@7536 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index 7afcd4407..2ff63e025 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -3787,18 +3787,16 @@ GEOS2LWGEOM(const GEOSGeometry *geom, char want3d) case GEOS_POINT: POSTGIS_DEBUG(4, "lwgeom_from_geometry: it's a Point"); cs = GEOSGeom_getCoordSeq(geom); -/* FIXME: dunno how to represent an empty point */ -if ( GEOSisEmpty(geom) ) - return (LWGEOM*)lwcollection_construct_empty(COLLECTIONTYPE, SRID, want3d, 0); + if ( GEOSisEmpty(geom) ) + return (LWGEOM*)lwpoint_construct_empty(SRID, want3d, 0); pa = ptarray_from_GEOSCoordSeq(cs, want3d); return (LWGEOM *)lwpoint_construct(SRID, NULL, pa); case GEOS_LINESTRING: case GEOS_LINEARRING: POSTGIS_DEBUG(4, "lwgeom_from_geometry: it's a LineString or LinearRing"); -/* FIXME: dunno how to represent an empty linestring */ -if ( GEOSisEmpty(geom) ) - return (LWGEOM*)lwcollection_construct_empty(COLLECTIONTYPE, SRID, want3d, 0); + if ( GEOSisEmpty(geom) ) + return (LWGEOM*)lwline_construct_empty(SRID, want3d, 0); cs = GEOSGeom_getCoordSeq(geom); pa = ptarray_from_GEOSCoordSeq(cs, want3d); @@ -3806,10 +3804,8 @@ if ( GEOSisEmpty(geom) ) case GEOS_POLYGON: POSTGIS_DEBUG(4, "lwgeom_from_geometry: it's a Polygon"); - -/* FIXME: dunno how to represent an empty polygon */ -if ( GEOSisEmpty(geom) ) - return (LWGEOM*)lwcollection_construct_empty(COLLECTIONTYPE, SRID, want3d, 0); + if ( GEOSisEmpty(geom) ) + return (LWGEOM*)lwpoly_construct_empty(SRID, want3d, 0); ngeoms = GEOSGetNumInteriorRings(geom); ppaa = lwalloc(sizeof(POINTARRAY *)*(ngeoms+1)); g = GEOSGetExteriorRing(geom); diff --git a/regress/tickets_expected b/regress/tickets_expected index 72085d08a..5c034a116 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -22,7 +22,7 @@ ERROR: Geometry argument does not have an 'M' ordinate #124a|COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,30 5),CIRCULARSTRING(30 5,34 56,67 89)) ERROR: incontinuous compound curve HINT: "...0 6),CIRCULARSTRING(30 5,34 56,67 89)" <-- parse error at position 85 within geometry -#145a|0107000020E610000000000000 +#145a|0103000020E610000000000000 #145b|0 #146|0|t|GEOMETRYCOLLECTION(LINESTRING(0 0,-1 -1),MULTIPOINT(1 2,2 3)) ERROR: Invalid hex string, length (267) has to be a multiple of two!