PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ ptarray_from_SFCGAL()

static POINTARRAY * ptarray_from_SFCGAL ( const sfcgal_geometry_t *  geom,
int  force3D 
)
static

Definition at line 131 of file lwgeom_sfcgal.c.

132 {
133  POINT4D point;
134  uint32_t i, npoints;
135  POINTARRAY *pa = NULL;
136 
137  assert(geom);
138 
139  switch (sfcgal_geometry_type_id(geom))
140  {
141  case SFCGAL_TYPE_POINT:
142  {
143  pa = ptarray_construct(want3d, 0, 1);
144  point.x = sfcgal_point_x(geom);
145  point.y = sfcgal_point_y(geom);
146 
147  if (sfcgal_geometry_is_3d(geom))
148  point.z = sfcgal_point_z(geom);
149  else if (want3d)
150  point.z = 0.0;
151 
152  ptarray_set_point4d(pa, 0, &point);
153  }
154  break;
155 
156  case SFCGAL_TYPE_LINESTRING:
157  {
158  npoints = sfcgal_linestring_num_points(geom);
159  pa = ptarray_construct(want3d, 0, npoints);
160 
161  for (i = 0; i < npoints; i++)
162  {
163  const sfcgal_geometry_t *pt = sfcgal_linestring_point_n(geom, i);
164  point.x = sfcgal_point_x(pt);
165  point.y = sfcgal_point_y(pt);
166 
167  if (sfcgal_geometry_is_3d(geom))
168  point.z = sfcgal_point_z(pt);
169  else if (want3d)
170  point.z = 0.0;
171 
172  ptarray_set_point4d(pa, i, &point);
173  }
174  }
175  break;
176 
177  case SFCGAL_TYPE_TRIANGLE:
178  {
179  pa = ptarray_construct(want3d, 0, 4);
180 
181  for (i = 0; i < 4; i++)
182  {
183  const sfcgal_geometry_t *pt = sfcgal_triangle_vertex(geom, (i % 3));
184  point.x = sfcgal_point_x(pt);
185  point.y = sfcgal_point_y(pt);
186 
187  if (sfcgal_geometry_is_3d(geom))
188  point.z = sfcgal_point_z(pt);
189  else if (want3d)
190  point.z = 0.0;
191 
192  ptarray_set_point4d(pa, i, &point);
193  }
194  }
195  break;
196 
197  /* Other types should not be called directly ... */
198  default:
199  lwerror("ptarray_from_SFCGAL: Unknown Type");
200  break;
201  }
202  return pa;
203 }
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition: ptarray.c:51
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition: lwgeom_api.c:369
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
double x
Definition: liblwgeom.h:414
double z
Definition: liblwgeom.h:414
double y
Definition: liblwgeom.h:414

References lwerror(), ptarray_construct(), ptarray_set_point4d(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by SFCGAL2LWGEOM().

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