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

Definition at line 331 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().

332 {
333  LWGEOM *geom = NULL;
334  int i, j;
335  json_object* poObjLines = NULL;
336 
337  if (!root_srid)
338  {
339  geom = (LWGEOM *)lwcollection_construct_empty(MULTILINETYPE, root_srid, 1, 0);
340  }
341  else
342  {
344  }
345 
346  poObjLines = findMemberByName( geojson, "coordinates" );
347  if ( ! poObjLines )
348  {
349  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
350  return NULL;
351  }
352 
353  if( json_type_array == json_object_get_type( poObjLines ) )
354  {
355  const int nLines = json_object_array_length( poObjLines );
356  for( i = 0; i < nLines; ++i)
357  {
358  POINTARRAY *pa = NULL;
359  json_object* poObjLine = NULL;
360  poObjLine = json_object_array_get_idx( poObjLines, i );
361  pa = ptarray_construct_empty(1, 0, 1);
362 
363  if( json_type_array == json_object_get_type( poObjLine ) )
364  {
365  const int nPoints = json_object_array_length( poObjLine );
366  for(j = 0; j < nPoints; ++j)
367  {
368  json_object* coords = NULL;
369  coords = json_object_array_get_idx( poObjLine, j );
370  parse_geojson_coord(coords, hasz, pa);
371  }
372 
373  geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
374  (LWLINE*)lwline_construct(root_srid, NULL, pa));
375  }
376  }
377  }
378 
379  return geom;
380 }
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:55
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)
Definition: lwin_geojson.c:103
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:65
#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: