From: Paul Ramsey Date: Fri, 2 Nov 2012 21:14:44 +0000 (+0000) Subject: #2015, ST_IsEmpty('POLYGON EMPTY') returns False X-Git-Tag: 2.1.0beta2~423 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=441a7b3fe7c0f753ab85edc4f882a806cdcd2cf2;p=postgis #2015, ST_IsEmpty('POLYGON EMPTY') returns False git-svn-id: http://svn.osgeo.org/postgis/trunk@10630 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/cunit/cu_out_wkb.c b/liblwgeom/cunit/cu_out_wkb.c index 16fca0eca..cd5dcfdea 100644 --- a/liblwgeom/cunit/cu_out_wkb.c +++ b/liblwgeom/cunit/cu_out_wkb.c @@ -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) diff --git a/liblwgeom/lwcircstring.c b/liblwgeom/lwcircstring.c index 41c16574f..d5aff562a 100644 --- a/liblwgeom/lwcircstring.c +++ b/liblwgeom/lwcircstring.c @@ -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; } diff --git a/liblwgeom/lwline.c b/liblwgeom/lwline.c index c46585db9..84cff91f1 100644 --- a/liblwgeom/lwline.c +++ b/liblwgeom/lwline.c @@ -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; } diff --git a/liblwgeom/lwout_wkt.c b/liblwgeom/lwout_wkt.c index 77c9025a7..4e3b9db6f 100644 --- a/liblwgeom/lwout_wkt.c +++ b/liblwgeom/lwout_wkt.c @@ -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; diff --git a/liblwgeom/lwpoint.c b/liblwgeom/lwpoint.c index 28f25632f..9da1a3a09 100644 --- a/liblwgeom/lwpoint.c +++ b/liblwgeom/lwpoint.c @@ -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; } diff --git a/liblwgeom/lwpoly.c b/liblwgeom/lwpoly.c index 119bc61c3..c6b6dcbe0 100644 --- a/liblwgeom/lwpoly.c +++ b/liblwgeom/lwpoly.c @@ -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; } diff --git a/liblwgeom/lwtriangle.c b/liblwgeom/lwtriangle.c index d36f5a98b..54d66fca2 100644 --- a/liblwgeom/lwtriangle.c +++ b/liblwgeom/lwtriangle.c @@ -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; }