@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.geometry(GeoJsonUtils.POINT, GeoJsonUtils.coordinate(this)); }
/** * Creates a Point type GeoJson Feature * * @param location * geometry * @return a Feature */ public GeoJsonObject create(final Location location) { return this.create(location, GeoJsonType.POINT); }
@Override public JsonObject asGeoJsonGeometry() { return GeoJsonUtils.geometry(GeoJsonUtils.LINESTRING, GeoJsonUtils.locationsToCoordinates(this.points)); }
public static void save(final Iterable<? extends Iterable<Location>> geometries, final WritableResource destination) { final GeoJsonObject object = new GeoJsonBuilder().create(Iterables.translate(geometries, polyLine -> new GeoJsonBuilder.LocationIterableProperties(polyLine, Maps.hashMap()))); save(object, destination); }
public static GeoJsonObject asGeoJson(final Iterable<? extends Iterable<Location>> geometries) { return new GeoJsonBuilder().create(Iterables.translate(geometries, geometry -> new LocationIterableProperties(geometry, new HashMap<>()))); }
public void saveAsGeoJson(final WritableResource resource) { final JsonWriter writer = new JsonWriter(resource); final GeoJsonObject geoJson = new GeoJsonBuilder().create(Iterables .translate(this.root.leafNodes(Rectangle.MAXIMUM), Node::toGeoJsonBuildingBlock)); writer.write(geoJson.jsonObject()); writer.close(); }
@Test public void testLocation() { final GeoJsonObject object = new GeoJsonBuilder().create(Location.TEST_5); Assert.assertEquals( "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-122.031007,37.390535]}}", object.toString()); object.withNewProperty("property", "value"); Assert.assertEquals( "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-122.031007,37.390535]},\"properties\":{\"property\":\"value\"}}", object.toString()); object.withNewProperty("property2", "value2"); Assert.assertEquals( "{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[-122.031007,37.390535]},\"properties\":{\"property\":\"value\",\"property2\":\"value2\"}}", object.toString()); }
public GeoJsonObject asGeoJson() { return new GeoJsonBuilder().create(this); }
/** * Converts deprecated LocationIterableProperties to GeometryWithProperties. * * @param locationIterableProperties * LocationIterableProperties object * @return GeometryWithProperties object */ protected static final GeometryWithProperties toGeometryWithProperties( final LocationIterableProperties locationIterableProperties) { final Map<String, Object> propertiesObjects = new HashMap<>(); propertiesObjects.putAll(locationIterableProperties.getProperties()); return new GeometryWithProperties(locationIterableProperties.getLocations(), propertiesObjects); }
/** * Creates a Json Feature from a {@link LocationIterableProperties} * * @deprecated use {@link #create(GeometryWithProperties)} instead * @param object * {@link LocationIterableProperties} * @return a GeoJson Feature */ @Deprecated public JsonObject create(final LocationIterableProperties object) { final GeometryWithProperties geometryWithProperties = toGeometryWithProperties(object); return create(geometryWithProperties); }
public static void main(final String[] args) { new ConcatenateGeoJsonCommand().run(args); }
/** * Creates a GeoJson FeatureCollection containing a list of Features * * @param objects * used to build each Feature * @return a GeoJson FeatureCollection * @deprecated use {@link #createFromGeometriesWithProperties(Iterable)} instead */ @Deprecated public GeoJsonObject create(final Iterable<LocationIterableProperties> objects) { return createFromGeometriesWithProperties(toGeometriesWithProperties(objects)); }
/** * Creates a GeometryCollection type Feature containing geometries derived from a collection of * {@link LocationIterableProperties}. <strong>Note:</strong> feature parameters are not present * in the resulting GeometryCollection and must be handled separately to avoid data loss. * * @deprecated use {@link #createGeometryCollectionFeature(Iterable)} instead * @param objects * used to build each geometry * @return a GeoJson Feature */ @Deprecated public GeoJsonObject createGeometryCollection( final Iterable<LocationIterableProperties> objects) { return createGeometryCollectionFeature(toGeometriesWithProperties(objects)); }
/** * 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; }
private static void save(final GeoJsonObject object, final WritableResource destination) { final JsonWriter writer = new JsonWriter(destination); writer.write(object.jsonObject()); writer.close(); }
@Override public void accept(final ChangeSet changeSet) { toGeoJson(changeSet).save(this.resource); }
private Iterable<PropertiesLocated> readGeoJsonItems(final String line) { return readGeoJsonItems(new StringResource(line)); } }
/** * Creates a LineString type GeoJson Feature * * @param polyLine * geometry * @return a GeoJson Feature */ public GeoJsonObject create(final PolyLine polyLine) { return this.create(polyLine, GeoJsonType.LINESTRING); }
/** * Creates a Polygon type GeoJson Feature * * @param polygon * geometry * @return a GeoJson Feature */ public GeoJsonObject create(final Polygon polygon) { return this.create(polygon.closedLoop(), GeoJsonType.POLYGON); }
public GeoJsonObject create(final GeoJsonType type, final Location... locations) { return this.create(Iterables.iterable(locations), type); }