324{
325 uint32_t ngeoms = 0, nshells = 0, nsolids = 0;
326 uint32_t i, j, k;
327 int want3d;
328
329 assert(geom);
330
331 want3d = force3D || sfcgal_geometry_is_3d(geom);
332
333 switch (sfcgal_geometry_type_id(geom))
334 {
335 case SFCGAL_TYPE_POINT: {
336 if (sfcgal_geometry_is_empty(geom))
338
341 }
342
343 case SFCGAL_TYPE_LINESTRING: {
344 if (sfcgal_geometry_is_empty(geom))
346
349 }
350
351 case SFCGAL_TYPE_TRIANGLE: {
352 if (sfcgal_geometry_is_empty(geom))
354
357 }
358
359 case SFCGAL_TYPE_POLYGON: {
360 if (sfcgal_geometry_is_empty(geom))
362
363 uint32_t nrings = sfcgal_polygon_num_interior_rings(geom) + 1;
365
367 for (i = 1; i < nrings; i++)
369
371 }
372
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);
380 if (ngeoms)
381 {
382 nsolids = 0;
384 for (i = 0; i < ngeoms; i++)
385 {
386 const sfcgal_geometry_t *g = sfcgal_geometry_collection_geometry_n(geom, i);
389 ++nsolids;
390 }
392 }
395 if (ngeoms)
396 {
397 if (ngeoms == nsolids)
399 else if (nsolids)
401 "SFCGAL2LWGEOM: SOLID in heterogeneous collection will be treated as a POLYHEDRALSURFACETYPE");
402 }
403 return rgeom;
404 }
405
406#if 0
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:
414
415
416#endif
417
418 case SFCGAL_TYPE_POLYHEDRALSURFACE: {
419 ngeoms = sfcgal_polyhedral_surface_num_polygons(geom);
420
422 if (ngeoms)
423 {
425 for (i = 0; i < ngeoms; i++)
426 {
427 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(geom, i);
429 }
430 }
432 }
433
434
435 case SFCGAL_TYPE_SOLID: {
436 nshells = sfcgal_solid_num_shells(geom);
437
438 for (ngeoms = 0, i = 0; i < nshells; i++)
439 ngeoms += sfcgal_polyhedral_surface_num_polygons(sfcgal_solid_shell_n(geom, i));
440
442 if (ngeoms)
443 {
445 for (i = 0, k = 0; i < nshells; i++)
446 {
447 const sfcgal_geometry_t *shell = sfcgal_solid_shell_n(geom, i);
448 ngeoms = sfcgal_polyhedral_surface_num_polygons(shell);
449
450 for (j = 0; j < ngeoms; j++)
451 {
452 const sfcgal_geometry_t *g = sfcgal_polyhedral_surface_polygon_n(shell, j);
454 k++;
455 }
456 }
457 }
459 if (ngeoms)
461 return rgeom;
462 }
463
464 case SFCGAL_TYPE_TRIANGULATEDSURFACE: {
465 ngeoms = sfcgal_triangulated_surface_num_triangles(geom);
467 if (ngeoms)
468 {
470 for (i = 0; i < ngeoms; i++)
471 {
472 const sfcgal_geometry_t *g = sfcgal_triangulated_surface_triangle_n(geom, i);
474 }
475 }
477 }
478
479 default:
480 lwerror(
"SFCGAL2LWGEOM: Unknown Type");
481 return NULL;
482 }
483}
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
void * lwrealloc(void *mem, size_t size)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
LWTRIANGLE * lwtriangle_construct_empty(int32_t srid, char hasz, char hasm)
void * lwalloc(size_t size)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
#define POLYHEDRALSURFACETYPE
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
#define FLAGS_GET_SOLID(flags)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
#define FLAGS_SET_SOLID(flags, value)
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)