@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)); points.add(Point.fromLngLat(3.0, 4.0)); points.add(Point.fromLngLat(1.0, 2.0)); LineString outer = LineString.fromLngLats(points); List<LineString> inner = new ArrayList<>(); inner.add(LineString.fromLngLats(points)); inner.add(LineString.fromLngLats(points)); Polygon polygon = Polygon.fromOuterInner(outer, inner); compareJson(polygon.toJson(), "{\"type\":\"Polygon\",\"coordinates\":" + "[[[1,2],[2,3],[3,4],[1,2]],[[1,2],[2,3],[3,4],[1,2]],[[1,2],[2,3],[3,4],[1,2]]]}"); }
@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)); points.add(Point.fromLngLat(3.0, 4.0)); points.add(Point.fromLngLat(1.0, 2.0)); LineString outer = LineString.fromLngLats(points); BoundingBox bbox = BoundingBox.fromLngLats(1.0, 2.0, 3.0, 4.0); List<LineString> inner = new ArrayList<>(); inner.add(LineString.fromLngLats(points)); inner.add(LineString.fromLngLats(points)); Polygon polygon = Polygon.fromOuterInner(outer, bbox, inner); compareJson(polygon.toJson(), "{\"type\":\"Polygon\",\"bbox\":[1.0,2.0,3.0,4.0],\"coordinates\":" + "[[[1,2],[2,3],[3,4],[1,2]],[[1,2],[2,3],[3,4],[1,2]],[[1,2],[2,3],[3,4],[1,2]]]}"); }
@Test public void toJsonHoles() throws IOException { final String json = loadJsonFixture(SAMPLE_POLYGON_HOLES); Polygon geo = Polygon.fromJson(json); compareJson(json, geo.toJson()); }
@Test public void toJson() throws IOException { final String json = loadJsonFixture(SAMPLE_POLYGON); Polygon geo = Polygon.fromJson(json); compareJson(json, geo.toJson()); }
@Test @Ignore public void name() throws Exception { Feature feature = Feature.fromJson(loadJsonFixture(CIRCLE_IN)); Polygon polygon = TurfTransformation.circle((Point) feature.geometry(), feature.getNumberProperty("radius").doubleValue()); FeatureCollection featureCollection = FeatureCollection.fromJson(loadJsonFixture(CIRCLE_OUT)); compareJson(featureCollection.features().get(1).geometry().toJson(), polygon.toJson()); } }