175{
176 if (!rings || json_object_get_type(rings) != json_type_array)
177 return NULL;
178
179 int nRings = json_object_array_length(rings);
180
181
182 if (!nRings)
184
185
187 int o = 0;
188
189 for (int i = 0; i < nRings; i++)
190 {
191 json_object *points = json_object_array_get_idx(rings, i);
192 if (!points || json_object_get_type(points) != json_type_array)
193 {
194 for (int k = 0; k < o; k++)
197 lwerror(
"The 'coordinates' in GeoJSON ring are not an array");
198 return NULL;
199 }
200 int nPoints = json_object_array_length(points);
201
202
203 if (!nPoints)
204 {
205
206 if (!i)
207 break;
208 else
209 continue;
210 }
211
213 for (int j = 0; j < nPoints; j++)
214 {
215 json_object *coords = NULL;
216 coords = json_object_array_get_idx(points, j);
218 {
219 for (int k = 0; k <= o; k++)
222 lwerror(
"The 'coordinates' in GeoJSON are not sufficiently nested");
223 return NULL;
224 }
225 }
226 o++;
227 }
228
229
230 if (!o)
231 {
234 }
235
237}
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 lwerror(const char *fmt,...)
Write a notice out to the error handler.
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)