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 2022/12/11 17:08:33 UTC

[incubator-baremaps] branch main updated: Enable inspect control in server mode (#554)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new b640b91b Enable inspect control in server mode (#554)
b640b91b is described below

commit b640b91bf35a5a73c8578ccfd291988bdc3a48d8
Author: Bertil Chapuis <bc...@gmail.com>
AuthorDate: Sun Dec 11 18:08:30 2022 +0100

    Enable inspect control in server mode (#554)
---
 .../org/apache/baremaps/server/DevResources.java   |   4 +--
 .../apache/baremaps/server/ServerResources.java    |   4 +--
 .../main/resources/{server => assets}/favicon.ico  | Bin
 .../{viewer => assets}/maplibre-gl-inspect.css     |   0
 .../{viewer => assets}/maplibre-gl-inspect.js      |   0
 .../maplibre-gl-tile-boundaries.css                |   0
 .../maplibre-gl-tile-boundaries.js                 |   0
 .../{viewer/index.html => assets/server.html}      |   7 +++--
 .../{viewer/index.html => assets/viewer.html}      |  16 +++-------
 .../src/main/resources/server/index.html           |  33 ---------------------
 .../src/main/resources/viewer/favicon.ico          | Bin 15086 -> 0 bytes
 .../openstreetmap/liechtenstein-latest.osm.pbf     | Bin 2710779 -> 0 bytes
 12 files changed, 13 insertions(+), 51 deletions(-)

diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/DevResources.java b/baremaps-server/src/main/java/org/apache/baremaps/server/DevResources.java
index 3e8ad149..b749a9f7 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/DevResources.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/DevResources.java
@@ -151,9 +151,9 @@ public class DevResources {
   @javax.ws.rs.Path("{path:.*}")
   public Response get(@PathParam("path") String path) throws IOException {
     if (path.equals("") || path.endsWith("/")) {
-      path += "index.html";
+      path += "viewer.html";
     }
-    path = String.format("viewer/%s", path);
+    path = String.format("assets/%s", path);
     try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(path)) {
       var bytes = inputStream.readAllBytes();
       return Response.ok().entity(bytes).build();
diff --git a/baremaps-server/src/main/java/org/apache/baremaps/server/ServerResources.java b/baremaps-server/src/main/java/org/apache/baremaps/server/ServerResources.java
index 593e7c50..08990b7c 100644
--- a/baremaps-server/src/main/java/org/apache/baremaps/server/ServerResources.java
+++ b/baremaps-server/src/main/java/org/apache/baremaps/server/ServerResources.java
@@ -100,9 +100,9 @@ public class ServerResources {
   @javax.ws.rs.Path("{path:.*}")
   public Response get(@PathParam("path") String path) throws IOException {
     if (path.equals("") || path.endsWith("/")) {
-      path += "index.html";
+      path += "server.html";
     }
-    path = String.format("server/%s", path);
+    path = String.format("assets/%s", path);
     try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(path)) {
       var bytes = inputStream.readAllBytes();
       return Response.ok().entity(bytes).build();
diff --git a/baremaps-server/src/main/resources/server/favicon.ico b/baremaps-server/src/main/resources/assets/favicon.ico
similarity index 100%
rename from baremaps-server/src/main/resources/server/favicon.ico
rename to baremaps-server/src/main/resources/assets/favicon.ico
diff --git a/baremaps-server/src/main/resources/viewer/maplibre-gl-inspect.css b/baremaps-server/src/main/resources/assets/maplibre-gl-inspect.css
similarity index 100%
rename from baremaps-server/src/main/resources/viewer/maplibre-gl-inspect.css
rename to baremaps-server/src/main/resources/assets/maplibre-gl-inspect.css
diff --git a/baremaps-server/src/main/resources/viewer/maplibre-gl-inspect.js b/baremaps-server/src/main/resources/assets/maplibre-gl-inspect.js
similarity index 100%
rename from baremaps-server/src/main/resources/viewer/maplibre-gl-inspect.js
rename to baremaps-server/src/main/resources/assets/maplibre-gl-inspect.js
diff --git a/baremaps-server/src/main/resources/viewer/maplibre-gl-tile-boundaries.css b/baremaps-server/src/main/resources/assets/maplibre-gl-tile-boundaries.css
similarity index 100%
rename from baremaps-server/src/main/resources/viewer/maplibre-gl-tile-boundaries.css
rename to baremaps-server/src/main/resources/assets/maplibre-gl-tile-boundaries.css
diff --git a/baremaps-server/src/main/resources/viewer/maplibre-gl-tile-boundaries.js b/baremaps-server/src/main/resources/assets/maplibre-gl-tile-boundaries.js
similarity index 100%
rename from baremaps-server/src/main/resources/viewer/maplibre-gl-tile-boundaries.js
rename to baremaps-server/src/main/resources/assets/maplibre-gl-tile-boundaries.js
diff --git a/baremaps-server/src/main/resources/viewer/index.html b/baremaps-server/src/main/resources/assets/server.html
similarity index 86%
copy from baremaps-server/src/main/resources/viewer/index.html
copy to baremaps-server/src/main/resources/assets/server.html
index 4ce59aae..7dc16852 100644
--- a/baremaps-server/src/main/resources/viewer/index.html
+++ b/baremaps-server/src/main/resources/assets/server.html
@@ -24,15 +24,17 @@
 <div id="map"></div>
 <script>
 
-  // Initialize the map
+  // Initialize the map.
   let map = new maplibregl.Map({
     container: 'map',
     style: '/style.json',
     hash: true
   });
 
+  // Add the navigation control to the map.
   map.addControl(new maplibregl.NavigationControl());
 
+  // Add the inspect control to the map.
   map.addControl(new MaplibreInspect({
     showMapPopup: true,
     showMapPopupOnHover: false,
@@ -43,11 +45,12 @@
     })
   }));
 
+  // Add the tile boundaries control to the map.
   map.addControl(new MaplibreTileBoundaries({
     showBoundaries: false
   }));
 
-  // Listen to map changes
+  // Listen to configuration changes and update the map.
   const connection = new EventSource('/changes')
   connection.onmessage = e => {
     let style = JSON.parse(e.data);
diff --git a/baremaps-server/src/main/resources/viewer/index.html b/baremaps-server/src/main/resources/assets/viewer.html
similarity index 79%
rename from baremaps-server/src/main/resources/viewer/index.html
rename to baremaps-server/src/main/resources/assets/viewer.html
index 4ce59aae..8b1011dc 100644
--- a/baremaps-server/src/main/resources/viewer/index.html
+++ b/baremaps-server/src/main/resources/assets/viewer.html
@@ -24,15 +24,17 @@
 <div id="map"></div>
 <script>
 
-  // Initialize the map
+  // Initialize the map.
   let map = new maplibregl.Map({
     container: 'map',
     style: '/style.json',
     hash: true
   });
 
+  // Add the navigation control to the map.
   map.addControl(new maplibregl.NavigationControl());
 
+  // Add the inspect control to the map.
   map.addControl(new MaplibreInspect({
     showMapPopup: true,
     showMapPopupOnHover: false,
@@ -43,21 +45,11 @@
     })
   }));
 
+  // Add the tile boundaries control to the map.
   map.addControl(new MaplibreTileBoundaries({
     showBoundaries: false
   }));
 
-  // Listen to map changes
-  const connection = new EventSource('/changes')
-  connection.onmessage = e => {
-    let style = JSON.parse(e.data);
-    if (style.reload) {
-      location.reload();
-    }
-    delete style.reload;
-    map.setStyle(style);
-  }
-
 </script>
 </body>
 </html>
diff --git a/baremaps-server/src/main/resources/server/index.html b/baremaps-server/src/main/resources/server/index.html
deleted file mode 100644
index a518a509..00000000
--- a/baremaps-server/src/main/resources/server/index.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<html>
-<head>
-  <script src='https://unpkg.com/maplibre-gl@2.1.9/dist/maplibre-gl.js'></script>
-  <link href='https://unpkg.com/maplibre-gl@2.1.9/dist/maplibre-gl.css' rel='stylesheet' />
-  <style>
-
-    body {
-      margin: 0;
-    }
-
-    #map {
-      width: 100%;
-      height: 100%;
-    }
-
-  </style>
-  <title>Baremaps</title>
-</head>
-<body>
-<div id="map"></div>
-<script>
-
-  // Initialize the map
-  let map = new maplibregl.Map({
-    container: 'map',
-    style: '/style.json',
-    hash: true
-  });
-  map.addControl(new maplibregl.NavigationControl());
-
-</script>
-</body>
-</html>
diff --git a/baremaps-server/src/main/resources/viewer/favicon.ico b/baremaps-server/src/main/resources/viewer/favicon.ico
deleted file mode 100644
index 7162b07e..00000000
Binary files a/baremaps-server/src/main/resources/viewer/favicon.ico and /dev/null differ
diff --git a/examples/openstreetmap/liechtenstein-latest.osm.pbf b/examples/openstreetmap/liechtenstein-latest.osm.pbf
deleted file mode 100644
index 591fd91d..00000000
Binary files a/examples/openstreetmap/liechtenstein-latest.osm.pbf and /dev/null differ