This is an automated email from the ASF dual-hosted git repository.

bchapuis pushed a commit to branch basemaps-schema
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git

commit d217b4fdfe6d81009f8c01ceb80aee44599579c8
Author: Bertil Chapuis <[email protected]>
AuthorDate: Wed Dec 18 14:31:22 2024 +0100

    Add the option to truncate the existing osm tables
---
 .../src/main/java/org/apache/baremaps/tasks/ImportOsmPbf.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/tasks/ImportOsmPbf.java 
b/baremaps-core/src/main/java/org/apache/baremaps/tasks/ImportOsmPbf.java
index bc4e966f3..5bda12d6c 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/tasks/ImportOsmPbf.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/tasks/ImportOsmPbf.java
@@ -44,6 +44,7 @@ public class ImportOsmPbf implements Task {
   private Object database;
   private Integer databaseSrid;
   private Boolean replaceExisting;
+  private Boolean truncateTables;
 
   /**
    * Constructs a {@code ImportOsmPbf}.
@@ -82,8 +83,8 @@ public class ImportOsmPbf implements Task {
     var wayRepository = new WayRepository(datasource);
     var relationRepository = new RelationRepository(datasource);
 
+    // Drop the existing tables
     if (TRUE.equals(replaceExisting)) {
-      // Drop the existing tables
       headerRepository.drop();
       nodeRepository.drop();
       wayRepository.drop();
@@ -96,6 +97,14 @@ public class ImportOsmPbf implements Task {
       relationRepository.create();
     }
 
+    // Truncate the existing tables
+    if (TRUE.equals(truncateTables)) {
+      headerRepository.truncate();
+      nodeRepository.truncate();
+      wayRepository.truncate();
+      relationRepository.truncate();
+    }
+
     var coordinateMap = context.getCoordinateMap();
     var referenceMap = context.getReferenceMap();
 

Reply via email to