PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ parse_geojson_multipoint()

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

Definition at line 295 of file lwin_geojson.c.

296 {
297  LWGEOM *geom;
298  int i = 0;
299  json_object* poObjPoints = NULL;
300 
301  if (!root_srid)
302  {
303  geom = (LWGEOM *)lwcollection_construct_empty(MULTIPOINTTYPE, root_srid, 1, 0);
304  }
305  else
306  {
308  }
309 
310  poObjPoints = findMemberByName( geojson, "coordinates" );
311  if ( ! poObjPoints )
312  {
313  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
314  return NULL;
315  }
316 
317  if( json_type_array == json_object_get_type( poObjPoints ) )
318  {
319  const int nPoints = json_object_array_length( poObjPoints );
320  for( i = 0; i < nPoints; ++i)
321  {
322  POINTARRAY *pa;
323  json_object* poObjCoords = NULL;
324  poObjCoords = json_object_array_get_idx( poObjPoints, i );
325 
326  pa = ptarray_construct_empty(1, 0, 1);
327  parse_geojson_coord(poObjCoords, hasz, pa);
328 
329  geom = (LWGEOM*)lwmpoint_add_lwpoint((LWMPOINT*)geom,
330  (LWPOINT*)lwpoint_construct(root_srid, NULL, pa));
331  }
332  }
333 
334  return geom;
335 }
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int srid, char hasz, char hasm)
Definition: lwcollection.c:94
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
Definition: lwmpoint.c:45
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:129
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
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(), lwmpoint_add_lwpoint(), lwpoint_construct(), MULTIPOINTTYPE, 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: