195 int type = GEOSGeomTypeId(geom);
196 int SRID = GEOSGetSRID(geom);
201 if (want3d && !GEOSHasZ(geom))
203 LWDEBUG(3,
"Geometry has no Z, won't provide one");
209 const GEOSCoordSequence* cs;
211 const GEOSGeometry* g;
216 LWDEBUG(4,
"lwgeom_from_geometry: it's a Point");
217 cs = GEOSGeom_getCoordSeq(geom);
222 case GEOS_LINESTRING:
223 case GEOS_LINEARRING:
224 LWDEBUG(4,
"lwgeom_from_geometry: it's a LineString or LinearRing");
227 cs = GEOSGeom_getCoordSeq(geom);
232 LWDEBUG(4,
"lwgeom_from_geometry: it's a Polygon");
234 ngeoms = GEOSGetNumInteriorRings(geom);
236 g = GEOSGetExteriorRing(geom);
237 cs = GEOSGeom_getCoordSeq(g);
239 for (i = 0; i < ngeoms; i++)
241 g = GEOSGetInteriorRingN(geom, i);
242 cs = GEOSGeom_getCoordSeq(g);
247 case GEOS_MULTIPOINT:
248 case GEOS_MULTILINESTRING:
249 case GEOS_MULTIPOLYGON:
250 case GEOS_GEOMETRYCOLLECTION:
251 LWDEBUG(4,
"lwgeom_from_geometry: it's a Collection or Multi");
253 ngeoms = GEOSGetNumGeometries(geom);
258 for (i = 0; i < ngeoms; i++)
260 g = GEOSGetGeometryN(geom, i);
267 lwerror(
"GEOS2LWGEOM: unknown geometry type: %d",
type);
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
POINTARRAY * ptarray_from_GEOSCoordSeq(const GEOSCoordSequence *cs, uint8_t want3d)
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define SRID_UNKNOWN
Unknown SRID value.
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
#define LWDEBUG(level, msg)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.