Search in sources :

Example 1 with PostgresReferenceMap

use of com.baremaps.osm.postgres.PostgresReferenceMap in project baremaps by baremaps.

the class Diff method call.

@Override
public Integer call() throws Exception {
    BlobStore blobStore = options.blobStore();
    DataSource datasource = PostgresUtils.datasource(database);
    LongDataMap<Coordinate> coordinates = new PostgresCoordinateMap(datasource);
    LongDataMap<List<Long>> references = new PostgresReferenceMap(datasource);
    HeaderRepository headerRepository = new PostgresHeaderRepository(datasource);
    Repository<Long, Node> nodeRepository = new PostgresNodeRepository(datasource);
    Repository<Long, Way> wayRepository = new PostgresWayRepository(datasource);
    Repository<Long, Relation> relationRepository = new PostgresRelationRepository(datasource);
    logger.info("Saving diff");
    Path tmpTiles = Files.createFile(Paths.get("diff.tmp"));
    try (PrintWriter printWriter = new PrintWriter(Files.newBufferedWriter(tmpTiles))) {
        new DiffService(blobStore, coordinates, references, headerRepository, nodeRepository, wayRepository, relationRepository, srid, zoom).call();
    }
    blobStore.put(this.tiles, Blob.builder().withContentLength(Files.size(tmpTiles)).withInputStream(Files.newInputStream(tmpTiles)).build());
    Files.deleteIfExists(tmpTiles);
    logger.info("Done");
    return 0;
}
Also used : Path(java.nio.file.Path) PostgresHeaderRepository(com.baremaps.osm.postgres.PostgresHeaderRepository) HeaderRepository(com.baremaps.osm.repository.HeaderRepository) PostgresWayRepository(com.baremaps.osm.postgres.PostgresWayRepository) PostgresReferenceMap(com.baremaps.osm.postgres.PostgresReferenceMap) Node(com.baremaps.osm.domain.Node) DiffService(com.baremaps.osm.repository.DiffService) PostgresCoordinateMap(com.baremaps.osm.postgres.PostgresCoordinateMap) Way(com.baremaps.osm.domain.Way) DataSource(javax.sql.DataSource) Relation(com.baremaps.osm.domain.Relation) Coordinate(org.locationtech.jts.geom.Coordinate) PostgresNodeRepository(com.baremaps.osm.postgres.PostgresNodeRepository) List(java.util.List) PostgresRelationRepository(com.baremaps.osm.postgres.PostgresRelationRepository) BlobStore(com.baremaps.blob.BlobStore) PostgresHeaderRepository(com.baremaps.osm.postgres.PostgresHeaderRepository) PrintWriter(java.io.PrintWriter)

Example 2 with PostgresReferenceMap

use of com.baremaps.osm.postgres.PostgresReferenceMap in project baremaps by baremaps.

the class Update method call.

@Override
public Integer call() throws Exception {
    BlobStore blobStore = options.blobStore();
    DataSource datasource = PostgresUtils.datasource(database);
    LongDataMap<Coordinate> coordinates = new PostgresCoordinateMap(datasource);
    LongDataMap<List<Long>> references = new PostgresReferenceMap(datasource);
    HeaderRepository headerRepository = new PostgresHeaderRepository(datasource);
    Repository<Long, Node> nodeRepository = new PostgresNodeRepository(datasource);
    Repository<Long, Way> wayRepository = new PostgresWayRepository(datasource);
    Repository<Long, Relation> relationRepository = new PostgresRelationRepository(datasource);
    logger.info("Importing changes");
    new UpdateService(blobStore, coordinates, references, headerRepository, nodeRepository, wayRepository, relationRepository, srid).call();
    logger.info("Done");
    return 0;
}
Also used : PostgresHeaderRepository(com.baremaps.osm.postgres.PostgresHeaderRepository) HeaderRepository(com.baremaps.osm.repository.HeaderRepository) PostgresWayRepository(com.baremaps.osm.postgres.PostgresWayRepository) PostgresReferenceMap(com.baremaps.osm.postgres.PostgresReferenceMap) Node(com.baremaps.osm.domain.Node) PostgresCoordinateMap(com.baremaps.osm.postgres.PostgresCoordinateMap) Way(com.baremaps.osm.domain.Way) DataSource(javax.sql.DataSource) Relation(com.baremaps.osm.domain.Relation) UpdateService(com.baremaps.osm.repository.UpdateService) Coordinate(org.locationtech.jts.geom.Coordinate) PostgresNodeRepository(com.baremaps.osm.postgres.PostgresNodeRepository) List(java.util.List) PostgresRelationRepository(com.baremaps.osm.postgres.PostgresRelationRepository) BlobStore(com.baremaps.blob.BlobStore) PostgresHeaderRepository(com.baremaps.osm.postgres.PostgresHeaderRepository)

Aggregations

BlobStore (com.baremaps.blob.BlobStore)2 Node (com.baremaps.osm.domain.Node)2 Relation (com.baremaps.osm.domain.Relation)2 Way (com.baremaps.osm.domain.Way)2 PostgresCoordinateMap (com.baremaps.osm.postgres.PostgresCoordinateMap)2 PostgresHeaderRepository (com.baremaps.osm.postgres.PostgresHeaderRepository)2 PostgresNodeRepository (com.baremaps.osm.postgres.PostgresNodeRepository)2 PostgresReferenceMap (com.baremaps.osm.postgres.PostgresReferenceMap)2 PostgresRelationRepository (com.baremaps.osm.postgres.PostgresRelationRepository)2 PostgresWayRepository (com.baremaps.osm.postgres.PostgresWayRepository)2 HeaderRepository (com.baremaps.osm.repository.HeaderRepository)2 List (java.util.List)2 DataSource (javax.sql.DataSource)2 Coordinate (org.locationtech.jts.geom.Coordinate)2 DiffService (com.baremaps.osm.repository.DiffService)1 UpdateService (com.baremaps.osm.repository.UpdateService)1 PrintWriter (java.io.PrintWriter)1 Path (java.nio.file.Path)1