325 uint32_t ngeoms, nshells, nsolids;
331 want3d = force3D || sfcgal_geometry_is_3d(geom);
333 switch (sfcgal_geometry_type_id(geom))
335 case SFCGAL_TYPE_POINT: {
336 if (sfcgal_geometry_is_empty(geom))
343 case SFCGAL_TYPE_LINESTRING: {
344 if (sfcgal_geometry_is_empty(geom))
351 case SFCGAL_TYPE_TRIANGLE: {
352 if (sfcgal_geometry_is_empty(geom))
359 case SFCGAL_TYPE_POLYGON: {
360 if (sfcgal_geometry_is_empty(geom))
363 uint32_t nrings = sfcgal_polygon_num_interior_rings(geom) + 1;
367 for (i = 1; i < nrings; i++)
373 case SFCGAL_TYPE_MULTIPOINT:
374 case SFCGAL_TYPE_MULTILINESTRING:
375 case SFCGAL_TYPE_MULTIPOLYGON:
376 case SFCGAL_TYPE_MULTISOLID:
377 case SFCGAL_TYPE_GEOMETRYCOLLECTION: {
378 ngeoms = sfcgal_geometry_collection_num_geometries(geom);
384 for (i = 0; i < ngeoms; i++)
386 const sfcgal_geometry_t *g = sfcgal_geometry_collection_geometry_n(geom, i);
397 if (ngeoms == nsolids)
401 "SFCGAL2LWGEOM: SOLID in heterogeneous collection will be treated as a POLYHEDRALSURFACETYPE");
407 case SFCGAL_TYPE_CIRCULARSTRING:
408 case SFCGAL_TYPE_COMPOUNDCURVE:
409 case SFCGAL_TYPE_CURVEPOLYGON:
410 case SFCGAL_TYPE_MULTICURVE:
411 case SFCGAL_TYPE_MULTISURFACE:
412 case SFCGAL_TYPE_CURVE:
413 case SFCGAL_TYPE_SURFACE:
418 case SFCGAL_TYPE_POLYHEDRALSURFACE: {
419 ngeoms = sfcgal_polyhedral_surface_num_polygons(geom);
425 for (i = 0; i < ngeoms; i++)
427 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(geom, i);
435 case SFCGAL_TYPE_SOLID: {
436 nshells = sfcgal_solid_num_shells(geom);
438 for (ngeoms = 0, i = 0; i < nshells; i++)
439 ngeoms += sfcgal_polyhedral_surface_num_polygons(sfcgal_solid_shell_n(geom, i));
445 for (i = 0, k = 0; i < nshells; i++)
447 const sfcgal_geometry_t *shell = sfcgal_solid_shell_n(geom, i);
448 ngeoms = sfcgal_polyhedral_surface_num_polygons(shell);
450 for (j = 0; j < ngeoms; j++)
452 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(shell, j);
464 case SFCGAL_TYPE_TRIANGULATEDSURFACE: {
465 ngeoms = sfcgal_triangulated_surface_num_triangles(geom);
470 for (i = 0; i < ngeoms; i++)
472 const sfcgal_geometry_t *g = sfcgal_triangulated_surface_triangle_n(geom, i);
480 lwerror(
"SFCGAL2LWGEOM: Unknown Type");
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWTRIANGLE * lwtriangle_construct_empty(int32_t srid, char hasz, char hasm)
void * lwrealloc(void *mem, size_t size)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
#define POLYHEDRALSURFACETYPE
#define FLAGS_GET_SOLID(flags)
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
#define FLAGS_SET_SOLID(flags, value)
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
LWTRIANGLE * lwtriangle_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
void lwnotice(const char *fmt,...) __attribute__((format(printf
Write a notice out to the notice handler.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static POINTARRAY * ptarray_from_SFCGAL(const sfcgal_geometry_t *geom, int force3D)
static int SFCGAL_type_to_lwgeom_type(sfcgal_geometry_type_t type)
LWGEOM * SFCGAL2LWGEOM(const sfcgal_geometry_t *geom, int force3D, int32_t srid)