]> granicus.if.org Git - postgis/commitdiff
#2015, ST_IsEmpty('POLYGON EMPTY') returns False
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 2 Nov 2012 21:14:44 +0000 (21:14 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 2 Nov 2012 21:14:44 +0000 (21:14 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10630 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_out_wkb.c
liblwgeom/lwcircstring.c
liblwgeom/lwline.c
liblwgeom/lwout_wkt.c
liblwgeom/lwpoint.c
liblwgeom/lwpoly.c
liblwgeom/lwtriangle.c

index 16fca0ecab2132a6b0c6853536a35c8ede0deab0..cd5dcfdea2cf2998bde3adc1b85181625b141524 100644 (file)
@@ -107,7 +107,7 @@ static void test_wkb_out_polygon(void)
        *  See http://http://trac.osgeo.org/postgis/ticket/937
        */
        cu_wkb_from_hexwkb("01030000000100000000000000");
-       CU_ASSERT_STRING_EQUAL(s,"00000000030000000100000000");
+       CU_ASSERT_STRING_EQUAL(s,"000000000300000000");
 }
 
 static void test_wkb_out_multipoint(void) 
index 41c16574fe5443716ea227547c166a0727708977..d5aff562ae65b6a5f0279a96eb37b6aa80540e3b 100644 (file)
@@ -262,7 +262,7 @@ lwcircstring_is_closed(const LWCIRCSTRING *curve)
 
 int lwcircstring_is_empty(const LWCIRCSTRING *circ)
 {
-       if ( !circ->points || circ->points->npoints == 0 )
+       if ( !circ->points || circ->points->npoints < 1 )
                return LW_TRUE;
        return LW_FALSE;
 }
index c46585db9e54d6e350cfc6b249e5bdb67edd6964..84cff91f1da36bcbd35800af0850edf20e447d3d 100644 (file)
@@ -456,7 +456,7 @@ lwline_force_dims(const LWLINE *line, int hasz, int hasm)
 
 int lwline_is_empty(const LWLINE *line)
 {
-       if ( !line->points || line->points->npoints == 0 )
+       if ( !line->points || line->points->npoints < 1 )
                return LW_TRUE;
        return LW_FALSE;
 }
index 77c9025a79ffb7204b5a5a4282756e987f04ae00..4e3b9db6fdfbd09150802922328a56b065c59bc9 100644 (file)
@@ -121,7 +121,7 @@ static void lwpoint_to_wkt_sb(const LWPOINT *pt, stringbuffer_t *sb, int precisi
                dimension_qualifiers_to_wkt_sb((LWGEOM*)pt, sb, variant);
        }
 
-       if ( (! pt->point) || (pt->point->npoints < 1) )
+       if ( lwpoint_is_empty(pt) )
        {
                empty_to_wkt_sb(sb);
                return;
@@ -140,7 +140,7 @@ static void lwline_to_wkt_sb(const LWLINE *line, stringbuffer_t *sb, int precisi
                stringbuffer_append(sb, "LINESTRING"); /* "LINESTRING" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)line, sb, variant);
        }
-       if ( (! line->points) || (line->points->npoints < 1) )
+       if ( lwline_is_empty(line) )
        {  
                empty_to_wkt_sb(sb);
                return;
@@ -160,7 +160,7 @@ static void lwpoly_to_wkt_sb(const LWPOLY *poly, stringbuffer_t *sb, int precisi
                stringbuffer_append(sb, "POLYGON"); /* "POLYGON" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)poly, sb, variant);
        }
-       if ( poly->nrings < 1 )
+       if ( lwpoly_is_empty(poly) )
        {
                empty_to_wkt_sb(sb);
                return;
@@ -186,7 +186,7 @@ static void lwcircstring_to_wkt_sb(const LWCIRCSTRING *circ, stringbuffer_t *sb,
                stringbuffer_append(sb, "CIRCULARSTRING"); /* "CIRCULARSTRING" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)circ, sb, variant);
        }
-       if ( (! circ->points) || (circ->points->npoints < 1) )
+       if ( lwcircstring_is_empty(circ) )
        {
                empty_to_wkt_sb(sb);
                return;
@@ -508,7 +508,7 @@ static void lwtriangle_to_wkt_sb(const LWTRIANGLE *tri, stringbuffer_t *sb, int
                stringbuffer_append(sb, "TRIANGLE"); /* "TRIANGLE" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)tri, sb, variant);
        }
-       if ( (! tri->points) || (tri->points->npoints < 1) )
+       if ( lwtriangle_is_empty(tri) )
        {  
                empty_to_wkt_sb(sb);
                return;
index 28f25632f40a6de51f015eb54453ebde5c2751a8..9da1a3a0983a2091768fc11bff2772e11449ace5 100644 (file)
@@ -257,7 +257,7 @@ lwpoint_force_dims(const LWPOINT *point, int hasz, int hasm)
 
 int lwpoint_is_empty(const LWPOINT *point)
 {
-       if ( ! point->point || point->point->npoints == 0 )
+       if ( ! point->point || point->point->npoints < 1 )
                return LW_TRUE;
        return LW_FALSE;
 }
index 119bc61c375ae642e037c9c977a1695630af9ee2..c6b6dcbe0e9b3c0f907eeb596615bb0c6e2a788f 100644 (file)
@@ -325,7 +325,7 @@ lwpoly_force_dims(const LWPOLY *poly, int hasz, int hasm)
 
 int lwpoly_is_empty(const LWPOLY *poly)
 {
-       if ( (poly->nrings == 0) || (!poly->rings) )
+       if ( (poly->nrings < 1) || (!poly->rings) || (!poly->rings[0]) || (poly->rings[0]->npoints < 1) )
                return LW_TRUE;
        return LW_FALSE;
 }
index d36f5a98b8b4cbf7c1d8a6c8f673a9124cf86f92..54d66fca24600de6fad80c6416f7aba9f46b8095 100644 (file)
@@ -161,7 +161,7 @@ lwtriangle_is_repeated_points(LWTRIANGLE *triangle)
 
 int lwtriangle_is_empty(const LWTRIANGLE *triangle)
 {
-       if ( !triangle->points || triangle->points->npoints == 0 )
+       if ( !triangle->points || triangle->points->npoints < 1 )
                return LW_TRUE;
        return LW_FALSE;
 }