You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@baremaps.apache.org by bc...@apache.org on 2023/09/04 20:08:23 UTC
[incubator-baremaps] 01/01: Expose the tileset and the SQL queries in dev mode
This is an automated email from the ASF dual-hosted git repository.
bchapuis pushed a commit to branch 766-tileset
in repository https://gitbox.apache.org/repos/asf/incubator-baremaps.git
commit bd7abbe801268bb0bdb4b8218e0b54d8395aea50
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Mon Sep 4 22:08:09 2023 +0200
Expose the tileset and the SQL queries in dev mode
---
.../src/main/java/org/apache/baremaps/cli/map/Dev.java | 6 +++---
.../src/main/java/org/apache/baremaps/cli/map/Serve.java | 2 +-
.../server/{TilesetResource.java => TileJSONResource.java} | 11 ++++++-----
.../java/org/apache/baremaps/server/TilesetResource.java | 14 ++++++++------
4 files changed, 18 insertions(+), 15 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 2c54f526..03c438f2 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
@@ -93,11 +93,11 @@ public class Dev implements Callable<Integer> {
}
};
- var tileJSONSupplierType = new TypeLiteral<Supplier<TileJSON>>() {};
- var tileJSONSupplier = (Supplier<TileJSON>) () -> {
+ var tileJSONSupplierType = new TypeLiteral<Supplier<Tileset>>() {};
+ var tileJSONSupplier = (Supplier<Tileset>) () -> {
try {
var config = configReader.read(tilesetPath);
- return objectMapper.readValue(config, TileJSON.class);
+ return objectMapper.readValue(config, Tileset.class);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java
index 62978214..f4a47619 100644
--- a/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java
+++ b/baremaps-cli/src/main/java/org/apache/baremaps/cli/map/Serve.java
@@ -92,7 +92,7 @@ public class Serve implements Callable<Integer> {
.register(CorsFilter.class)
.register(TileResource.class)
.register(StyleResource.class)
- .register(TilesetResource.class)
+ .register(TileJSONResource.class)
.register(ClassPathResource.class)
.register(newContextResolver(objectMapper))
.register(new AbstractBinder() {
diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/TilesetResource.java b/baremaps-server/src/main/java/org/apache/baremaps/server/TileJSONResource.java
similarity index 88%
copy from baremaps-server/src/main/java/org/apache/baremaps/server/TilesetResource.java
copy to baremaps-server/src/main/java/org/apache/baremaps/server/TileJSONResource.java
index 8b968416..52dca2e3 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/TilesetResource.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/TileJSONResource.java
@@ -12,25 +12,26 @@
package org.apache.baremaps.server;
-import java.util.function.Supplier;
+import org.apache.baremaps.vectortile.tilejson.TileJSON;
+
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import org.apache.baremaps.vectortile.tilejson.TileJSON;
+import java.util.function.Supplier;
/**
- * A resource that provides access to the tileset.
+ * A resource that provides access to the tileJSON file.
*/
@Singleton
@javax.ws.rs.Path("/")
-public class TilesetResource {
+public class TileJSONResource {
private final Supplier<TileJSON> tileJSONSupplier;
@Inject
- public TilesetResource(Supplier<TileJSON> tileJSONSupplier) {
+ public TileJSONResource(Supplier<TileJSON> tileJSONSupplier) {
this.tileJSONSupplier = tileJSONSupplier;
}
diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/TilesetResource.java b/baremaps-server/src/main/java/org/apache/baremaps/server/TilesetResource.java
index 8b968416..be162f6c 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/TilesetResource.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/TilesetResource.java
@@ -19,26 +19,28 @@ import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.apache.baremaps.vectortile.tilejson.TileJSON;
+import org.apache.baremaps.vectortile.tileset.Tileset;
/**
- * A resource that provides access to the tileset.
+ * A resource that provides access to the tileset file.
+ * Only suitable for development purposes, as it exposes SQL queries.
*/
@Singleton
@javax.ws.rs.Path("/")
public class TilesetResource {
- private final Supplier<TileJSON> tileJSONSupplier;
+ private final Supplier<Tileset> tilesetSupplier;
@Inject
- public TilesetResource(Supplier<TileJSON> tileJSONSupplier) {
- this.tileJSONSupplier = tileJSONSupplier;
+ public TilesetResource(Supplier<Tileset> tilesetSupplier) {
+ this.tilesetSupplier = tilesetSupplier;
}
@GET
@javax.ws.rs.Path("tiles.json")
@Produces(MediaType.APPLICATION_JSON)
- public TileJSON getTileset() {
- return tileJSONSupplier.get();
+ public Tileset getTileset() {
+ return tilesetSupplier.get();
}
}