/** * Creates a Point type GeoJson Feature * * @param location * geometry * @return a Feature */ public GeoJsonObject create(final Location location) { return this.create(location, GeoJsonType.POINT); }
/** * 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); }
/** * 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 GeoJsonObject create(final GeoJsonType type, final Location... locations) { return this.create(Iterables.iterable(locations), type); }
public GeoJsonObject asGeoJson() { return new GeoJsonBuilder().create(this); }
/** * @deprecated use {@link MultiPolygon#asGeoJsonFeatureCollection()} instead, for geojson that * represents the same geometry * @return multiple geojson polygon features in a feature collection */ @Deprecated public GeoJsonObject asGeoJson() { return new GeoJsonBuilder().create(asLocationIterableProperties()); }
public static GeoJsonObject asGeoJson(final Iterable<? extends Iterable<Location>> geometries) { return new GeoJsonBuilder().create(Iterables.translate(geometries, geometry -> new LocationIterableProperties(geometry, new HashMap<>()))); }
public GeoJsonObject asGeoJson() { return new GeoJsonBuilder().create(Iterables.from(asGeoJsonBigNode())); }
@Override public GeoJsonObject convert(final Atlas atlas) { return new GeoJsonBuilder(this.logFrequency).create(Iterables .translateMulti(new BigNodeFinder().find(atlas), BigNode::asGeoJsonRestrictedPath)); } }
@Override public GeoJsonObject asGeoJson(final Predicate<AtlasEntity> matcher) { return new GeoJsonBuilder().create(Iterables.filterTranslate(entities(), atlasEntity -> atlasEntity.toGeoJsonBuildingBlock(), matcher)); }
@Override public GeoJsonObject convert(final Atlas atlas) { return new GeoJsonBuilder().create( Iterables.translate(new BigNodeFinder().find(atlas), BigNode::asGeoJsonBigNode)); } }
/** * Find the big nodes and save them as geojson in a resource * * @param atlas * The atlas to look at * @param writableResource * Where to save the geojson */ public void findAndSaveBigNodesAsGeoJson(final Atlas atlas, final WritableResource writableResource) { final List<LocationIterableProperties> features = new ArrayList<>(); Iterables.stream(this.find(atlas)).map(BigNode::asGeoJsonBigNode).forEach(features::add); new GeoJsonBuilder().create(features).save(writableResource); }
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); }
@Override public GeoJsonObject convert(final Atlas atlas) { return new GeoJsonBuilder() .create(Iterables.translate(new ComplexTurnRestrictionFinder().find(atlas), turnRestriction -> turnRestriction.getTurnRestriction().asGeoJson())); } }
/** * @param diffs * An {@link Iterable} of {@link Diff} * @param filter * The filter to apply to the diff * @return A GeoJSON String representation of all the {@link Diff} items in the {@link Iterable} * , which match the filter. */ public static String toGeoJson(final Iterable<Diff> diffs, final Predicate<Diff> filter) { return new GeoJsonBuilder().create( Iterables.stream(diffs).filter(diff -> diff.getItemType() != ItemType.RELATION) .filter(filter).flatMap(Diff::processDiff).collect()) .jsonObject().toString(); }
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 testLineString() { final GeoJsonObject object = new GeoJsonBuilder() .create(new PolyLine(Location.TEST_5, Location.TEST_2)); Assert.assertEquals( "{\"type\":\"Feature\",\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-122.031007,37.390535],[-122.028464,37.321628]]}}", object.toString()); final Map<String, String> properties = new HashMap<>(); properties.put("property", "value"); properties.put("property2", "value2"); object.withNewProperties(properties); Assert.assertEquals( "{\"type\":\"Feature\",\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-122.031007,37.390535],[-122.028464,37.321628]]},\"properties\":{\"property2\":\"value2\",\"property\":\"value\"}}", object.toString()); }
@Test public void testConsistency() { final Polygon polygon = new Polygon(Location.TEST_5, Location.TEST_2, Location.TEST_6); final GeoJsonObject object = new GeoJsonBuilder().create(polygon); final Map<String, String> properties = new HashMap<>(); properties.put("property", "value"); properties.put("property2", "value2"); object.withNewProperties(properties); // The GeoJsonReader reads Feature collections only object.makeFeatureCollection(); final GeoJsonReader reader = new GeoJsonReader(new StringResource(object.toString())); final PropertiesLocated item = reader.next(); Assert.assertEquals(polygon, item.getItem()); }
@Override protected int onRun(final CommandMap command) { final File folder = (File) command.get(INPUT_FOLDER); final Atlas atlas = loadAtlas(command); final File bigNodesFile = folder.child("improved.bigNodes.geojson"); final JsonWriter writer = new JsonWriter(bigNodesFile); writer.write(new GeoJsonBuilder().create( Iterables.translate(new BigNodeFinder().find(atlas), BigNode::asGeoJsonBigNode)) .jsonObject()); writer.close(); return 0; } }