PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ ptarray_to_SFCGAL()

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

Definition at line 210 of file lwgeom_sfcgal.c.

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

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: