295 uint32_t ngeoms, nshells, nsolids;
301 want3d = force3D || sfcgal_geometry_is_3d(geom);
303 switch (sfcgal_geometry_type_id(geom))
305 case SFCGAL_TYPE_POINT:
307 if (sfcgal_geometry_is_empty(geom))
314 case SFCGAL_TYPE_LINESTRING:
316 if (sfcgal_geometry_is_empty(geom))
323 case SFCGAL_TYPE_TRIANGLE:
325 if (sfcgal_geometry_is_empty(geom))
332 case SFCGAL_TYPE_POLYGON:
334 if (sfcgal_geometry_is_empty(geom))
337 uint32_t nrings = sfcgal_polygon_num_interior_rings(geom) + 1;
341 for (i = 1; i < nrings; i++)
347 case SFCGAL_TYPE_MULTIPOINT:
348 case SFCGAL_TYPE_MULTILINESTRING:
349 case SFCGAL_TYPE_MULTIPOLYGON:
350 case SFCGAL_TYPE_MULTISOLID:
351 case SFCGAL_TYPE_GEOMETRYCOLLECTION:
353 ngeoms = sfcgal_geometry_collection_num_geometries(geom);
359 for (i = 0; i < ngeoms; i++)
361 const sfcgal_geometry_t *g = sfcgal_geometry_collection_geometry_n(geom, i);
372 if (ngeoms == nsolids)
376 "SFCGAL2LWGEOM: SOLID in heterogeneous collection will be treated as a POLYHEDRALSURFACETYPE");
382 case SFCGAL_TYPE_CIRCULARSTRING:
383 case SFCGAL_TYPE_COMPOUNDCURVE:
384 case SFCGAL_TYPE_CURVEPOLYGON:
385 case SFCGAL_TYPE_MULTICURVE:
386 case SFCGAL_TYPE_MULTISURFACE:
387 case SFCGAL_TYPE_CURVE:
388 case SFCGAL_TYPE_SURFACE:
393 case SFCGAL_TYPE_POLYHEDRALSURFACE:
395 ngeoms = sfcgal_polyhedral_surface_num_polygons(geom);
401 for (i = 0; i < ngeoms; i++)
403 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(geom, i);
411 case SFCGAL_TYPE_SOLID:
413 nshells = sfcgal_solid_num_shells(geom);
415 for (ngeoms = 0, i = 0; i < nshells; i++)
416 ngeoms += sfcgal_polyhedral_surface_num_polygons(sfcgal_solid_shell_n(geom, i));
422 for (i = 0, k = 0; i < nshells; i++)
424 const sfcgal_geometry_t *shell = sfcgal_solid_shell_n(geom, i);
425 ngeoms = sfcgal_polyhedral_surface_num_polygons(shell);
427 for (j = 0; j < ngeoms; j++)
429 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(shell, j);
441 case SFCGAL_TYPE_TRIANGULATEDSURFACE:
443 ngeoms = sfcgal_triangulated_surface_num_triangles(geom);
448 for (i = 0; i < ngeoms; i++)
450 const sfcgal_geometry_t *g = sfcgal_triangulated_surface_triangle_n(geom, i);
458 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)