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

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

commit d0c4d50ed39a2be49be896ea6c78b356e39b9c41
Author: Bertil Chapuis <[email protected]>
AuthorDate: Sat Sep 23 20:45:20 2023 +0200

    Format code
---
 .../main/java/org/apache/baremaps/cli/map/Dev.java | 51 ++++++++--------
 .../org/apache/baremaps/utils/Compression.java     | 67 +++++++++++++---------
 .../baremaps/workflow/tasks/DecompressFile.java    |  1 -
 .../baremaps/workflow/tasks/ImportOsmChange.java   |  8 ++-
 4 files changed, 68 insertions(+), 59 deletions(-)

diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java 
b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
index a3a06e2a..3bfbc47e 100644
--- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
+++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Dev.java
@@ -71,21 +71,19 @@ public class Dev implements Callable<Integer> {
     var tileset = objectMapper.readValue(configReader.read(this.tilesetPath), 
Tileset.class);
     var datasource = 
PostgresUtils.createDataSourceFromObject(tileset.getDatabase());
 
-    var tileStoreType = new TypeLiteral<Supplier<TileStore>>() {
-    };
+    var tileStoreType = new TypeLiteral<Supplier<TileStore>>() {};
     var tileStoreSupplier = (Supplier<TileStore>) () -> {
       try {
         var config = configReader.read(this.tilesetPath);
         var tilesetObject =
-                objectMapper.readValue(config, Tileset.class);
+            objectMapper.readValue(config, Tileset.class);
         return new PostgresTileStore(datasource, tilesetObject);
       } catch (IOException e) {
         throw new RuntimeException(e);
       }
     };
 
-    var styleSupplierType = new TypeLiteral<Supplier<Style>>() {
-    };
+    var styleSupplierType = new TypeLiteral<Supplier<Style>>() {};
     var styleSupplier = (Supplier<Style>) () -> {
       try {
         var config = configReader.read(stylePath);
@@ -95,8 +93,7 @@ public class Dev implements Callable<Integer> {
       }
     };
 
-    var tileJSONSupplierType = new TypeLiteral<Supplier<Tileset>>() {
-    };
+    var tileJSONSupplierType = new TypeLiteral<Supplier<Tileset>>() {};
     var tileJSONSupplier = (Supplier<Tileset>) () -> {
       try {
         var config = configReader.read(tilesetPath);
@@ -107,26 +104,26 @@ public class Dev implements Callable<Integer> {
     };
 
     var application = new ResourceConfig()
-            .register(CorsFilter.class)
-            .register(ChangeResource.class)
-            .register(TileResource.class)
-            .register(StyleResource.class)
-            .register(TilesetResource.class)
-            .register(ChangeResource.class)
-            .register(ClassPathResource.class)
-            .register(newContextResolver(objectMapper))
-            .register(new AbstractBinder() {
-              @Override
-              protected void configure() {
-                bind("assets").to(String.class).named("directory");
-                bind("viewer.html").to(String.class).named("index");
-                bind(tilesetPath).to(Path.class).named("tileset");
-                bind(stylePath).to(Path.class).named("style");
-                bind(tileStoreSupplier).to(tileStoreType);
-                bind(styleSupplier).to(styleSupplierType);
-                bind(tileJSONSupplier).to(tileJSONSupplierType);
-              }
-            });
+        .register(CorsFilter.class)
+        .register(ChangeResource.class)
+        .register(TileResource.class)
+        .register(StyleResource.class)
+        .register(TilesetResource.class)
+        .register(ChangeResource.class)
+        .register(ClassPathResource.class)
+        .register(newContextResolver(objectMapper))
+        .register(new AbstractBinder() {
+          @Override
+          protected void configure() {
+            bind("assets").to(String.class).named("directory");
+            bind("viewer.html").to(String.class).named("index");
+            bind(tilesetPath).to(Path.class).named("tileset");
+            bind(stylePath).to(Path.class).named("style");
+            bind(tileStoreSupplier).to(tileStoreType);
+            bind(styleSupplier).to(styleSupplierType);
+            bind(tileJSONSupplier).to(tileJSONSupplierType);
+          }
+        });
 
     var httpService = new 
HttpJerseyRouterBuilder().buildBlockingStreaming(application);
     var serverContext = 
HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/utils/Compression.java 
b/baremaps-core/src/main/java/org/apache/baremaps/utils/Compression.java
index 4e204aaa..7b4d3a18 100644
--- a/baremaps-core/src/main/java/org/apache/baremaps/utils/Compression.java
+++ b/baremaps-core/src/main/java/org/apache/baremaps/utils/Compression.java
@@ -1,7 +1,16 @@
-package org.apache.baremaps.utils;
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not 
use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
 
-import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
-import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
+package org.apache.baremaps.utils;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -9,35 +18,37 @@ import java.io.OutputStream;
 import java.nio.file.Path;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.GZIPOutputStream;
+import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
+import 
org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
 
 public enum Compression {
-    none,
-    gzip,
-    bzip2;
+  none,
+  gzip,
+  bzip2;
 
-    public static Compression detect(Path file) {
-        if (file.toString().endsWith(".gz")) {
-            return gzip;
-        } else if (file.toString().endsWith(".bz2")) {
-            return bzip2;
-        } else {
-            return none;
-        }
+  public static Compression detect(Path file) {
+    if (file.toString().endsWith(".gz")) {
+      return gzip;
+    } else if (file.toString().endsWith(".bz2")) {
+      return bzip2;
+    } else {
+      return none;
     }
+  }
 
-    public InputStream decompress(InputStream inputStream) throws IOException {
-        return switch (this) {
-            case gzip -> new GZIPInputStream(inputStream);
-            case bzip2 -> new BZip2CompressorInputStream(inputStream);
-            default -> inputStream;
-        };
-    }
+  public InputStream decompress(InputStream inputStream) throws IOException {
+    return switch (this) {
+      case gzip -> new GZIPInputStream(inputStream);
+      case bzip2 -> new BZip2CompressorInputStream(inputStream);
+      default -> inputStream;
+    };
+  }
 
-    public OutputStream compress(OutputStream outputStream) throws IOException 
{
-        return switch (this) {
-            case gzip -> new GZIPOutputStream(outputStream);
-            case bzip2 -> new BZip2CompressorOutputStream(outputStream);
-            default -> outputStream;
-        };
-    }
+  public OutputStream compress(OutputStream outputStream) throws IOException {
+    return switch (this) {
+      case gzip -> new GZIPOutputStream(outputStream);
+      case bzip2 -> new BZip2CompressorOutputStream(outputStream);
+      default -> outputStream;
+    };
+  }
 }
diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java
 
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java
index 7b1ed2de..80f98d5e 100644
--- 
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java
+++ 
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/DecompressFile.java
@@ -19,7 +19,6 @@ import java.nio.file.StandardCopyOption;
 import java.nio.file.StandardOpenOption;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.ZipFile;
-
 import org.apache.baremaps.workflow.Task;
 import org.apache.baremaps.workflow.WorkflowContext;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
diff --git 
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmChange.java
 
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmChange.java
index 4066f75f..b6112682 100644
--- 
a/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmChange.java
+++ 
b/baremaps-core/src/main/java/org/apache/baremaps/workflow/tasks/ImportOsmChange.java
@@ -29,12 +29,13 @@ import org.apache.baremaps.workflow.WorkflowContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public record ImportOsmChange(Path file, String database, Integer srid, 
Compression compression) implements Task {
+public record ImportOsmChange(Path file, String database, Integer srid,
+    Compression compression) implements Task {
 
   private static final Logger logger = 
LoggerFactory.getLogger(ImportOsmChange.class);
 
   public ImportOsmChange(Path file, String database, Integer srid) {
-    this (file, database, srid, Compression.detect(file));
+    this(file, database, srid, Compression.detect(file));
   }
 
   @Override
@@ -54,7 +55,8 @@ public record ImportOsmChange(Path file, String database, 
Integer srid, Compress
     var prepareChange = consumeThenReturn(prepareGeometries);
     var importChange = new ChangeImporter(nodeRepository, wayRepository, 
relationRepository);
 
-    try (var changeInputStream = new 
BufferedInputStream(compression.decompress(Files.newInputStream(file)))) {
+    try (var changeInputStream =
+        new 
BufferedInputStream(compression.decompress(Files.newInputStream(file)))) {
       new 
XmlChangeReader().stream(changeInputStream).map(prepareChange).forEach(importChange);
     }
   }

Reply via email to