]> 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 12:25:30 +0000 (12:25 +0000)
committerMark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>
Fri, 7 Nov 2008 12:25:30 +0000 (12:25 +0000)
git-svn-id: http://svn.osgeo.org/postgis/branches/1.3@3270 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/liblwgeom.h
lwgeom/lwgeom_api.c

index 77ceb8e33a432efb127b6b651fec87a0516fe94c..91c2116bb0edb233ce0b3d729ca5305bcd96269c 100644 (file)
@@ -1198,6 +1198,7 @@ extern BOX3D *lwcurve_compute_box3d(LWCURVE *curve);
 extern void pfree_curve(LWCURVE  *curve);
 LWCURVE *lwcurve_clone(const LWCURVE *curve);
 LWCURVE *lwgeom_getcurve_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
+LWCURVEPOLY *lwgeom_getcurvepoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
 /******************************************************************
  * LWMULTIx and LWCOLLECTION functions
index d5df282f03d8e1050d5ca826b868cfb471f21a6c..2f976c02b1280da85f469b5bee79f8758575d20c 100644 (file)
@@ -1208,6 +1208,28 @@ lwgeom_getcurve_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
        return lwcurve_deserialize(sub_geom);
 }
 
+/*
+ * 1st geometry has geom_number = 0
+ * if the actual geometry isnt a CURVEPOLYGON, null is returned (see _gettype()).
+ * if there arent enough geometries, return null.
+ * this is fine to call on a curvepolygon 
+ */
+LWCURVEPOLY *
+lwgeom_getcurvepoly_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 != CURVEPOLYTYPE) return NULL;
+
+       return lwcurvepoly_deserialize(sub_geom);
+}
+
 /*
  * 1st geometry has geom_number = 0
  * if there arent enough geometries, return null.