143{
145 uint32_t i, npoints;
147 int is_3d;
148 int is_measured = 0;
149
150 assert(geom);
151
152 is_3d = sfcgal_geometry_is_3d(geom);
153
154#if POSTGIS_SFCGAL_VERSION >= 10308
155 is_measured = sfcgal_geometry_is_measured(geom);
156#endif
157
158 switch (sfcgal_geometry_type_id(geom))
159 {
160 case SFCGAL_TYPE_POINT: {
162 point.
x = sfcgal_point_x(geom);
163 point.
y = sfcgal_point_y(geom);
164
165 if (is_3d)
166 point.
z = sfcgal_point_z(geom);
167 else if (want3d)
169
170#if POSTGIS_SFCGAL_VERSION >= 10308
171 if (is_measured)
172 point.
m = sfcgal_point_m(geom);
173#endif
174
176 }
177 break;
178
179 case SFCGAL_TYPE_LINESTRING: {
180 npoints = sfcgal_linestring_num_points(geom);
182
183 for (i = 0; i < npoints; i++)
184 {
185 const sfcgal_geometry_t *pt = sfcgal_linestring_point_n(geom, i);
186 point.
x = sfcgal_point_x(pt);
187 point.
y = sfcgal_point_y(pt);
188
189 if (is_3d)
190 point.
z = sfcgal_point_z(pt);
191 else if (want3d)
193
194#if POSTGIS_SFCGAL_VERSION >= 10308
195 if (is_measured)
196 point.
m = sfcgal_point_m(pt);
197#endif
198
200 }
201 }
202 break;
203
204 case SFCGAL_TYPE_TRIANGLE: {
206
207 for (i = 0; i < 4; i++)
208 {
209 const sfcgal_geometry_t *pt = sfcgal_triangle_vertex(geom, (i % 3));
210 point.
x = sfcgal_point_x(pt);
211 point.
y = sfcgal_point_y(pt);
212
213 if (is_3d)
214 point.
z = sfcgal_point_z(pt);
215 else if (want3d)
217
218#if POSTGIS_SFCGAL_VERSION >= 10308
219 if (is_measured)
220 point.
m = sfcgal_point_m(pt);
221#endif
222
224 }
225 }
226 break;
227
228
229 default:
230 lwerror(
"ptarray_from_SFCGAL: Unknown Type");
231 break;
232 }
233 return pa;
234}
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
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...
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.