177{
178 if (!rings || json_object_get_type(rings) != json_type_array)
179 return NULL;
180
181 int nRings = json_object_array_length(rings);
182
183
184 if (!nRings)
186
187
189 int o = 0;
190
191 for (int i = 0; i < nRings; i++)
192 {
193 json_object *points = json_object_array_get_idx(rings, i);
194 if (!points || json_object_get_type(points) != json_type_array)
195 {
196 for (int k = 0; k < o; k++)
199 lwerror(
"The 'coordinates' in GeoJSON ring are not an array");
200 return NULL;
201 }
202 int nPoints = json_object_array_length(points);
203
204
205 if (!nPoints)
206 {
207
208 if (!i)
209 break;
210 else
211 continue;
212 }
213
215 for (int j = 0; j < nPoints; j++)
216 {
217 json_object *coords = NULL;
218 coords = json_object_array_get_idx(points, j);
220 {
221 for (int k = 0; k <= o; k++)
224 lwerror(
"The 'coordinates' in GeoJSON are not sufficiently nested");
225 return NULL;
226 }
227 }
228 o++;
229 }
230
231
232 if (!o)
233 {
236 }
237
239}
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void * lwalloc(size_t size)
void ptarray_free(POINTARRAY *pa)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)