280 uint32_t ngeoms, nshells, nsolids;
286 want3d = force3D || sfcgal_geometry_is_3d(geom);
288 switch (sfcgal_geometry_type_id(geom))
290 case SFCGAL_TYPE_POINT:
292 if (sfcgal_geometry_is_empty(geom))
299 case SFCGAL_TYPE_LINESTRING:
301 if (sfcgal_geometry_is_empty(geom))
308 case SFCGAL_TYPE_TRIANGLE:
310 if (sfcgal_geometry_is_empty(geom))
317 case SFCGAL_TYPE_POLYGON:
319 if (sfcgal_geometry_is_empty(geom))
322 uint32_t nrings = sfcgal_polygon_num_interior_rings(geom) + 1;
326 for (i = 1; i < nrings; i++)
332 case SFCGAL_TYPE_MULTIPOINT:
333 case SFCGAL_TYPE_MULTILINESTRING:
334 case SFCGAL_TYPE_MULTIPOLYGON:
335 case SFCGAL_TYPE_MULTISOLID:
336 case SFCGAL_TYPE_GEOMETRYCOLLECTION:
338 ngeoms = sfcgal_geometry_collection_num_geometries(geom);
344 for (i = 0; i < ngeoms; i++)
346 const sfcgal_geometry_t *g = sfcgal_geometry_collection_geometry_n(geom, i);
357 if (ngeoms == nsolids)
361 "SFCGAL2LWGEOM: SOLID in heterogeneous collection will be treated as a POLYHEDRALSURFACETYPE");
367 case SFCGAL_TYPE_CIRCULARSTRING:
368 case SFCGAL_TYPE_COMPOUNDCURVE:
369 case SFCGAL_TYPE_CURVEPOLYGON:
370 case SFCGAL_TYPE_MULTICURVE:
371 case SFCGAL_TYPE_MULTISURFACE:
372 case SFCGAL_TYPE_CURVE:
373 case SFCGAL_TYPE_SURFACE:
378 case SFCGAL_TYPE_POLYHEDRALSURFACE:
380 ngeoms = sfcgal_polyhedral_surface_num_polygons(geom);
386 for (i = 0; i < ngeoms; i++)
388 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(geom, i);
396 case SFCGAL_TYPE_SOLID:
398 nshells = sfcgal_solid_num_shells(geom);
400 for (ngeoms = 0, i = 0; i < nshells; i++)
401 ngeoms += sfcgal_polyhedral_surface_num_polygons(sfcgal_solid_shell_n(geom, i));
407 for (i = 0, k = 0; i < nshells; i++)
409 const sfcgal_geometry_t *shell = sfcgal_solid_shell_n(geom, i);
410 ngeoms = sfcgal_polyhedral_surface_num_polygons(shell);
412 for (j = 0; j < ngeoms; j++)
414 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(shell, j);
426 case SFCGAL_TYPE_TRIANGULATEDSURFACE:
428 ngeoms = sfcgal_triangulated_surface_num_triangles(geom);
433 for (i = 0; i < ngeoms; i++)
435 const sfcgal_geometry_t *g = sfcgal_triangulated_surface_triangle_n(geom, i);
443 lwerror(
"SFCGAL2LWGEOM: Unknown Type");
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)
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.