/** * An iterable of locations will turn into a JsonArray of Longitude, Latitude coordinates. * * @param locations * An iterable of locations * @return A JsonArray of Longitude, Latitude coordinates. */ public static JsonArray locationsToCoordinates(final Iterable<Location> locations) { final JsonArray coordinates = new JsonArray(); for (final Location point : locations) { coordinates.add(coordinate(point)); } return coordinates; }
@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.geometry(GeoJsonUtils.POINT, GeoJsonUtils.coordinate(this)); }
/** * Creates a GeoJSON Polygon geometry from a bounds. * * @param bounds * A bounds. * @return A GeoJSON Polygon geometry JsonObject. */ public static JsonObject boundsToPolygonGeometry(final Rectangle bounds) { final JsonArray outerRing = new JsonArray(); final Iterable<Location> locations = bounds.closedLoop(); for (final Location location : locations) { outerRing.add(coordinate(location)); } final JsonArray coordinates = new JsonArray(); coordinates.add(outerRing); return geometry(POLYGON, coordinates); }
/** * From a location, we get a Latitude / Longitude Json Array [ latitude, longitude ] * * @param location * An atlas location * @return JsonArray [ longitude, latitude ] coordinate. */ public static JsonArray coordinate(final Location location) { return coordinate(location.getLongitude().asDegrees(), location.getLatitude().asDegrees()); }
@Test public void testCoordinate() { final JsonArray coordinate = GeoJsonUtils.coordinate(LONGITUDE, LATITUDE); Assert.assertEquals(COORDINATE, coordinate.toString()); } }
return GeoJsonUtils.geometry(GeoJsonUtils.POINT, GeoJsonUtils.coordinate(0.0, 0.0));