From 52e2191c2b0f58f48bc6137fe2a13682f0d222b8 Mon Sep 17 00:00:00 2001 From: Andrea Aime Date: Sun, 28 Jul 2024 11:15:15 +0200 Subject: [PATCH] Support numeric grid names in vector tiles preview --- .../core/src/main/java/org/geowebcache/demo/Demo.java | 7 +++++++ .../resources/org/geowebcache/rest/webresources/demo.js | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java b/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java index 3d4f9dc95..135892dd7 100644 --- a/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java +++ b/geowebcache/core/src/main/java/org/geowebcache/demo/Demo.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang3.StringUtils; import org.geotools.util.logging.Logging; import org.geowebcache.GeoWebCacheException; import org.geowebcache.filter.parameters.FloatParameterFilter; @@ -342,6 +343,12 @@ private static String generateHTML(TileLayer layer, String gridSetStr, String fo Arrays.stream(gridSubset.getGridNames()) .map(s -> String.format("\"%s\"", s)) .collect(Collectors.joining(", ", "[", "]"))); + makeHiddenInput( + buf, + "gridNamesNumeric", + String.valueOf( + Arrays.stream(gridSubset.getGridNames()) + .allMatch(n -> StringUtils.isNumeric(n)))); makeHiddenInput(buf, "format", formatStr); makeHiddenInput(buf, "layerName", layerName); makeHiddenInput(buf, "SRS", gridSubset.getSRS().toString()); diff --git a/geowebcache/core/src/main/resources/org/geowebcache/rest/webresources/demo.js b/geowebcache/core/src/main/resources/org/geowebcache/rest/webresources/demo.js index 5d86df45c..99b5224f3 100644 --- a/geowebcache/core/src/main/resources/org/geowebcache/rest/webresources/demo.js +++ b/geowebcache/core/src/main/resources/org/geowebcache/rest/webresources/demo.js @@ -55,6 +55,7 @@ window.onload = function() { } var gridsetName = getValue('gridsetName'); + var gridNamesNumeric = getValue('gridNamesNumeric') === 'true' ? true : false ; var gridNames = JSON.parse(getValue('gridNames')); var baseUrl = '../service/wmts'; var style = ''; @@ -75,7 +76,7 @@ window.onload = function() { 'VERSION': '1.0.0', 'LAYER': layerName, 'STYLE': style, - 'TILEMATRIX': gridsetName + ':{z}', + 'TILEMATRIX': gridNamesNumeric ? '{z}' : gridsetName + ':{z}', 'TILEMATRIXSET': gridsetName, 'FORMAT': format, 'TILECOL': '{x}',