@Test public void bbox_doesNotSerializeWhenNotPresent() throws Exception { List<Point> points = new ArrayList<>(); points.add(Point.fromLngLat(1.0, 2.0)); points.add(Point.fromLngLat(2.0, 3.0)); LineString lineString = LineString.fromLngLats(points); List<Geometry> geometries = new ArrayList<>(); geometries.add(points.get(0)); geometries.add(lineString); GeometryCollection geometryCollection = GeometryCollection.fromGeometries(geometries); compareJson(geometryCollection.toJson(), "{\"type\":\"GeometryCollection\",\"geometries\":[" + "{\"type\":\"Point\"," + "\"coordinates\":[1.0,2.0]},{\"type\":\"LineString\",\"coordinates\":[[1,2],[2,3]]}]}"); }
@Test public void bbox_doesSerializeWhenPresent() throws Exception { List<Point> points = new ArrayList<>(); points.add(Point.fromLngLat(1.0, 2.0)); points.add(Point.fromLngLat(2.0, 3.0)); LineString lineString = LineString.fromLngLats(points); List<Geometry> geometries = new ArrayList<>(); geometries.add(points.get(0)); geometries.add(lineString); BoundingBox bbox = BoundingBox.fromLngLats(1.0, 2.0, 3.0, 4.0); GeometryCollection geometryCollection = GeometryCollection.fromGeometries(geometries, bbox); compareJson(geometryCollection.toJson(), "{\"type\":\"GeometryCollection\",\"bbox\":[1.0,2.0,3.0,4.0]," + "\"geometries\":[{\"type\":\"Point\",\"coordinates\":[1.0,2.0]}," + "{\"type\":\"LineString\",\"coordinates\":[[1,2],[2,3]]}]}"); }
@Test public void toJson() throws IOException { final String json = loadJsonFixture(SAMPLE_GEOMETRYCOLLECTION); GeometryCollection geo = GeometryCollection.fromJson(json); compareJson(json, geo.toJson()); } }