PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ parse_geojson_multilinestring()

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

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

342 {
343  LWGEOM *geom = NULL;
344  int i, j;
345  json_object* poObjLines = NULL;
346 
347  if (!root_srid)
348  {
349  geom = (LWGEOM *)lwcollection_construct_empty(MULTILINETYPE, root_srid, 1, 0);
350  }
351  else
352  {
354  }
355 
356  poObjLines = findMemberByName( geojson, "coordinates" );
357  if ( ! poObjLines )
358  {
359  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
360  return NULL;
361  }
362 
363  if( json_type_array == json_object_get_type( poObjLines ) )
364  {
365  const int nLines = json_object_array_length( poObjLines );
366  for( i = 0; i < nLines; ++i)
367  {
368  POINTARRAY *pa = NULL;
369  json_object* poObjLine = NULL;
370  poObjLine = json_object_array_get_idx( poObjLines, i );
371  pa = ptarray_construct_empty(1, 0, 1);
372 
373  if( json_type_array == json_object_get_type( poObjLine ) )
374  {
375  const int nPoints = json_object_array_length( poObjLine );
376  for(j = 0; j < nPoints; ++j)
377  {
378  json_object* coords = NULL;
379  coords = json_object_array_get_idx( poObjLine, j );
380  parse_geojson_coord(coords, hasz, pa);
381  }
382 
383  geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
384  (LWLINE*)lwline_construct(root_srid, NULL, pa));
385  }
386  }
387  }
388 
389  return geom;
390 }
static void geojson_lwerror(char *msg, __attribute__((__unused__)) int error_code)
Definition: lwin_geojson.c:55
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
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: