]> granicus.if.org Git - postgis/commitdiff
lwcollection_same allows different components ordering to
authorSandro Santilli <strk@keybit.net>
Fri, 26 Nov 2004 15:06:08 +0000 (15:06 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 26 Nov 2004 15:06:08 +0000 (15:06 +0000)
reflect older behaviour.

git-svn-id: http://svn.osgeo.org/postgis/trunk@1114 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwcollection.c

index 70739df640d5ee1f1f7a8e8f535f0186ae267604..6d03974fc5d48b8699022e17f7d8ba14aa74a005 100644 (file)
@@ -295,7 +295,8 @@ lwcollection_segmentize2d(LWCOLLECTION *col, double dist)
 char
 lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
 {
-       unsigned int i;
+       unsigned int i, j;
+       char *hit;
 
 #if DEBUG_CALLS
        lwnotice("lwcollection_same called");
@@ -304,10 +305,23 @@ lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2)
        if ( TYPE_GETTYPE(c1->type) != TYPE_GETTYPE(c2->type) ) return 0;
        if ( c1->ngeoms != c2->ngeoms ) return 0;
 
+       hit = (char *)lwalloc(sizeof(char)*c1->ngeoms);
+       memset(hit, 0, sizeof(char)*c1->ngeoms);
+
        for (i=0; i<c1->ngeoms; i++)
        {
-               if ( ! lwgeom_same(c1->geoms[i], c2->geoms[i]) )
-                       return 0;
+               char found=0;
+               for (j=0; j<c2->ngeoms; j++)
+               {
+                       if ( hit[j] ) continue;
+                       if ( lwgeom_same(c1->geoms[i], c2->geoms[j]) )
+                       {
+                               hit[j] = 1;
+                               found=1;
+                               break;
+                       }
+               }
+               if ( ! found ) return 0;
        }
        return 1;
 }