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

Definition at line 170 of file lwin_geojson.c.

References findMemberByName(), geojson_lwerror(), LWDEBUG, lwline_construct(), parse_geojson_coord(), and ptarray_construct_empty().

Referenced by parse_geojson().

171 {
172  LWGEOM *geom;
173  POINTARRAY *pa;
174  json_object* points = NULL;
175  int i = 0;
176 
177  LWDEBUG(2, "parse_geojson_linestring called.");
178 
179  points = findMemberByName( geojson, "coordinates" );
180  if ( ! points )
181  {
182  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
183  return NULL;
184  }
185 
186  pa = ptarray_construct_empty(1, 0, 1);
187 
188  if( json_type_array == json_object_get_type( points ) )
189  {
190  const int nPoints = json_object_array_length( points );
191  for(i = 0; i < nPoints; ++i)
192  {
193  json_object* coords = NULL;
194  coords = json_object_array_get_idx( points, i );
195  parse_geojson_coord(coords, hasz, pa);
196  }
197  }
198 
199  geom = (LWGEOM *) lwline_construct(root_srid, NULL, pa);
200 
201  LWDEBUG(2, "parse_geojson_linestring finished.");
202  return geom;
203 }
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
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)
Definition: lwin_geojson.c:83
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

Here is the call graph for this function:

Here is the caller graph for this function: