]> granicus.if.org Git - postgis/commitdiff
Add new pointer-based coordinate access method, now that aligned storage is the new...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 28 Sep 2012 21:48:53 +0000 (21:48 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 28 Sep 2012 21:48:53 +0000 (21:48 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@10340 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/liblwgeom.h.in
liblwgeom/lwgeom_api.c

index d80b9d0a860ac8bfac5d10bd84e1bcd6275dd446..147d2da1f14d68fb4d5280dc50f211a873fcfcc4 100644 (file)
@@ -765,6 +765,14 @@ extern POINT2D getPoint2d(const POINTARRAY *pa, int n);
  */
 extern int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point);
 
+/**
+* Returns a pointer into the POINTARRAY serialized_ptlist, 
+* suitable for reading from. This is very high performance
+* and declared const because you aren't allowed to muck with the 
+* values, only read them.
+*/
+extern const POINT2D* getPoint2d_cp(const POINTARRAY *pa, int n);
+
 /*
  * set point N to the given value
  * NOTE that the pointarray can be of any
index 8c46bd1666107c4e942f755cf83c4fa73376c73f..c3cff2001b00fb1e9e7256fcad4d83038d0e3b70 100644 (file)
@@ -448,6 +448,27 @@ getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
        return 1;
 }
 
+/**
+* Returns a pointer into the POINTARRAY serialized_ptlist, 
+* suitable for reading from. This is very high performance
+* and declared const because you aren't allowed to muck with the 
+* values, only read them.
+*/
+const POINT2D*
+getPoint2d_cp(const POINTARRAY *pa, int n)
+{
+       if ( ! pa ) return 0;
+
+       if ( (n<0) || (n>=pa->npoints))
+       {
+               lwerror("getPoint2D_const_p: point offset out of range");
+               return 0; /*error */
+       }
+
+       return (const POINT2D*)getPoint_internal(pa, n);
+}
+
+
 /*
  * set point N to the given value
  * NOTE that the pointarray can be of any