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

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

311 {
312  LWGEOM *geom = NULL;
313  int i, j;
314  json_object* poObjLines = NULL;
315 
316  if (!root_srid)
317  {
318  geom = (LWGEOM *)lwcollection_construct_empty(MULTILINETYPE, root_srid, 1, 0);
319  }
320  else
321  {
323  }
324 
325  poObjLines = findMemberByName( geojson, "coordinates" );
326  if ( ! poObjLines ) {
327  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
328  return NULL;
329  }
330 
331  if( json_type_array == json_object_get_type( poObjLines ) )
332  {
333  const int nLines = json_object_array_length( poObjLines );
334  for( i = 0; i < nLines; ++i)
335  {
336  POINTARRAY *pa = NULL;
337  json_object* poObjLine = NULL;
338  poObjLine = json_object_array_get_idx( poObjLines, i );
339  pa = ptarray_construct_empty(1, 0, 1);
340 
341  if( json_type_array == json_object_get_type( poObjLine ) )
342  {
343  const int nPoints = json_object_array_length( poObjLine );
344  for(j = 0; j < nPoints; ++j)
345  {
346  json_object* coords = NULL;
347  coords = json_object_array_get_idx( poObjLine, j );
348  parse_geojson_coord(coords, hasz, pa);
349  }
350 
352  (LWLINE*)lwline_construct(root_srid, NULL, pa));
353  }
354  }
355  }
356 
357  return geom;
358 }
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:57
static void geojson_lwerror(char *msg, int error_code)
Definition: lwin_geojson.c:36
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)
Definition: lwin_geojson.c:84
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
Definition: lwmline.c:33
LWGEOM * geom
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
static json_object * findMemberByName(json_object *poObj, const char *pszName)
Definition: lwin_geojson.c:46
#define MULTILINETYPE
Definition: liblwgeom.h:64
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:81

Here is the call graph for this function:

Here is the caller graph for this function: