Search in sources :

Example 1 with ProjectionTransformer

use of com.baremaps.osm.geometry.ProjectionTransformer in project baremaps by baremaps.

the class DiffService method call.

@Override
public List<Tile> call() throws Exception {
    logger.info("Importing changes");
    Header header = headerRepository.selectLatest();
    String replicationUrl = header.getReplicationUrl();
    Long sequenceNumber = header.getReplicationSequenceNumber() + 1;
    URI changeUri = resolve(replicationUrl, sequenceNumber, "osc.gz");
    Blob blob = blobStore.get(changeUri);
    ProgressLogger progressLogger = new ProgressLogger(blob.getContentLength(), 5000);
    ProjectionTransformer projectionTransformer = new ProjectionTransformer(srid, 4326);
    try (InputStream changesInputStream = new GZIPInputStream(new InputStreamProgress(blob.getInputStream(), progressLogger))) {
        return new OsmChangeParser().changes(changesInputStream).flatMap(this::geometriesForChange).map(projectionTransformer::transform).flatMap(this::tilesForGeometry).distinct().collect(Collectors.toList());
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) Blob(com.baremaps.blob.Blob) Header(com.baremaps.osm.domain.Header) GZIPInputStream(java.util.zip.GZIPInputStream) InputStream(java.io.InputStream) InputStreamProgress(com.baremaps.osm.progress.InputStreamProgress) ProgressLogger(com.baremaps.osm.progress.ProgressLogger) OsmChangeParser(com.baremaps.osm.change.OsmChangeParser) URI(java.net.URI) ProjectionTransformer(com.baremaps.osm.geometry.ProjectionTransformer)

Aggregations

Blob (com.baremaps.blob.Blob)1 OsmChangeParser (com.baremaps.osm.change.OsmChangeParser)1 Header (com.baremaps.osm.domain.Header)1 ProjectionTransformer (com.baremaps.osm.geometry.ProjectionTransformer)1 InputStreamProgress (com.baremaps.osm.progress.InputStreamProgress)1 ProgressLogger (com.baremaps.osm.progress.ProgressLogger)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 GZIPInputStream (java.util.zip.GZIPInputStream)1