static const LWGEOM* lwgeom_subgeom(const LWGEOM* g, int n) { const LWCOLLECTION* c = lwgeom_as_lwcollection(g); if ( c ) return lwcollection_getsubgeom((LWCOLLECTION*)c, n); else return g; }
/** * Serializes a LWGEOM to a char*. This is a helper function that partially * writes the appropriate draw, stroke, and fill commands used to generate an * SVG image using ImageMagick's "convert" command. * @param output a char reference to write the LWGEOM to * @param lwgeom a reference to a LWGEOM * @return the numbers of character written to *output */ static size_t drawGeometry(char *output, LWGEOM *lwgeom, LAYERSTYLE *styles ) { char *ptr = output; int i; int type = lwgeom_getType(lwgeom->type); switch (type) { case POINTTYPE: ptr += drawPoint(ptr, (LWPOINT*)lwgeom, styles ); break; case LINETYPE: ptr += drawLineString(ptr, (LWLINE*)lwgeom, styles ); break; case POLYGONTYPE: ptr += drawPolygon(ptr, (LWPOLY*)lwgeom, styles ); break; case MULTIPOINTTYPE: case MULTILINETYPE: case MULTIPOLYGONTYPE: case COLLECTIONTYPE: for (i=0; i<((LWCOLLECTION*)lwgeom)->ngeoms; i++) { ptr += drawGeometry( ptr, lwcollection_getsubgeom ((LWCOLLECTION*)lwgeom, i), styles ); } break; } return (ptr - output); }