use of com.baremaps.store.LongDataMap in project baremaps by baremaps.
the class RelationGeometryTest method handleRelation.
Geometry handleRelation(String file) throws IOException {
InputStream input = new GZIPInputStream(this.getClass().getResourceAsStream(file));
List<Entity> entities = new OsmXmlParser().entities(input).collect(Collectors.toList());
LongDataMap<Coordinate> coordinates = new MockLongDataMap<>(entities.stream().filter(e -> e instanceof Node).map(e -> (Node) e).collect(Collectors.toMap(n -> n.getId(), n -> new Coordinate(n.getLon(), n.getLat()))));
LongDataMap<List<Long>> references = new MockLongDataMap<>(entities.stream().filter(e -> e instanceof Way).map(e -> (Way) e).collect(Collectors.toMap(w -> w.getId(), w -> w.getNodes())));
Relation relation = entities.stream().filter(e -> e instanceof Relation).map(e -> (Relation) e).findFirst().get();
new CreateGeometryConsumer(coordinates, references).match(relation);
return relation.getGeometry();
}
Aggregations