]> granicus.if.org Git - postgis/commitdiff
Update behavior of lwgeom_same to match "orderingequals" semantics (#289)
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 11 Nov 2009 19:57:24 +0000 (19:57 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 11 Nov 2009 19:57:24 +0000 (19:57 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@4789 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/lwcollection.c
liblwgeom/lwgeom.c
regress/regress_expected

index 8f5420f378511cc16ce5825464c859bf32b4c9e1..78d185dd9a34aa21f21901d1398441ace44a2f22 100644 (file)
@@ -336,13 +336,21 @@ lwcollection_segmentize2d(LWCOLLECTION *col, double dist)
 char
 lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
 {
-       unsigned int i, j;
-       unsigned int *hit;
+       unsigned int i;
+//     unsigned int *hit;
 
        LWDEBUG(2, "lwcollection_same called");
 
-       if ( TYPE_GETTYPE(c1->type) != TYPE_GETTYPE(c2->type) ) return 0;
-       if ( c1->ngeoms != c2->ngeoms ) return 0;
+       if ( TYPE_GETTYPE(c1->type) != TYPE_GETTYPE(c2->type) ) return LW_FALSE;
+       if ( c1->ngeoms != c2->ngeoms ) return LW_FALSE;
+
+       for( i = 0; i < c1->ngeoms; i++ )
+       {
+               if ( ! lwgeom_same(c1->geoms[i], c2->geoms[i]) )
+                       return LW_FALSE;
+       }
+
+/* Former method allowed out-of-order equality between collections 
 
        hit = lwalloc(sizeof(unsigned int)*c1->ngeoms);
        memset(hit, 0, sizeof(unsigned int)*c1->ngeoms);
@@ -360,9 +368,11 @@ lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
                                break;
                        }
                }
-               if ( ! found ) return 0;
+               if ( ! found ) return LW_FALSE;
        }
-       return 1;
+*/
+
+       return LW_TRUE;
 }
 
 int lwcollection_ngeoms(const LWCOLLECTION *col)
index c65749268dca117f5bdebb5dc4fc5eaed0940cf6..4e2431d74fa97766006e9c36fbd62e9f2e82866e 100644 (file)
@@ -781,14 +781,14 @@ lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
        {
                LWDEBUG(3, " type differ");
 
-               return 0;
+               return LW_FALSE;
        }
 
        if ( TYPE_GETZM(lwgeom1->type) != TYPE_GETZM(lwgeom2->type) )
        {
                LWDEBUG(3, " ZM flags differ");
 
-               return 0;
+               return LW_FALSE;
        }
 
        /* Check boxes if both already computed  */
@@ -799,7 +799,7 @@ lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
                {
                        LWDEBUG(3, " bounding boxes differ");
 
-                       return 0;
+                       return LW_FALSE;
                }
        }
 
@@ -824,7 +824,7 @@ lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
        default:
                lwerror("lwgeom_same: unsupported geometry type: %s",
                        lwgeom_typename(TYPE_GETTYPE(lwgeom1->type)));
-               return 0;
+               return LW_FALSE;
        }
 
 }
index 33204a870e4c754ac7415f163be0a01e3942370e..f2a830952e9b1bee9db630290adb202fc4b4825c 100644 (file)
@@ -84,9 +84,9 @@ HINT:  "MULTIPOINT(1 1, 2 2" <-- parse error at position 19 within geometry
 68|t
 68a|t
 69|t
-69a|t
+69a|f
 70|t
-70a|t
+70a|f
 71|t
 71a|f
 72|t