PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ptarray_from_SFCGAL()

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

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

115{
116 POINT4D point;
117 uint32_t i, npoints;
118 POINTARRAY *pa = NULL;
119
120 assert(geom);
121
122 switch (sfcgal_geometry_type_id(geom))
123 {
124 case SFCGAL_TYPE_POINT:
125 {
126 pa = ptarray_construct(want3d, 0, 1);
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)
133 point.z = 0.0;
134
135 ptarray_set_point4d(pa, 0, &point);
136 }
137 break;
138
139 case SFCGAL_TYPE_LINESTRING:
140 {
141 npoints = sfcgal_linestring_num_points(geom);
142 pa = ptarray_construct(want3d, 0, npoints);
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)
153 point.z = 0.0;
154
155 ptarray_set_point4d(pa, i, &point);
156 }
157 }
158 break;
159
160 case SFCGAL_TYPE_TRIANGLE:
161 {
162 pa = ptarray_construct(want3d, 0, 4);
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)
173 point.z = 0.0;
174
175 ptarray_set_point4d(pa, i, &point);
176 }
177 }
178 break;
179
180 /* Other types should not be called directly ... */
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)
Definition lwgeom_api.c:376
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 lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
double x
Definition liblwgeom.h:400
double z
Definition liblwgeom.h:400
double y
Definition liblwgeom.h:400

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: