use of com.baremaps.osm.pbf.OsmPbfParser in project baremaps by baremaps.
the class OpenStreetMapTest method monacoOsmPbf.
@Test
void monacoOsmPbf() throws IOException, URISyntaxException {
try (InputStream inputStream = MONACO_OSM_PBF.openStream()) {
Stream<Entity> stream = new OsmPbfParser().entities(inputStream);
process(stream, 1, 1, 25002, 4018, 243);
}
}
use of com.baremaps.osm.pbf.OsmPbfParser in project baremaps by baremaps.
the class OpenStreetMapBenchmark method entityStream.
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 2)
@Measurement(iterations = 5)
public void entityStream() throws IOException {
AtomicLong nodes = new AtomicLong(0);
AtomicLong ways = new AtomicLong(0);
AtomicLong relations = new AtomicLong(0);
try (InputStream inputStream = new BufferedInputStream(Files.newInputStream(path))) {
new OsmPbfParser().entities(inputStream).forEach(new EntityConsumerAdapter() {
@Override
public void match(Node node) {
nodes.incrementAndGet();
}
@Override
public void match(Way way) {
ways.incrementAndGet();
}
@Override
public void match(Relation relation) {
relations.incrementAndGet();
}
});
}
}
use of com.baremaps.osm.pbf.OsmPbfParser in project baremaps by baremaps.
the class ImportService method call.
@Override
public Void call() throws Exception {
Consumer<Block> cacheBlock = new DataStoreConsumer(coordinates, references);
Consumer<Entity> createGeometry = new CreateGeometryConsumer(coordinates, references);
Consumer<Entity> reprojectGeometry = new ReprojectEntityConsumer(4326, srid);
Consumer<Block> prepareGeometries = new BlockEntityConsumer(createGeometry.andThen(reprojectGeometry));
Function<Block, Block> prepareBlock = consumeThenReturn(cacheBlock.andThen(prepareGeometries));
Consumer<Block> saveBlock = new SaveBlockConsumer(headerRepository, nodeRepository, wayRepository, relationRepository);
Blob blob = blobStore.get(uri);
ProgressLogger progressLogger = new ProgressLogger(blob.getContentLength(), 5000);
try (InputStream inputStream = new InputStreamProgress(blob.getInputStream(), progressLogger)) {
batch(new OsmPbfParser().blocks(inputStream).map(prepareBlock)).forEach(saveBlock);
}
return null;
}
use of com.baremaps.osm.pbf.OsmPbfParser in project baremaps by baremaps.
the class SaveBlockConsumerTest method test.
@Test
@Tag("integration")
void test() throws BlobStoreException, RepositoryException, URISyntaxException {
// Import data
SaveBlockConsumer dataImporter = new SaveBlockConsumer(headerRepository, nodeRepository, tableRepository, relationRepository);
InputStream inputStream = new ResourceBlobStore().get(new URI("res://simple/data.osm.pbf")).getInputStream();
new OsmPbfParser().blocks(inputStream).forEach(dataImporter);
// Check node importation
assertNull(nodeRepository.get(0l));
assertNotNull(nodeRepository.get(1l));
assertNotNull(nodeRepository.get(2l));
assertNotNull(nodeRepository.get(3l));
assertNull(nodeRepository.get(4l));
// Check way importation
assertNull(tableRepository.get(0l));
assertNotNull(tableRepository.get(1l));
assertNull(tableRepository.get(2l));
// Check relation importation
assertNull(relationRepository.get(0l));
assertNotNull(relationRepository.get(1l));
assertNull(relationRepository.get(2l));
}
use of com.baremaps.osm.pbf.OsmPbfParser in project baremaps by baremaps.
the class OpenStreetMapGeometriesBenchmark method store.
@Benchmark
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 0)
@Measurement(iterations = 1)
public void store() throws IOException {
Path directory = Files.createTempDirectory(Paths.get("."), "benchmark_");
LongDataMap<Coordinate> coordinates = new LongDataOpenHashMap<>(new DataStore<>(new CoordinateDataType(), new OnDiskMemory(directory)));
LongDataMap<List<Long>> references = new LongDataOpenHashMap<>(new DataStore<>(new LongListDataType(), new OnHeapMemory()));
AtomicLong nodes = new AtomicLong(0);
AtomicLong ways = new AtomicLong(0);
AtomicLong relations = new AtomicLong(0);
try (InputStream inputStream = new BufferedInputStream(Files.newInputStream(path))) {
new OsmPbfParser().coordinates(coordinates).references(references).projection(4326).entities(inputStream).forEach(new EntityConsumerAdapter() {
@Override
public void match(Node node) {
nodes.incrementAndGet();
}
@Override
public void match(Way way) {
ways.incrementAndGet();
}
@Override
public void match(Relation relation) {
relations.incrementAndGet();
}
});
}
}
Aggregations