PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ptarray_to_SFCGAL()

static sfcgal_geometry_t * ptarray_to_SFCGAL ( const POINTARRAY pa,
int  type 
)
static

Convert a PostGIS pointarray to SFCGAL structure.

Definition at line 265 of file lwgeom_sfcgal.c.

266{
267 POINT4D point;
268 int is_3d, is_measured;
269 uint32_t i;
270
271 assert(pa);
272
273 is_3d = FLAGS_GET_Z(pa->flags) != 0;
274 is_measured = FLAGS_GET_M(pa->flags) != 0;
275
276 switch (type)
277 {
278 case POINTTYPE: {
279 getPoint4d_p(pa, 0, &point);
280 return create_sfcgal_point_by_dimensions(point.x, point.y, point.z, point.m, is_3d, is_measured);
281 }
282 break;
283 case LINETYPE: {
284 sfcgal_geometry_t *line = sfcgal_linestring_create();
285 for (i = 0; i < pa->npoints; i++)
286 {
287 getPoint4d_p(pa, i, &point);
288 sfcgal_linestring_add_point(
289 line,
290 create_sfcgal_point_by_dimensions(point.x, point.y, point.z, point.m, is_3d, is_measured));
291 }
292 return line;
293 }
294 break;
295 case TRIANGLETYPE: {
296 sfcgal_geometry_t *triangle = sfcgal_triangle_create();
297 for (i = 0; i < 3; i++)
298 {
299 getPoint4d_p(pa, i, &point);
300 sfcgal_geometry_t *vertex =
301 create_sfcgal_point_by_dimensions(point.x, point.y, point.z, point.m, is_3d, is_measured);
302 if (vertex)
303 {
304 sfcgal_triangle_set_vertex(triangle, i, vertex);
305 sfcgal_geometry_delete(vertex);
306 }
307 }
308 return triangle;
309 }
310 break;
311 default:
312 lwerror("ptarray_to_SFCGAL: Unknown Type");
313 return NULL;
314 }
315}
#define LINETYPE
Definition liblwgeom.h:103
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:166
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
#define TRIANGLETYPE
Definition liblwgeom.h:115
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static sfcgal_geometry_t * create_sfcgal_point_by_dimensions(double x, double y, double z, double m, int is_3d, int is_measured)
Create a SFCGAL point based on dimensional flags (XY, XYZ, XYM, XYZM).
double m
Definition liblwgeom.h:414
double x
Definition liblwgeom.h:414
double z
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414
lwflags_t flags
Definition liblwgeom.h:431
uint32_t npoints
Definition liblwgeom.h:427

References create_sfcgal_point_by_dimensions(), POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d_p(), LINETYPE, lwerror(), POINT4D::m, POINTARRAY::npoints, POINTTYPE, TRIANGLETYPE, POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by LWGEOM2SFCGAL().

Here is the call graph for this function:
Here is the caller graph for this function: