297 uint32_t ngeoms, nshells, nsolids;
303 want3d = force3D || sfcgal_geometry_is_3d(geom);
305 switch (sfcgal_geometry_type_id(geom))
307 case SFCGAL_TYPE_POINT:
309 if (sfcgal_geometry_is_empty(geom))
316 case SFCGAL_TYPE_LINESTRING:
318 if (sfcgal_geometry_is_empty(geom))
325 case SFCGAL_TYPE_TRIANGLE:
327 if (sfcgal_geometry_is_empty(geom))
334 case SFCGAL_TYPE_POLYGON:
336 if (sfcgal_geometry_is_empty(geom))
339 uint32_t nrings = sfcgal_polygon_num_interior_rings(geom) + 1;
343 for (i = 1; i < nrings; i++)
349 case SFCGAL_TYPE_MULTIPOINT:
350 case SFCGAL_TYPE_MULTILINESTRING:
351 case SFCGAL_TYPE_MULTIPOLYGON:
352 case SFCGAL_TYPE_MULTISOLID:
353 case SFCGAL_TYPE_GEOMETRYCOLLECTION:
355 ngeoms = sfcgal_geometry_collection_num_geometries(geom);
361 for (i = 0; i < ngeoms; i++)
363 const sfcgal_geometry_t *g = sfcgal_geometry_collection_geometry_n(geom, i);
374 if (ngeoms == nsolids)
378 "SFCGAL2LWGEOM: SOLID in heterogeneous collection will be treated as a POLYHEDRALSURFACETYPE");
384 case SFCGAL_TYPE_CIRCULARSTRING:
385 case SFCGAL_TYPE_COMPOUNDCURVE:
386 case SFCGAL_TYPE_CURVEPOLYGON:
387 case SFCGAL_TYPE_MULTICURVE:
388 case SFCGAL_TYPE_MULTISURFACE:
389 case SFCGAL_TYPE_CURVE:
390 case SFCGAL_TYPE_SURFACE:
395 case SFCGAL_TYPE_POLYHEDRALSURFACE:
397 ngeoms = sfcgal_polyhedral_surface_num_polygons(geom);
403 for (i = 0; i < ngeoms; i++)
405 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(geom, i);
413 case SFCGAL_TYPE_SOLID:
415 nshells = sfcgal_solid_num_shells(geom);
417 for (ngeoms = 0, i = 0; i < nshells; i++)
418 ngeoms += sfcgal_polyhedral_surface_num_polygons(sfcgal_solid_shell_n(geom, i));
424 for (i = 0, k = 0; i < nshells; i++)
426 const sfcgal_geometry_t *shell = sfcgal_solid_shell_n(geom, i);
427 ngeoms = sfcgal_polyhedral_surface_num_polygons(shell);
429 for (j = 0; j < ngeoms; j++)
431 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(shell, j);
443 case SFCGAL_TYPE_TRIANGULATEDSURFACE:
445 ngeoms = sfcgal_triangulated_surface_num_triangles(geom);
450 for (i = 0; i < ngeoms; i++)
452 const sfcgal_geometry_t *g = sfcgal_triangulated_surface_triangle_n(geom, i);
460 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 lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice 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)