PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ parse_geojson_coord()

static int parse_geojson_coord ( json_object *  poObj,
int *  hasz,
POINTARRAY pa 
)
inlinestatic

Definition at line 106 of file lwin_geojson.c.

107{
108 POINT4D pt = {0, 0, 0, 0};
109
110 if (json_object_get_type(poObj) == json_type_array)
111 {
112 json_object *poObjCoord = NULL;
113 const int nSize = json_object_array_length(poObj);
114 if (nSize == 0)
115 return LW_TRUE;
116 if (nSize < 2)
117 {
118 lwerror("Too few ordinates in GeoJSON");
119 return LW_FAILURE;
120 }
121
122 /* Read X coordinate */
123 poObjCoord = json_object_array_get_idx(poObj, 0);
124 pt.x = json_object_get_double(poObjCoord);
125
126 /* Read Y coordinate */
127 poObjCoord = json_object_array_get_idx(poObj, 1);
128 pt.y = json_object_get_double(poObjCoord);
129
130 if (nSize > 2) /* should this be >= 3 ? */
131 {
132 /* Read Z coordinate */
133 poObjCoord = json_object_array_get_idx(poObj, 2);
134 pt.z = json_object_get_double(poObjCoord);
135 *hasz = LW_TRUE;
136 }
137 }
138 else
139 {
140 /* If it's not an array, just don't handle it */
141 lwerror("The 'coordinates' in GeoJSON are not sufficiently nested");
142 return LW_FAILURE;
143 }
144
145 return ptarray_append_point(pa, &pt, LW_TRUE);
146}
#define LW_FAILURE
Definition liblwgeom.h:96
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
Definition ptarray.c:147
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
double x
Definition liblwgeom.h:414
double z
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414

References LW_FAILURE, LW_TRUE, lwerror(), ptarray_append_point(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by parse_geojson_linestring(), parse_geojson_multilinestring(), parse_geojson_multipoint(), parse_geojson_point(), and parse_geojson_poly_rings().

Here is the call graph for this function:
Here is the caller graph for this function: