PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ ptarray_to_SFCGAL()

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

Definition at line 195 of file liblwgeom/lwgeom_sfcgal.c.

196 {
197  POINT3DZ point;
198  int is_3d;
199  uint32_t i;
200 
201  assert(pa);
202 
203  is_3d = FLAGS_GET_Z(pa->flags) != 0;
204 
205  switch (type)
206  {
207  case POINTTYPE:
208  {
209  getPoint3dz_p(pa, 0, &point);
210  if (is_3d)
211  return sfcgal_point_create_from_xyz(point.x, point.y, point.z);
212  else
213  return sfcgal_point_create_from_xy(point.x, point.y);
214  }
215  break;
216 
217  case LINETYPE:
218  {
219  sfcgal_geometry_t *line = sfcgal_linestring_create();
220 
221  for (i = 0; i < pa->npoints; i++)
222  {
223  getPoint3dz_p(pa, i, &point);
224  if (is_3d)
225  {
226  sfcgal_linestring_add_point(line,
227  sfcgal_point_create_from_xyz(point.x, point.y, point.z));
228  }
229  else
230  {
231  sfcgal_linestring_add_point(line, sfcgal_point_create_from_xy(point.x, point.y));
232  }
233  }
234 
235  return line;
236  }
237  break;
238 
239  case TRIANGLETYPE:
240  {
241  sfcgal_geometry_t *triangle = sfcgal_triangle_create();
242 
243  getPoint3dz_p(pa, 0, &point);
244  if (is_3d)
245  sfcgal_triangle_set_vertex_from_xyz(triangle, 0, point.x, point.y, point.z);
246  else
247  sfcgal_triangle_set_vertex_from_xy(triangle, 0, point.x, point.y);
248 
249  getPoint3dz_p(pa, 1, &point);
250  if (is_3d)
251  sfcgal_triangle_set_vertex_from_xyz(triangle, 1, point.x, point.y, point.z);
252  else
253  sfcgal_triangle_set_vertex_from_xy(triangle, 1, point.x, point.y);
254 
255  getPoint3dz_p(pa, 2, &point);
256  if (is_3d)
257  sfcgal_triangle_set_vertex_from_xyz(triangle, 2, point.x, point.y, point.z);
258  else
259  sfcgal_triangle_set_vertex_from_xy(triangle, 2, point.x, point.y);
260 
261  return triangle;
262  }
263  break;
264 
265  /* Other SFCGAL types should not be called directly ... */
266  default:
267  lwerror("ptarray_from_SFCGAL: Unknown Type");
268  return NULL;
269  }
270 }
#define LINETYPE
Definition: liblwgeom.h:117
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:116
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:179
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:215
#define TRIANGLETYPE
Definition: liblwgeom.h:129
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:382
double x
Definition: liblwgeom.h:382
double y
Definition: liblwgeom.h:382
lwflags_t flags
Definition: liblwgeom.h:417
uint32_t npoints
Definition: liblwgeom.h:413

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: