115{
117 uint32_t i, npoints;
119
120 assert(geom);
121
122 switch (sfcgal_geometry_type_id(geom))
123 {
124 case SFCGAL_TYPE_POINT:
125 {
127 point.
x = sfcgal_point_x(geom);
128 point.
y = sfcgal_point_y(geom);
129
130 if (sfcgal_geometry_is_3d(geom))
131 point.
z = sfcgal_point_z(geom);
132 else if (want3d)
134
136 }
137 break;
138
139 case SFCGAL_TYPE_LINESTRING:
140 {
141 npoints = sfcgal_linestring_num_points(geom);
143
144 for (i = 0; i < npoints; i++)
145 {
146 const sfcgal_geometry_t *pt = sfcgal_linestring_point_n(geom, i);
147 point.
x = sfcgal_point_x(pt);
148 point.
y = sfcgal_point_y(pt);
149
150 if (sfcgal_geometry_is_3d(geom))
151 point.
z = sfcgal_point_z(pt);
152 else if (want3d)
154
156 }
157 }
158 break;
159
160 case SFCGAL_TYPE_TRIANGLE:
161 {
163
164 for (i = 0; i < 4; i++)
165 {
166 const sfcgal_geometry_t *pt = sfcgal_triangle_vertex(geom, (i % 3));
167 point.
x = sfcgal_point_x(pt);
168 point.
y = sfcgal_point_y(pt);
169
170 if (sfcgal_geometry_is_3d(geom))
171 point.
z = sfcgal_point_z(pt);
172 else if (want3d)
174
176 }
177 }
178 break;
179
180
181 default:
182 lwerror(
"ptarray_from_SFCGAL: Unknown Type");
183 break;
184 }
185 return pa;
186}
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 lwerror(const char *fmt,...)
Write a notice out to the error handler.