]> granicus.if.org Git - postgis/commitdiff
Make one-point lines convertible to GEOS, see #1543
authorSandro Santilli <strk@keybit.net>
Tue, 14 Feb 2012 13:31:22 +0000 (13:31 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 14 Feb 2012 13:31:22 +0000 (13:31 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9184 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwgeom_geos.c
regress/tickets.sql
regress/tickets_expected

index a119418b9f9a759b077303f493882d0e31750997..deb5593f34e8feffc6eb6def2e8f0b033f9bbf0e 100644 (file)
@@ -297,6 +297,13 @@ LWGEOM2GEOS(const LWGEOM *lwgeom)
                break;
        case LINETYPE:
                lwl = (LWLINE *)lwgeom;
+               if ( lwl->points->npoints == 1 ) {
+                       /* Duplicate point, to make geos-friendly */
+                       lwl->points = ptarray_addPoint(lwl->points,
+                                          getPoint_internal(lwl->points, 0),
+                                          FLAGS_NDIMS(lwl->points->flags),
+                                          lwl->points->npoints);
+               }
                sq = ptarray_to_GEOSCoordSeq(lwl->points);
                g = GEOSGeom_createLineString(sq);
                if ( ! g )
@@ -322,6 +329,7 @@ LWGEOM2GEOS(const LWGEOM *lwgeom)
                else
                {
                        sq = ptarray_to_GEOSCoordSeq(lwpoly->rings[0]);
+                       /* TODO: check ring for being closed and fix if not */
                        shell = GEOSGeom_createLinearRing(sq);
                        if ( ! shell ) return NULL;
                        /*lwerror("LWGEOM2GEOS: exception during polygon shell conversion"); */
index 680661c511b3dceb949502c970af5c4d5969eb89..615826466de40b130e8cebe7ab08377f24bcf492 100644 (file)
@@ -590,6 +590,12 @@ select '#1042',round((st_ymax(st_minimumboundingcircle('LINESTRING(-1 -1, 1 1)')
 select '#1398a', st_astext(st_snaptogrid(st_project('POINT(-120 45)'::geography, 100000, radians(45))::geometry,0.000001));
 select '#1398b', st_astext(st_snaptogrid(st_project('POINT(20 85)'::geography, 2000000, radians(0.1))::geometry,0.000001));
 
+-- #1543
+with inp as ( select 
+'0105000000020000000102000000040000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000000001020000000100000000000000000000000000000000000000'
+::geometry as g )
+select '#1543', st_astext(g), st_astext(st_buildarea(g)) from inp;
+
 -- Clean up
 DELETE FROM spatial_ref_sys;
 
index 681279cc893418ea96ec94047065fa565c6f6987..9b7c567742911b47d8fbaf7a0a98c315b19a0a97 100644 (file)
@@ -67,10 +67,10 @@ NOTICE:  No points or linestrings in input array
 #304
 #304.a|21
 #304.b|1
-#408|IllegalArgumentException: point array must contain 0 or >1 elements
-NOTICE:  IllegalArgumentException: point array must contain 0 or >1 elements
+#408|Too few points in geometry component[2310341.45565344 4836396.65124226]
+NOTICE:  Too few points in geometry component at or near point 2310341.4556534393 4836396.6512422552
 #408.1|f
-#408.2|IllegalArgumentException: point array must contain 0 or >1 elements
+#408.2|Too few points in geometry component[0 0]
 NOTICE:  IllegalArgumentException: Invalid number of points in LinearRing found 2 - must be 0 or >= 4
 #408.3|f
 #408.4|IllegalArgumentException: Invalid number of points in LinearRing found 2 - must be 0 or >= 4
@@ -196,3 +196,4 @@ ERROR:  AddToPROJ4SRSCache: couldn't parse proj4 string: '': (null)
 #1042|2
 #1398a|POINT(-119.093153 45.632669)
 #1398b|POINT(-160.137654 77.091608)
+#1543|MULTILINESTRING((0 0,10 0,10 10,0 0),(0 0))|POLYGON((0 0,10 10,10 0,0 0))