extern int lwgeom_dimension(const LWGEOM *geom);
extern LWPOINT* lwline_get_lwpoint(LWLINE *line, int where);
+extern LWPOINT* lwcircstring_get_lwpoint(LWCIRCSTRING *circ, int where);
extern double ptarray_length_2d(const POINTARRAY *pts);
extern double ptarray_length(const POINTARRAY *pts);
lwline_free(line);
return length;
}
+
+/*
+ * Returns freshly allocated #LWPOINT that corresponds to the index where.
+ * Returns NULL if the geometry is empty or the index invalid.
+ */
+LWPOINT* lwcircstring_get_lwpoint(LWCIRCSTRING *circ, int where) {
+ POINT4D pt;
+ LWPOINT *lwpoint;
+ POINTARRAY *pa;
+
+ if ( lwcircstring_is_empty(circ) || where < 0 || where >= circ->points->npoints )
+ return NULL;
+
+ pa = ptarray_construct_empty(FLAGS_GET_Z(circ->flags), FLAGS_GET_M(circ->flags), 1);
+ pt = getPoint4d(circ->points, where);
+ ptarray_append_point(pa, &pt, LW_TRUE);
+ lwpoint = lwpoint_construct(circ->srid, NULL, pa);
+ return lwpoint;
+}
* probably not worth the bother
*/
LWLINE *line;
+ LWCIRCSTRING *circ;
LWPOLY *poly;
LWTRIANGLE *tri;
LWPOINT *lwpoint = NULL;
}
break;
case CIRCSTRINGTYPE:
- ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
- errmsg("Invalid Geometry type circstring passed to ST_DumpPoints()")));
+ circ = lwgeom_as_lwcircstring(lwgeom);
+ if (circ->points && state->pt <= circ->points->npoints) {
+ lwpoint = lwcircstring_get_lwpoint((LWCIRCSTRING*)lwgeom, state->pt);
+ }
+ break;
default:
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
- errmsg("Invalid Geometry type passed to ST_DumpPoints()")));
+ errmsg("Invalid Geometry type %d passed to ST_DumpPoints()", lwgeom->type)));
}
/*
case MULTISURFACETYPE:
case POLYHEDRALSURFACETYPE:
case TINTYPE:
+
#endif
{5,1,2,2}|POINT(5 6)
{5,1,2,3}|POINT(6 6)
{5,1,2,4}|POINT(5 5)
-ERROR: Invalid Geometry type circstring passed to ST_DumpPoints()
-ERROR: Invalid Geometry type circstring passed to ST_DumpPoints()
+{1,1}|POINT(-71.0821 42.3036)
+{1,2}|POINT(-71.4821 42.3036)
+{1,3}|POINT(-71.7821 42.7036)
+{1,4}|POINT(-71.0821 42.7036)
+{1,5}|POINT(-71.0821 42.3036)
+{2,1}|POINT(-71.1821 42.4036)
+{2,2}|POINT(-71.3821 42.6036)
+{2,3}|POINT(-71.3821 42.4036)
+{2,4}|POINT(-71.1821 42.4036)
+{1,1}|POINT(0 0)
+{1,2}|POINT(4 0)
+{1,3}|POINT(4 4)
+{1,4}|POINT(0 4)
+{1,5}|POINT(0 0)
+{2,1}|POINT(1 1)
+{2,2}|POINT(3 3)
+{2,3}|POINT(3 1)
+{2,4}|POINT(1 1)