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

Definition at line 268 of file lwin_geojson.c.

References findMemberByName(), geojson_lwerror(), lwcollection_construct_empty(), lwmpoint_add_lwpoint(), lwpoint_construct(), MULTIPOINTTYPE, parse_geojson_coord(), and ptarray_construct_empty().

Referenced by parse_geojson().

269 {
270  LWGEOM *geom;
271  int i = 0;
272  json_object* poObjPoints = NULL;
273 
274  if (!root_srid)
275  {
276  geom = (LWGEOM *)lwcollection_construct_empty(MULTIPOINTTYPE, root_srid, 1, 0);
277  }
278  else
279  {
281  }
282 
283  poObjPoints = findMemberByName( geojson, "coordinates" );
284  if ( ! poObjPoints ) {
285  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
286  return NULL;
287  }
288 
289  if( json_type_array == json_object_get_type( poObjPoints ) )
290  {
291  const int nPoints = json_object_array_length( poObjPoints );
292  for( i = 0; i < nPoints; ++i)
293  {
294  POINTARRAY *pa;
295  json_object* poObjCoords = NULL;
296  poObjCoords = json_object_array_get_idx( poObjPoints, i );
297 
298  pa = ptarray_construct_empty(1, 0, 1);
299  parse_geojson_coord(poObjCoords, hasz, pa);
300 
302  (LWPOINT*)lwpoint_construct(root_srid, NULL, pa));
303  }
304  }
305 
306  return geom;
307 }
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:57
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
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
LWGEOM * geom
static json_object * findMemberByName(json_object *poObj, const char *pszName)
Definition: lwin_geojson.c:46
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
Definition: lwmpoint.c:32
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
Definition: lwpoint.c:96
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: