Search in sources :

Example 11 with Header

use of com.baremaps.osm.domain.Header in project baremaps by baremaps.

the class PostgresHeaderRepository method getValue.

private Header getValue(ResultSet resultSet) throws SQLException {
    long replicationSequenceNumber = resultSet.getLong(1);
    LocalDateTime replicationTimestamp = resultSet.getObject(2, LocalDateTime.class);
    String replicationUrl = resultSet.getString(3);
    String source = resultSet.getString(4);
    String writingProgram = resultSet.getString(5);
    return new Header(replicationSequenceNumber, replicationTimestamp, replicationUrl, source, writingProgram);
}
Also used : LocalDateTime(java.time.LocalDateTime) Header(com.baremaps.osm.domain.Header)

Example 12 with Header

use of com.baremaps.osm.domain.Header in project baremaps by baremaps.

the class HeaderBlockReader method read.

/**
 * Returns the {@code HeaderBlock}.
 *
 * @return the header block
 */
public HeaderBlock read() {
    LocalDateTime timestamp = LocalDateTime.ofEpochSecond(headerBlock.getOsmosisReplicationTimestamp(), 0, ZoneOffset.UTC);
    Long replicationSequenceNumber = headerBlock.getOsmosisReplicationSequenceNumber();
    String replicationBaseUrl = headerBlock.getOsmosisReplicationBaseUrl();
    String source = headerBlock.getSource();
    String writingProgram = headerBlock.getWritingprogram();
    Header header = new Header(replicationSequenceNumber, timestamp, replicationBaseUrl, source, writingProgram);
    HeaderBBox headerBBox = headerBlock.getBbox();
    double minLon = headerBBox.getLeft() * .000000001;
    double maxLon = headerBBox.getRight() * .000000001;
    double minLat = headerBBox.getBottom() * .000000001;
    double maxLat = headerBBox.getTop() * .000000001;
    Bound bound = new Bound(maxLat, maxLon, minLat, minLon);
    return new HeaderBlock(blob, header, bound);
}
Also used : LocalDateTime(java.time.LocalDateTime) HeaderBBox(com.baremaps.osm.binary.Osmformat.HeaderBBox) HeaderBlock(com.baremaps.osm.domain.HeaderBlock) Header(com.baremaps.osm.domain.Header) Bound(com.baremaps.osm.domain.Bound)

Example 13 with Header

use of com.baremaps.osm.domain.Header 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

Header (com.baremaps.osm.domain.Header)13 URI (java.net.URI)5 RepositoryException (com.baremaps.osm.repository.RepositoryException)4 Connection (java.sql.Connection)4 SQLException (java.sql.SQLException)4 PGConnection (org.postgresql.PGConnection)4 ImportService (com.baremaps.osm.repository.ImportService)3 UpdateService (com.baremaps.osm.repository.UpdateService)3 LongDataOpenHashMap (com.baremaps.store.LongDataOpenHashMap)3 OnHeapMemory (com.baremaps.store.memory.OnHeapMemory)3 CoordinateDataType (com.baremaps.store.type.CoordinateDataType)3 LongListDataType (com.baremaps.store.type.LongListDataType)3 PreparedStatement (java.sql.PreparedStatement)3 LocalDateTime (java.time.LocalDateTime)3 List (java.util.List)3 Tag (org.junit.jupiter.api.Tag)3 Test (org.junit.jupiter.api.Test)3 Coordinate (org.locationtech.jts.geom.Coordinate)3 Blob (com.baremaps.blob.Blob)2 OsmChangeParser (com.baremaps.osm.change.OsmChangeParser)2