]> granicus.if.org Git - postgis/commitdiff
Add missing lwgeom_getcurve_inspected() function which is required for some of the...
authorMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Fri, 7 Nov 2008 14:05:53 +0000 (14:05 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Fri, 7 Nov 2008 14:05:53 +0000 (14:05 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@3275 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/liblwgeom.h
liblwgeom/lwgeom_api.c

index dc2b26a573c455aaacb29aed5728e55529d49dad..d49d272f8d0b81700babbb7b235eb6bc5060ba46 100644 (file)
@@ -1281,6 +1281,7 @@ extern int lwcurve_compute_box2d_p(LWCURVE *curve, BOX2DFLOAT4 *box);
 extern BOX3D *lwcurve_compute_box3d(LWCURVE *curve);
 extern void pfree_curve(LWCURVE  *curve);
 LWCURVE *lwcurve_clone(const LWCURVE *curve);
+extern LWCURVE *lwgeom_getcurve_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
 /******************************************************************
  * LWMULTIx and LWCOLLECTION functions
index 030b213028ce7d9aa299afbfd640eba302ef7eb7..4554a066fdca6f6caa5f0029072b192631da0ac9 100644 (file)
@@ -1151,6 +1151,28 @@ lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
        return lwpoly_deserialize(sub_geom);
 }
 
+/*
+ * 1st geometry has geom_number = 0
+ * if the actual geometry isnt a CIRCULARSTRING, null is returned (see _gettype()).
+ * if there arent enough geometries, return null.
+ * this is fine to call on a circularstring
+ */
+LWCURVE *
+lwgeom_getcurve_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
+{
+       uchar *sub_geom;
+       uchar type;
+
+       sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
+
+       if (sub_geom == NULL) return NULL;
+
+       type = lwgeom_getType(sub_geom[0]);
+       if (type != CURVETYPE) return NULL;
+
+       return lwcurve_deserialize(sub_geom);
+}
+
 /*
  * 1st geometry has geom_number = 0
  * if there arent enough geometries, return null.