PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ ptarray_from_SFCGAL()

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

Definition at line 129 of file lwgeom_sfcgal.c.

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

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: