PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ ptarray_to_SFCGAL()

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

Definition at line 212 of file lwgeom_sfcgal.c.

213 {
214  POINT3DZ point;
215  int is_3d;
216  uint32_t i;
217 
218  assert(pa);
219 
220  is_3d = FLAGS_GET_Z(pa->flags) != 0;
221 
222  switch (type)
223  {
224  case POINTTYPE:
225  {
226  getPoint3dz_p(pa, 0, &point);
227  if (is_3d)
228  return sfcgal_point_create_from_xyz(point.x, point.y, point.z);
229  else
230  return sfcgal_point_create_from_xy(point.x, point.y);
231  }
232  break;
233 
234  case LINETYPE:
235  {
236  sfcgal_geometry_t *line = sfcgal_linestring_create();
237 
238  for (i = 0; i < pa->npoints; i++)
239  {
240  getPoint3dz_p(pa, i, &point);
241  if (is_3d)
242  {
243  sfcgal_linestring_add_point(line,
244  sfcgal_point_create_from_xyz(point.x, point.y, point.z));
245  }
246  else
247  {
248  sfcgal_linestring_add_point(line, sfcgal_point_create_from_xy(point.x, point.y));
249  }
250  }
251 
252  return line;
253  }
254  break;
255 
256  case TRIANGLETYPE:
257  {
258  sfcgal_geometry_t *triangle = sfcgal_triangle_create();
259 
260  getPoint3dz_p(pa, 0, &point);
261  if (is_3d)
262  sfcgal_triangle_set_vertex_from_xyz(triangle, 0, point.x, point.y, point.z);
263  else
264  sfcgal_triangle_set_vertex_from_xy(triangle, 0, point.x, point.y);
265 
266  getPoint3dz_p(pa, 1, &point);
267  if (is_3d)
268  sfcgal_triangle_set_vertex_from_xyz(triangle, 1, point.x, point.y, point.z);
269  else
270  sfcgal_triangle_set_vertex_from_xy(triangle, 1, point.x, point.y);
271 
272  getPoint3dz_p(pa, 2, &point);
273  if (is_3d)
274  sfcgal_triangle_set_vertex_from_xyz(triangle, 2, point.x, point.y, point.z);
275  else
276  sfcgal_triangle_set_vertex_from_xy(triangle, 2, point.x, point.y);
277 
278  return triangle;
279  }
280  break;
281 
282  /* Other SFCGAL types should not be called directly ... */
283  default:
284  lwerror("ptarray_from_SFCGAL: Unknown Type");
285  return NULL;
286  }
287 }
#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
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:215
#define TRIANGLETYPE
Definition: liblwgeom.h:115
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
type
Definition: ovdump.py:42
double z
Definition: liblwgeom.h:396
double x
Definition: liblwgeom.h:396
double y
Definition: liblwgeom.h:396
lwflags_t flags
Definition: liblwgeom.h:431
uint32_t npoints
Definition: liblwgeom.h:427

References POINTARRAY::flags, FLAGS_GET_Z, getPoint3dz_p(), LINETYPE, lwerror(), POINTARRAY::npoints, POINTTYPE, TRIANGLETYPE, ovdump::type, POINT3DZ::x, POINT3DZ::y, and POINT3DZ::z.

Referenced by LWGEOM2SFCGAL().

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