PostGIS  2.3.7dev-r@@SVN_REVISION@@
static LWGEOM* parse_geojson_multilinestring ( json_object *  geojson,
int *  hasz,
int  root_srid 
)
static

Definition at line 325 of file lwin_geojson.c.

References findMemberByName(), geojson_lwerror(), lwcollection_construct_empty(), lwline_construct(), lwmline_add_lwline(), MULTILINETYPE, parse_geojson_coord(), and ptarray_construct_empty().

Referenced by parse_geojson().

326 {
327  LWGEOM *geom = NULL;
328  int i, j;
329  json_object* poObjLines = NULL;
330 
331  if (!root_srid)
332  {
333  geom = (LWGEOM *)lwcollection_construct_empty(MULTILINETYPE, root_srid, 1, 0);
334  }
335  else
336  {
338  }
339 
340  poObjLines = findMemberByName( geojson, "coordinates" );
341  if ( ! poObjLines )
342  {
343  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
344  return NULL;
345  }
346 
347  if( json_type_array == json_object_get_type( poObjLines ) )
348  {
349  const int nLines = json_object_array_length( poObjLines );
350  for( i = 0; i < nLines; ++i)
351  {
352  POINTARRAY *pa = NULL;
353  json_object* poObjLine = NULL;
354  poObjLine = json_object_array_get_idx( poObjLines, i );
355  pa = ptarray_construct_empty(1, 0, 1);
356 
357  if( json_type_array == json_object_get_type( poObjLine ) )
358  {
359  const int nPoints = json_object_array_length( poObjLine );
360  for(j = 0; j < nPoints; ++j)
361  {
362  json_object* coords = NULL;
363  coords = json_object_array_get_idx( poObjLine, j );
364  parse_geojson_coord(coords, hasz, pa);
365  }
366 
367  geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
368  (LWLINE*)lwline_construct(root_srid, NULL, pa));
369  }
370  }
371  }
372 
373  return geom;
374 }
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
static void geojson_lwerror(char *msg, int error_code)
Definition: lwin_geojson.c:49
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)
Definition: lwin_geojson.c:97
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
Definition: lwmline.c:46
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
static json_object * findMemberByName(json_object *poObj, const char *pszName)
Definition: lwin_geojson.c:59
#define MULTILINETYPE
Definition: liblwgeom.h:88
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94

Here is the call graph for this function:

Here is the caller graph for this function: