PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ parse_geojson_linestring()

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

Definition at line 184 of file lwin_geojson.c.

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

Referenced by parse_geojson().

185 {
186  LWGEOM *geom;
187  POINTARRAY *pa;
188  json_object* points = NULL;
189  int i = 0;
190 
191  LWDEBUG(2, "parse_geojson_linestring called.");
192 
193  points = findMemberByName( geojson, "coordinates" );
194  if ( ! points )
195  {
196  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
197  return NULL;
198  }
199 
200  pa = ptarray_construct_empty(1, 0, 1);
201 
202  if( json_type_array == json_object_get_type( points ) )
203  {
204  const int nPoints = json_object_array_length( points );
205  for(i = 0; i < nPoints; ++i)
206  {
207  json_object* coords = NULL;
208  coords = json_object_array_get_idx( points, i );
209  parse_geojson_coord(coords, hasz, pa);
210  }
211  }
212 
213  geom = (LWGEOM *) lwline_construct(root_srid, NULL, pa);
214 
215  LWDEBUG(2, "parse_geojson_linestring finished.");
216  return geom;
217 }
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:49
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
static int parse_geojson_coord(json_object *poObj, int *hasz, POINTARRAY *pa)
Definition: lwin_geojson.c:97
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:59
Here is the call graph for this function:
Here is the caller graph for this function: