]> granicus.if.org Git - postgis/commitdiff
Move ptarray reverse axis function from postgis/lwgeom_in_gml to liblwgeom/ptarray
authorOlivier Courtin <olivier.courtin@camptocamp.com>
Tue, 23 Feb 2010 18:29:00 +0000 (18:29 +0000)
committerOlivier Courtin <olivier.courtin@camptocamp.com>
Tue, 23 Feb 2010 18:29:00 +0000 (18:29 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5319 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/liblwgeom.h
liblwgeom/ptarray.c
postgis/lwgeom_in_gml.c

index dfbdb7e3cd5b627edad19bcefa92dced77482af1..20035595b9fb4cac3584084bf2e4fd87397f6e45 100644 (file)
@@ -1382,6 +1382,8 @@ extern void ptarray_longitude_shift(POINTARRAY *pa);
 
 extern int32 lwgeom_nrings_recursive(uchar *serialized);
 extern void ptarray_reverse(POINTARRAY *pa);
+extern POINTARRAY* ptarray_reverse_axis(POINTARRAY *pa);
+
 extern POINTARRAY *ptarray_substring(POINTARRAY *, double, double);
 extern double ptarray_locate_point(POINTARRAY *, POINT2D *);
 extern void closest_point_on_segment(POINT2D *p, POINT2D *A, POINT2D *B, POINT2D *ret);
index 375f2543c3a364ccbfbca102f68aef4845ca222d..9265207f968d2415094d2afc6b3bcc9d71c921a9 100644 (file)
@@ -73,6 +73,30 @@ ptarray_reverse(POINTARRAY *pa)
 
 }
 
+
+/**
+ * Reverse X and Y axis on a given POINTARRAY
+ */
+POINTARRAY*
+ptarray_reverse_axis(POINTARRAY *pa)
+{
+        int i;
+        double d;
+        POINT4D p;
+
+        for (i=0 ; i < pa->npoints ; i++)
+        {
+                getPoint4d_p(pa, i, &p);
+                d = p.y;
+                p.y = p.x;
+                p.x = d;
+                setPoint4d(pa, i, &p);
+        }
+
+        return pa;
+}
+
+
 /**
  * @brief calculate the 2d bounding box of a set of points
  *             write result to the provided BOX2DFLOAT4
index 8f4d795f8f7964dea1ac79352d5f23a3183fbb56..9d57186366de72e9165417974c7a1ac1215652ed 100644 (file)
@@ -299,28 +299,6 @@ static xmlNodePtr get_xlink_node(xmlNodePtr xnode)
 }
 
 
-/**
- * Reverse X and Y axis on a given POINTARRAY
- */
-static POINTARRAY* gml_reverse_axis_pa(POINTARRAY *pa)
-{
-       int i;
-       double d;
-       POINT4D p;
-
-       for (i=0 ; i < pa->npoints ; i++)
-       {
-               getPoint4d_p(pa, i, &p);
-               d = p.y;
-               p.y = p.x;
-               p.x = d;
-               setPoint4d(pa, i, &p);
-       }
-
-       return pa;
-}
-
-
 /**
  * Use Proj4 to reproject a given POINTARRAY
  */
@@ -977,7 +955,7 @@ static POINTARRAY* parse_gml_data(xmlNodePtr xnode, bool *hasz, int *root_srid)
                                lwerror("invalid GML representation");
 
                        srs = parse_gml_srs(xb);
-                       if (srs->reverse_axis) tmp_pa = gml_reverse_axis_pa(tmp_pa);
+                       if (srs->reverse_axis) tmp_pa = ptarray_reverse_axis(tmp_pa);
                        if (!*root_srid) *root_srid = srs->srid;
                        else
                        {
@@ -1012,7 +990,7 @@ static LWGEOM* parse_gml_point(xmlNodePtr xnode, bool *hasz, int *root_srid)
        if (pa->npoints != 1) lwerror("invalid GML representation");
 
        srs = parse_gml_srs(xnode);
-       if (srs->reverse_axis) pa = gml_reverse_axis_pa(pa);
+       if (srs->reverse_axis) pa = ptarray_reverse_axis(pa);
        if (!*root_srid)
        {
                *root_srid = srs->srid;
@@ -1046,7 +1024,7 @@ static LWGEOM* parse_gml_line(xmlNodePtr xnode, bool *hasz, int *root_srid)
        if (pa->npoints < 2) lwerror("invalid GML representation");
 
        srs = parse_gml_srs(xnode);
-       if (srs->reverse_axis) pa = gml_reverse_axis_pa(pa);
+       if (srs->reverse_axis) pa = ptarray_reverse_axis(pa);
        if (!*root_srid)
        {
                *root_srid = srs->srid;
@@ -1162,7 +1140,7 @@ static LWGEOM* parse_gml_curve(xmlNodePtr xnode, bool *hasz, int *root_srid)
        }
 
        srs = parse_gml_srs(xnode);
-       if (srs->reverse_axis) pa = gml_reverse_axis_pa(pa);
+       if (srs->reverse_axis) pa = ptarray_reverse_axis(pa);
        if (!*root_srid)
        {
                *root_srid = srs->srid;
@@ -1219,7 +1197,7 @@ static LWGEOM* parse_gml_polygon(xmlNodePtr xnode, bool *hasz, int *root_srid)
                                ||  (*hasz && !ptarray_isclosed3d(ppa[0])))
                                lwerror("invalid GML representation");
 
-                       if (srs->reverse_axis) ppa[0] = gml_reverse_axis_pa(ppa[0]);
+                       if (srs->reverse_axis) ppa[0] = ptarray_reverse_axis(ppa[0]);
                }
        }
 
@@ -1249,7 +1227,7 @@ static LWGEOM* parse_gml_polygon(xmlNodePtr xnode, bool *hasz, int *root_srid)
                                ||  (*hasz && !ptarray_isclosed3d(ppa[ring])))
                                lwerror("invalid GML representation");
 
-                       if (srs->reverse_axis) ppa[ring] = gml_reverse_axis_pa(ppa[ring]);
+                       if (srs->reverse_axis) ppa[ring] = ptarray_reverse_axis(ppa[ring]);
                        ring++;
                }
        }
@@ -1350,7 +1328,7 @@ static LWGEOM* parse_gml_surface(xmlNodePtr xnode, bool *hasz, int *root_srid)
                                        ||  (*hasz && !ptarray_isclosed3d(ppa[0])))
                                        lwerror("invalid GML representation");
 
-                               if (srs->reverse_axis) ppa[0] = gml_reverse_axis_pa(ppa[0]);
+                               if (srs->reverse_axis) ppa[0] = ptarray_reverse_axis(ppa[0]);
                        }
                }
 
@@ -1378,7 +1356,7 @@ static LWGEOM* parse_gml_surface(xmlNodePtr xnode, bool *hasz, int *root_srid)
                                        lwerror("invalid GML representation");
 
                                if (srs->reverse_axis)
-                                       ppa[ring] = gml_reverse_axis_pa(ppa[ring]);
+                                       ppa[ring] = ptarray_reverse_axis(ppa[ring]);
 
                                ring++;
                        }