use of com.baremaps.osm.xml.OsmXmlParser in project baremaps by baremaps.
the class OpenStreetMapTest method monacoOsmBz2.
@Test
void monacoOsmBz2() throws IOException, URISyntaxException {
try (InputStream inputStream = new BZip2CompressorInputStream(MONACO_OSM_BZ2.openStream())) {
Stream<Entity> stream = new OsmXmlParser().entities(inputStream);
process(stream, 1, 1, 24951, 4015, 243);
}
}
use of com.baremaps.osm.xml.OsmXmlParser 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