PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ parse_geojson_linestring()

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

Definition at line 190 of file lwin_geojson.c.

191 {
192  LWGEOM *geom;
193  POINTARRAY *pa;
194  json_object* points = NULL;
195  int i = 0;
196 
197  LWDEBUG(2, "parse_geojson_linestring called.");
198 
199  points = findMemberByName( geojson, "coordinates" );
200  if ( ! points )
201  {
202  geojson_lwerror("Unable to find 'coordinates' in GeoJSON string", 4);
203  return NULL;
204  }
205 
206  pa = ptarray_construct_empty(1, 0, 1);
207 
208  if( json_type_array == json_object_get_type( points ) )
209  {
210  const int nPoints = json_object_array_length( points );
211  for(i = 0; i < nPoints; ++i)
212  {
213  json_object* coords = NULL;
214  coords = json_object_array_get_idx( points, i );
215  parse_geojson_coord(coords, hasz, pa);
216  }
217  }
218 
219  geom = (LWGEOM *) lwline_construct(root_srid, NULL, pa);
220 
221  LWDEBUG(2, "parse_geojson_linestring finished.");
222  return geom;
223 }
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
#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: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(), LWDEBUG, lwline_construct(), 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: