From: Sandro Santilli Date: Mon, 4 Mar 2013 17:57:55 +0000 (+0000) Subject: Fix equality operator between EMPTY and point on origin (#2110) X-Git-Tag: 2.1.0beta2~186 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7325caadf58675e37b05af633f72157f2a5e4580;p=postgis Fix equality operator between EMPTY and point on origin (#2110) git-svn-id: http://svn.osgeo.org/postgis/trunk@11142 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_btree.c b/postgis/lwgeom_btree.c index 12bc1162c..353732082 100644 --- a/postgis/lwgeom_btree.c +++ b/postgis/lwgeom_btree.c @@ -168,6 +168,7 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS) GSERIALIZED *geom2 = (GSERIALIZED *) PG_DETOAST_DATUM(PG_GETARG_DATUM(1)); GBOX box1; GBOX box2; + bool empty1, empty2; bool result; POSTGIS_DEBUG(2, "lwgeom_eq called"); @@ -181,12 +182,16 @@ Datum lwgeom_eq(PG_FUNCTION_ARGS) PG_RETURN_NULL(); } - gserialized_get_gbox_p(geom1, &box1); - gserialized_get_gbox_p(geom2, &box2); + empty1 = ( gserialized_get_gbox_p(geom1, &box1) == LW_FAILURE ); + empty2 = ( gserialized_get_gbox_p(geom2, &box2) == LW_FAILURE ); PG_FREE_IF_COPY(geom1, 0); PG_FREE_IF_COPY(geom2, 1); - if ( ! (FPeq(box1.xmin, box2.xmin) && FPeq(box1.ymin, box2.ymin) && + if ( empty1 != empty2 ) + { + result = FALSE; + } + else if ( ! (FPeq(box1.xmin, box2.xmin) && FPeq(box1.ymin, box2.ymin) && FPeq(box1.xmax, box2.xmax) && FPeq(box1.ymax, box2.ymax)) ) { result = FALSE; diff --git a/regress/tickets.sql b/regress/tickets.sql index 5f93b1e6f..3f4f03bf5 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -807,6 +807,10 @@ FROM (SELECT 'POLYGON((1 1 1, 5 1 1,5 5 1, 1 5 1,1 1 1))'::geometry as a, 'LINES SELECT '#2108', ST_AsEWKT(ST_Line_Interpolate_Point('SRID=3395;LINESTRING M EMPTY'::geometry, 0.5)); SELECT '#2117', ST_AsEWKT(ST_PointOnSurface('SRID=3395;MULTIPOLYGON M EMPTY'::geometry)); +SELECT '#2110.1', 'POINT(0 0)'::geometry = 'POINT EMPTY'::geometry; +SELECT '#2110.2', 'POINT EMPTY'::geometry = 'POINT EMPTY'::geometry; +SELECT '#2110.3', 'POINT(0 0)'::geometry = 'POINT(0 0)'::geometry; + SELECT '#2145', round(ST_Length(St_Segmentize(ST_GeographyFromText('LINESTRING(-89.3000030518 28.2000007629,-89.1999969482 89.1999969482,-89.1999969482 89.1999969482)'), 10000))::numeric,0); diff --git a/regress/tickets_expected b/regress/tickets_expected index 446f44130..b104a7f80 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -235,4 +235,7 @@ ERROR: invalid GML representation #2112b|1|LINESTRING(1 1 1,1 0 1) #2108|SRID=3395;POINTM EMPTY #2117|SRID=3395;POINTM EMPTY +#2110.1|f +#2110.2|t +#2110.3|t #2145|6792004