15 #include "CUnit/Basic.h"
49 "POINT(1.1111111111111 1.1111111111111)",
50 "{\"type\":\"Point\",\"coordinates\":[1,1]}",
55 "POINT(1.1111111111111 1.1111111111111)",
56 "{\"type\":\"Point\",\"coordinates\":[1.111,1.111]}",
61 "POINT(1.2345678901234 1.2345678901234)",
62 "{\"type\":\"Point\",\"coordinates\":[1.23456789,1.23456789]}",
67 "POINT(1E300 -1E300)",
68 "{\"type\":\"Point\",\"coordinates\":[1e+300,-1e+300]}",
74 "{\"type\":\"Point\",\"coordinates\":[1,2]}",
79 "POINT(59.99 -59.99)",
80 "{\"type\":\"Point\",\"coordinates\":[59.99,-59.99]}",
84 do_geojson_test(
"POINT(1E-300 -2E-200)",
"{\"type\":\"Point\",\"coordinates\":[1e-300,-2e-200]}", NULL, 300, 0);
93 "{\"type\":\"Point\",\"coordinates\":[0,1,2]}",
99 "{\"type\":\"Point\",\"coordinates\":[0,1]}",
105 "{\"type\":\"Point\",\"coordinates\":[0,1,2]}",
114 "LINESTRING(0 1,2 3,4 5)",
115 "{\"type\":\"LineString\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"coordinates\":[[0,1],[2,3],[4,5]]}",
120 "POLYGON((0 1,2 3,4 5,0 1))",
121 "{\"type\":\"Polygon\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"coordinates\":[[[0,1],[2,3],[4,5],[0,1]]]}",
126 "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
127 "{\"type\":\"Polygon\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"coordinates\":[[[0,1],[2,3],[4,5],[0,1]],[[6,7],[8,9],[10,11],[6,7]]]}",
132 "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
133 "{\"type\":\"MultiLineString\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"coordinates\":[[[0,1],[2,3],[4,5]],[[6,7],[8,9],[10,11]]]}",
138 "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
139 "{\"type\":\"MultiPolygon\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"coordinates\":[[[[0,1],[2,3],[4,5],[0,1]]],[[[6,7],[8,9],[10,11],[6,7]]]]}",
144 "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
145 "{\"type\":\"GeometryCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"geometries\":[{\"type\":\"Point\",\"coordinates\":[0,1]},{\"type\":\"LineString\",\"coordinates\":[[2,3],[4,5]]}]}",
150 "GEOMETRYCOLLECTION EMPTY",
151 "{\"type\":\"GeometryCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"geometries\":[]}",
155 static void out_geojson_test_bbox(
void)
159 "LINESTRING(0 1,2 3,4 5)",
160 "{\"type\":\"LineString\",\"bbox\":[0,1,4,5],\"coordinates\":[[0,1],[2,3],[4,5]]}",
165 "POLYGON((0 1,2 3,4 5,0 1))",
166 "{\"type\":\"Polygon\",\"bbox\":[0,1,4,5],\"coordinates\":[[[0,1],[2,3],[4,5],[0,1]]]}",
171 "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
172 "{\"type\":\"Polygon\",\"bbox\":[0,1,4,5],\"coordinates\":[[[0,1],[2,3],[4,5],[0,1]],[[6,7],[8,9],[10,11],[6,7]]]}",
177 "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
178 "{\"type\":\"MultiLineString\",\"bbox\":[0,1,10,11],\"coordinates\":[[[0,1],[2,3],[4,5]],[[6,7],[8,9],[10,11]]]}",
183 "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
184 "{\"type\":\"MultiPolygon\",\"bbox\":[0,1,10,11],\"coordinates\":[[[[0,1],[2,3],[4,5],[0,1]]],[[[6,7],[8,9],[10,11],[6,7]]]]}",
189 "GEOMETRYCOLLECTION(LINESTRING(0 1,-1 3),LINESTRING(2 3,4 5))",
190 "{\"type\":\"GeometryCollection\",\"bbox\":[-1,1,4,5],\"geometries\":[{\"type\":\"LineString\",\"coordinates\":[[0,1],[-1,3]]},{\"type\":\"LineString\",\"coordinates\":[[2,3],[4,5]]}]}",
195 "GEOMETRYCOLLECTION EMPTY",
196 "{\"type\":\"GeometryCollection\",\"geometries\":[]}",
200 static void out_geojson_test_geoms(
void)
204 "LINESTRING(0 1,2 3,4 5)",
205 "{\"type\":\"LineString\",\"coordinates\":[[0,1],[2,3],[4,5]]}",
210 "POLYGON((0 1,2 3,4 5,0 1))",
211 "{\"type\":\"Polygon\",\"coordinates\":[[[0,1],[2,3],[4,5],[0,1]]]}",
216 "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
217 "{\"type\":\"Polygon\",\"coordinates\":[[[0,1],[2,3],[4,5],[0,1]],[[6,7],[8,9],[10,11],[6,7]]]}",
222 "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
223 "{\"type\":\"MultiLineString\",\"coordinates\":[[[0,1],[2,3],[4,5]],[[6,7],[8,9],[10,11]]]}",
228 "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
229 "{\"type\":\"MultiPolygon\",\"coordinates\":[[[[0,1],[2,3],[4,5],[0,1]]],[[[6,7],[8,9],[10,11],[6,7]]]]}",
234 "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
235 "{\"type\":\"GeometryCollection\",\"geometries\":[{\"type\":\"Point\",\"coordinates\":[0,1]},{\"type\":\"LineString\",\"coordinates\":[[2,3],[4,5]]}]}",
240 "GEOMETRYCOLLECTION EMPTY",
241 "{\"type\":\"GeometryCollection\",\"geometries\":[]}",
246 "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
247 "GeoJson: geometry not supported.");
251 "CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)",
252 "lwgeom_to_geojson: 'CircularString' geometry type not supported");
256 "COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))",
257 "lwgeom_to_geojson: 'CompoundCurve' geometry type not supported");
261 "CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))",
262 "lwgeom_to_geojson: 'CurvePolygon' geometry type not supported");
266 "MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))",
267 "lwgeom_to_geojson: 'MultiCurve' geometry type not supported");
271 "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
272 "lwgeom_to_geojson: 'MultiSurface' geometry type not supported");
281 CU_pSuite suite = CU_add_suite(
"geojson_output", NULL, NULL);
static void out_geojson_test_dims(void)
static void do_geojson_unsupported(char *in, char *out)
static void out_geojson_test_precision(void)
static void do_geojson_test(char *in, char *out, char *srs, int precision, int has_bbox)
static void out_geojson_test_srid(void)
void cu_error_msg_reset()
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
void out_geojson_suite_setup(void)
#define ASSERT_VARLENA_EQUAL(v, s)
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
void lwgeom_free(LWGEOM *geom)
#define LW_PARSER_CHECK_NONE
lwvarlena_t * lwgeom_to_geojson(const LWGEOM *geo, const char *srs, int precision, int has_bbox)
Takes a GEOMETRY and returns a GeoJson representation.
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)