]> granicus.if.org Git - postgis/commitdiff
Fix equality operator between EMPTY and point on origin (#2110)
authorSandro Santilli <strk@keybit.net>
Mon, 4 Mar 2013 17:57:55 +0000 (17:57 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 4 Mar 2013 17:57:55 +0000 (17:57 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@11142 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_btree.c
regress/tickets.sql
regress/tickets_expected

index 12bc1162ce07c439182c67d574708c7253c8d841..35373208256c2c24183c11f12695b8ad17d29a57 100644 (file)
@@ -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;
index 5f93b1e6fa04d41a5271467c576b22b82bf65b26..3f4f03bf58ef40f24d4fbb1f6d7920f61e31447c 100644 (file)
@@ -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);
index 446f44130f593e0fa9574fb81f7b222d6101daa4..b104a7f809576668989240cf422dd8b4edeaf653 100644 (file)
@@ -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