use of com.baremaps.osm.store.DataStoreConsumer 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;
}
Aggregations