PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ptarray_to_SFCGAL()

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

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

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

Referenced by LWGEOM2SFCGAL().

202 {
203  POINT3DZ point;
204  int is_3d;
205  uint32_t i;
206 
207  assert(pa);
208 
209  is_3d = FLAGS_GET_Z(pa->flags) != 0;
210 
211  switch (type)
212  {
213  case POINTTYPE:
214  {
215  getPoint3dz_p(pa, 0, &point);
216  if (is_3d) return sfcgal_point_create_from_xyz(point.x, point.y, point.z);
217  else return sfcgal_point_create_from_xy(point.x, point.y);
218  }
219  break;
220 
221  case LINETYPE:
222  {
223  sfcgal_geometry_t* line = sfcgal_linestring_create();
224 
225  for (i = 0; i < pa->npoints; i++)
226  {
227  getPoint3dz_p(pa, i, &point);
228  if (is_3d)
229  {
230  sfcgal_linestring_add_point(line,
231  sfcgal_point_create_from_xyz(point.x, point.y, point.z));
232  }
233  else
234  {
235  sfcgal_linestring_add_point(line,
236  sfcgal_point_create_from_xy(point.x, point.y));
237  }
238  }
239 
240  return line;
241  }
242  break;
243 
244  case TRIANGLETYPE:
245  {
246  sfcgal_geometry_t* triangle = sfcgal_triangle_create();
247 
248  getPoint3dz_p(pa, 0, &point);
249  if (is_3d) sfcgal_triangle_set_vertex_from_xyz(triangle, 0, point.x, point.y, point.z);
250  else sfcgal_triangle_set_vertex_from_xy (triangle, 0, point.x, point.y);
251 
252  getPoint3dz_p(pa, 1, &point);
253  if (is_3d) sfcgal_triangle_set_vertex_from_xyz(triangle, 1, point.x, point.y, point.z);
254  else sfcgal_triangle_set_vertex_from_xy (triangle, 1, point.x, point.y);
255 
256  getPoint3dz_p(pa, 2, &point);
257  if (is_3d) sfcgal_triangle_set_vertex_from_xyz(triangle, 2, point.x, point.y, point.z);
258  else sfcgal_triangle_set_vertex_from_xy (triangle, 2, point.x, point.y);
259 
260  return triangle;
261  }
262  break;
263 
264  /* Other SFCGAL types should not be called directly ... */
265  default:
266  lwerror("ptarray_from_SFCGAL: Unknown Type");
267  return NULL;
268  }
269 }
#define LINETYPE
Definition: liblwgeom.h:86
double z
Definition: liblwgeom.h:334
double y
Definition: liblwgeom.h:334
double x
Definition: liblwgeom.h:334
int npoints
Definition: liblwgeom.h:371
#define TRIANGLETYPE
Definition: liblwgeom.h:98
unsigned int uint32_t
Definition: uthash.h:78
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:214
uint8_t flags
Definition: liblwgeom.h:369
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:140
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
type
Definition: ovdump.py:41
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: