]> granicus.if.org Git - postgis/commitdiff
Fix 2.5d split (#745)
authorSandro Santilli <strk@keybit.net>
Mon, 16 Jan 2012 17:37:12 +0000 (17:37 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 16 Jan 2012 17:37:12 +0000 (17:37 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8847 b70326c6-7e19-0410-871a-916f4a2858ee

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

index c0f8320af052e1a2dbc42dbdfb73b62ec005c568..2904e7af9ef773e52adf6b635b96d78e3e9b079f 100644 (file)
@@ -241,6 +241,8 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in)
        GEOSGeometry* polygons;
        const GEOSGeometry *vgeoms[1];
        int i,n;
+       int hasZ = FLAGS_GET_Z(lwpoly_in->flags);
+
 
        /* Possible outcomes:
         *
@@ -287,12 +289,12 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in)
 
        /* debugging..
                lwnotice("Bounds poly: %s",
-                              lwgeom_to_ewkt(GEOS2LWGEOM(g1_bounds, 0)));
+                              lwgeom_to_ewkt(GEOS2LWGEOM(g1_bounds, hasZ)));
                lwnotice("Line: %s",
-                              lwgeom_to_ewkt(GEOS2LWGEOM(g2, 0)));
+                              lwgeom_to_ewkt(GEOS2LWGEOM(g2, hasZ)));
 
                lwnotice("Noded bounds: %s",
-                              lwgeom_to_ewkt(GEOS2LWGEOM(vgeoms[0], 0)));
+                              lwgeom_to_ewkt(GEOS2LWGEOM(vgeoms[0], hasZ)));
        */
 
        polygons = GEOSPolygonize(vgeoms, 1);
@@ -324,8 +326,8 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in)
         * geometries and return the rest in a collection
         */
        n = GEOSGetNumGeometries(polygons);
-       out = lwcollection_construct(COLLECTIONTYPE, lwpoly_in->srid,
-                                    NULL, 0, NULL);
+       out = lwcollection_construct_empty(COLLECTIONTYPE, lwpoly_in->srid,
+                                    hasZ, 0);
        /* Allocate space for all polys */
        out->geoms = lwalloc(sizeof(LWGEOM*)*n);
        assert(0 == out->ngeoms);
@@ -370,7 +372,7 @@ lwpoly_split_by_line(const LWPOLY* lwpoly_in, const LWLINE* blade_in)
                        continue;
                }
 
-               out->geoms[out->ngeoms++] = GEOS2LWGEOM(p, FLAGS_GET_Z(lwpoly_in->flags));
+               out->geoms[out->ngeoms++] = GEOS2LWGEOM(p, hasZ);
        }
 
        GEOSGeom_destroy(g1);
index 20e6f0da1ac68ce9b4dbb46bf7bd58c8cbe04f54..012850c130b1fc3cd6b60c5515fa448cac40d556 100644 (file)
@@ -521,6 +521,10 @@ SELECT '#1414', st_astext(st_force_3dz('CURVEPOLYGON EMPTY'));
 -- #1478
 SELECT '#1478', 'SRID=1;POINT EMPTY'::geometry::text::geometry;
 
+-- #745 
+SELECT '#745', ST_AsEWKT(ST_Split('POLYGON((-72 42 1,-70 43 1,-71 41 1,-72 42 1))',
+                                  'LINESTRING(-10 40 1,-9 41 1)'));
+
 -- Clean up
 DELETE FROM spatial_ref_sys;
 
index 04264619866853068816fcdb767120e493b59ecf..fd93c25d3761037a9a86435eaade5fbf13ee5e9a 100644 (file)
@@ -174,3 +174,4 @@ ERROR:  MultiSurface cannot contain MultiPoint element
 #1454|t
 #1414|CURVEPOLYGON Z EMPTY
 #1478|01040000200100000000000000
+#745|GEOMETRYCOLLECTION(POLYGON((-72 42 1,-70 43 1,-71 41 1,-72 42 1)))