PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ parse_geojson_multilinestring()

static LWGEOM* parse_geojson_multilinestring ( json_object *  geojson,
int *  hasz,
int  root_srid 
)
static

Definition at line 338 of file lwin_geojson.c.

339 {
340  LWGEOM *geom = NULL;
341  int i, j;
342  json_object* poObjLines = NULL;
343 
344  if (!root_srid)
345  {
346  geom = (LWGEOM *)lwcollection_construct_empty(MULTILINETYPE, root_srid, 1, 0);
347  }
348  else
349  {
351  }
352 
353  poObjLines = findMemberByName( geojson, "coordinates" );
354  if ( ! poObjLines )
355  {
356  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
357  return NULL;
358  }
359 
360  if( json_type_array == json_object_get_type( poObjLines ) )
361  {
362  const int nLines = json_object_array_length( poObjLines );
363  for( i = 0; i < nLines; ++i)
364  {
365  POINTARRAY *pa = NULL;
366  json_object* poObjLine = NULL;
367  poObjLine = json_object_array_get_idx( poObjLines, i );
368  pa = ptarray_construct_empty(1, 0, 1);
369 
370  if( json_type_array == json_object_get_type( poObjLine ) )
371  {
372  const int nPoints = json_object_array_length( poObjLine );
373  for(j = 0; j < nPoints; ++j)
374  {
375  json_object* coords = NULL;
376  coords = json_object_array_get_idx( poObjLine, j );
377  parse_geojson_coord(coords, hasz, pa);
378  }
379 
380  geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
381  (LWLINE*)lwline_construct(root_srid, NULL, pa));
382  }
383  }
384  }
385 
386  return geom;
387 }
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
#define MULTILINETYPE
Definition: liblwgeom.h:89
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
Definition: lwmline.c:46
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)
Definition: lwin_geojson.c:103
static void geojson_lwerror(char *msg, __attribute__((__unused__)) int error_code)
Definition: lwin_geojson.c:55
static json_object * findMemberByName(json_object *poObj, const char *pszName)
Definition: lwin_geojson.c:65

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

Referenced by parse_geojson().

Here is the call graph for this function:
Here is the caller graph for this function: