Search in sources :

Example 1 with PostgresHeaderRepository

use of com.baremaps.osm.postgres.PostgresHeaderRepository 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 PostgresHeaderRepository

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

the class Import method call.

@Override
public Integer call() throws Exception {
    BlobStore blobStore = options.blobStore();
    DataSource datasource = PostgresUtils.datasource(database);
    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);
    Path directory = Files.createTempDirectory(Paths.get("."), "baremaps_");
    Path nodes = Files.createDirectories(directory.resolve("nodes"));
    Path referencesKeys = Files.createDirectories(directory.resolve("references_keys"));
    Path referencesValues = Files.createDirectories(directory.resolve("references_values"));
    LongDataMap<Coordinate> coordinates = new LongAlignedDataDenseMap<>(new LonLatDataType(), new OnDiskMemory(nodes));
    LongDataMap<List<Long>> references = new LongDataSortedMap<>(new AlignedDataList<>(new PairDataType<>(new LongDataType(), new LongDataType()), new OnDiskMemory(referencesKeys)), new DataStore<>(new LongListDataType(), new OnDiskMemory(referencesValues)));
    logger.info("Importing data");
    new ImportService(file, 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) LongListDataType(com.baremaps.store.type.LongListDataType) Node(com.baremaps.osm.domain.Node) Way(com.baremaps.osm.domain.Way) Relation(com.baremaps.osm.domain.Relation) ImportService(com.baremaps.osm.repository.ImportService) LongDataSortedMap(com.baremaps.store.LongDataSortedMap) LongAlignedDataDenseMap(com.baremaps.store.LongAlignedDataDenseMap) AlignedDataList(com.baremaps.store.AlignedDataList) List(java.util.List) BlobStore(com.baremaps.blob.BlobStore) PairDataType(com.baremaps.store.type.PairDataType) Path(java.nio.file.Path) PostgresWayRepository(com.baremaps.osm.postgres.PostgresWayRepository) OnDiskMemory(com.baremaps.store.memory.OnDiskMemory) LonLatDataType(com.baremaps.store.type.LonLatDataType) DataSource(javax.sql.DataSource) Coordinate(org.locationtech.jts.geom.Coordinate) PostgresNodeRepository(com.baremaps.osm.postgres.PostgresNodeRepository) PostgresRelationRepository(com.baremaps.osm.postgres.PostgresRelationRepository) LongDataType(com.baremaps.store.type.LongDataType) PostgresHeaderRepository(com.baremaps.osm.postgres.PostgresHeaderRepository)

Example 3 with PostgresHeaderRepository

use of com.baremaps.osm.postgres.PostgresHeaderRepository 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)3 Node (com.baremaps.osm.domain.Node)3 Relation (com.baremaps.osm.domain.Relation)3 Way (com.baremaps.osm.domain.Way)3 PostgresHeaderRepository (com.baremaps.osm.postgres.PostgresHeaderRepository)3 PostgresNodeRepository (com.baremaps.osm.postgres.PostgresNodeRepository)3 PostgresRelationRepository (com.baremaps.osm.postgres.PostgresRelationRepository)3 PostgresWayRepository (com.baremaps.osm.postgres.PostgresWayRepository)3 HeaderRepository (com.baremaps.osm.repository.HeaderRepository)3 List (java.util.List)3 DataSource (javax.sql.DataSource)3 Coordinate (org.locationtech.jts.geom.Coordinate)3 PostgresCoordinateMap (com.baremaps.osm.postgres.PostgresCoordinateMap)2 PostgresReferenceMap (com.baremaps.osm.postgres.PostgresReferenceMap)2 Path (java.nio.file.Path)2 DiffService (com.baremaps.osm.repository.DiffService)1 ImportService (com.baremaps.osm.repository.ImportService)1 UpdateService (com.baremaps.osm.repository.UpdateService)1 AlignedDataList (com.baremaps.store.AlignedDataList)1 LongAlignedDataDenseMap (com.baremaps.store.LongAlignedDataDenseMap)1