PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ parse_geojson_multilinestring()

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

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

312 {
313  LWGEOM *geom = NULL;
314  int i, j;
315  json_object* poObjLines = NULL;
316 
317  if (!root_srid)
318  {
319  geom = (LWGEOM *)lwcollection_construct_empty(MULTILINETYPE, root_srid, 1, 0);
320  }
321  else
322  {
324  }
325 
326  poObjLines = findMemberByName( geojson, "coordinates" );
327  if ( ! poObjLines )
328  {
329  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
330  return NULL;
331  }
332 
333  if( json_type_array == json_object_get_type( poObjLines ) )
334  {
335  const int nLines = json_object_array_length( poObjLines );
336  for( i = 0; i < nLines; ++i)
337  {
338  POINTARRAY *pa = NULL;
339  json_object* poObjLine = NULL;
340  poObjLine = json_object_array_get_idx( poObjLines, i );
341  pa = ptarray_construct_empty(1, 0, 1);
342 
343  if( json_type_array == json_object_get_type( poObjLine ) )
344  {
345  const int nPoints = json_object_array_length( poObjLine );
346  for(j = 0; j < nPoints; ++j)
347  {
348  json_object* coords = NULL;
349  coords = json_object_array_get_idx( poObjLine, j );
350  parse_geojson_coord(coords, hasz, pa);
351  }
352 
353  geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
354  (LWLINE*)lwline_construct(root_srid, NULL, pa));
355  }
356  }
357  }
358 
359  return geom;
360 }
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:35
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)
Definition: lwin_geojson.c:83
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
Definition: lwmline.c:32
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:45
#define MULTILINETYPE
Definition: liblwgeom.h:74
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: