]> granicus.if.org Git - postgis/commitdiff
Allow dumping polygons with empty rings, fixing bug #937, add unit testing for that...
authorSandro Santilli <strk@keybit.net>
Thu, 5 May 2011 21:12:43 +0000 (21:12 +0000)
committerSandro Santilli <strk@keybit.net>
Thu, 5 May 2011 21:12:43 +0000 (21:12 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7102 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_out_wkb.c
liblwgeom/lwout_wkb.c

index d2768fa7a6db20f0f08c2e4a697365ffd54d86cd..3cc3c2b35edfc0a5da53d10a9ad409218bd54913 100644 (file)
@@ -48,6 +48,16 @@ static int clean_wkb_out_suite(void)
        return 0;
 }
 
+static void cu_wkb_out_from_hexwkb(char *hexwkb)
+{
+       LWGEOM *g = lwgeom_from_hexwkb(hexwkb, PARSER_CHECK_NONE);
+       if ( s ) free(s);
+       if ( t ) free(t);
+       s = lwgeom_to_wkb(g, WKB_HEX | WKB_XDR | WKB_EXTENDED, NULL);
+       t = lwgeom_to_hexwkb_old(g, PARSER_CHECK_NONE, XDR);
+       lwgeom_free(g);
+}
+
 static void cu_wkb_out(char *wkt)
 {
        LWGEOM *g = lwgeom_from_ewkt(wkt, PARSER_CHECK_NONE);
@@ -97,6 +107,13 @@ static void test_wkb_out_polygon(void)
        cu_wkb_out("POLYGON EMPTY");
 //     printf("new: %s\nold: %s\n",s,t);
        CU_ASSERT_STRING_EQUAL(s, t);
+
+       /*
+        * POLYGON with EMPTY shell
+        * See http://http://trac.osgeo.org/postgis/ticket/937
+        */
+       cu_wkb_out_from_hexwkb("01030000000100000000000000");
+       CU_ASSERT_STRING_EQUAL(s, t);
 }
 
 static void test_wkb_out_multipoint(void) 
index 58b9948d83209f3034bafd584da0fe8592131854..25cf1296f857665e82e6ffadf6cb6336640391eb 100644 (file)
@@ -310,8 +310,12 @@ static size_t ptarray_to_wkb_size(const POINTARRAY *pa, uchar variant)
 {
        int dims = 2;
        size_t size = 0;
+#if 0
+/* see http://trac.osgeo.org/postgis/ticket/937 */
        if ( pa->npoints < 1 )
                return 0;
+#endif
+
        if ( variant & (WKB_ISO | WKB_EXTENDED) )
                dims = FLAGS_NDIMS(pa->flags);
 
@@ -331,12 +335,15 @@ static uchar* ptarray_to_wkb_buf(const POINTARRAY *pa, uchar *buf, uchar variant
        int i, j;
        double *dbl_ptr;
 
+#if 0
+/* see http://trac.osgeo.org/postgis/ticket/937 */
        /* Nothing to do with a pointarray with no ordinates */
        if ( pa->npoints < 1 )
        {
-               lwerror("Point array has < 1 ordinates!");
+               lwnotice("Point array has < 1 ordinates!");
                return buf;
        }
+#endif
 
        /* SFSQL is always 2-d. Extended and ISO use all available dimensions */
        if ( (variant & WKB_ISO) || (variant & WKB_EXTENDED) )