Skip to content

Commit

Permalink
Make the replacement of tables optional
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis committed Oct 27, 2023
1 parent 5978cd6 commit bbe4252
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public Integer call() throws Exception {
new org.apache.baremaps.workflow.tasks.ImportOsmPbf(
file.toAbsolutePath(),
database,
srid).execute(new WorkflowContext());
srid,
true).execute(new WorkflowContext());
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public record ImportOsmPbf(Path file, Object database, Integer databaseSrid)
public record ImportOsmPbf(Path file, Object database, Integer databaseSrid, Boolean replaceTables)
implements
Task {

Expand All @@ -62,16 +62,16 @@ public void execute(WorkflowContext context) throws Exception {
var wayRepository = new PostgresWayRepository(dataSource);
var relationRepository = new PostgresRelationRepository(dataSource);

headerRepository.drop();
nodeRepository.drop();
wayRepository.drop();
relationRepository.drop();

headerRepository.create();
nodeRepository.create();
wayRepository.create();
relationRepository.create();

if (replaceTables) {
headerRepository.drop();
nodeRepository.drop();
wayRepository.drop();
relationRepository.drop();
headerRepository.create();
nodeRepository.create();
wayRepository.create();
relationRepository.create();
}
var cacheDir = Files.createTempDirectory(Paths.get("."), "cache_");

DataMap<Long, Coordinate> coordinateMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void test() throws IOException {
new Step("import", List.of("download"),
List.of(new ImportOsmPbf(Paths.get("liechtenstein-latest.osm.pbf"),
"jdbc:postgresql://localhost:5432/baremaps?&user=baremaps&password=baremaps",
3857)))));
3857, true)))));
var json = mapper.writeValueAsString(workflow1);
assertTrue(json.contains(DownloadUrl.class.getSimpleName()));
assertTrue(json.contains(ImportOsmPbf.class.getSimpleName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void execute() {
Paths.get("downloads/liechtenstein.osm.pbf")))),
new Step("import-osmpbf", List.of("fetch-osmpbf"),
List.of(new ImportOsmPbf(Paths.get("downloads/liechtenstein.osm.pbf"), jdbcUrl(),
3857))),
3857, true))),
new Step("fetch-shapefile", List.of(), List.of(new DownloadUrl(
"https://osmdata.openstreetmap.de/download/simplified-water-polygons-split-3857.zip",
Paths.get("downloads/simplified-water-polygons-split-3857.zip")))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void execute() throws Exception {
var file = TestFiles.resolve("data.osm.pbf");
var jdbcUrl = jdbcUrl();
var srid = 3857;
var task = new ImportOsmPbf(file, jdbcUrl, srid);
var task = new ImportOsmPbf(file, jdbcUrl, srid, true);
task.execute(new WorkflowContext());
}
}
3 changes: 2 additions & 1 deletion basemap/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export default {
"type": "ImportOsmPbf",
"file": "data/data.osm.pbf",
"database": config.database,
"databaseSrid": 3857
"databaseSrid": 3857,
"replaceTables": true,
},
]
},
Expand Down
6 changes: 4 additions & 2 deletions daylight/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export default {
"type": "ImportOsmPbf",
"file": "data/data.osm.pbf",
"database": config.database,
"databaseSrid": 3857
"databaseSrid": 3857,
"replaceTables": true,
},
]
},
Expand All @@ -44,7 +45,8 @@ export default {
"type": "ImportOsmPbf",
"file": "data/buildings.osm.pbf",
"database": config.database,
"databaseSrid": 3857
"databaseSrid": 3857,
"replaceTables": false,
},
]
},
Expand Down

0 comments on commit bbe4252

Please sign in to comment.