From c832dcbcac1fdbeff5e3f746d7d701927a5495ee Mon Sep 17 00:00:00 2001 From: Sean Arms <67096+lesserwhirls@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:03:37 -0700 Subject: [PATCH] BUG: set default styles parameter in GetMap requests Use "default" for the STYLES parameter of GetMap requests when the parameter is missing or empty. If not set, default-/default (e.g. default-scalar/default) is used by edal-java, which does not take into account defaults set in wmsConfig.xml. Fixes Unidata/tds#552 --- .../main/java/thredds/server/wms/ThreddsWmsServlet.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tds/src/main/java/thredds/server/wms/ThreddsWmsServlet.java b/tds/src/main/java/thredds/server/wms/ThreddsWmsServlet.java index f8091e14f7..30b2694af6 100644 --- a/tds/src/main/java/thredds/server/wms/ThreddsWmsServlet.java +++ b/tds/src/main/java/thredds/server/wms/ThreddsWmsServlet.java @@ -33,6 +33,7 @@ import com.google.common.cache.RemovalListener; import com.google.common.util.concurrent.UncheckedExecutionException; import java.io.IOException; +import java.util.Collections; import java.util.Formatter; import java.util.concurrent.ExecutionException; import org.slf4j.Logger; @@ -70,6 +71,8 @@ public class ThreddsWmsServlet extends WmsServlet { private static final Logger logger = LoggerFactory.getLogger(ThreddsWmsServlet.class); + private static final Map defaultStyles = Collections.singletonMap("styles", "default"); + private static class CachedWmsCatalogue { public final ThreddsWmsCatalogue wmsCatalogue; public final long lastModified; @@ -112,6 +115,11 @@ protected void dispatchWmsRequest(String request, RequestParams params, HttpServ TdsRequestedDataset tdsDataset = new TdsRequestedDataset(httpServletRequest, removePrefix); ThreddsWmsCatalogue catalogue = acquireCatalogue(httpServletRequest, httpServletResponse, tdsDataset.getPath()); + // set default style if needed + if (request.equals("GetMap") && params.getString("styles", "").isEmpty()) { + params = params.mergeParameters(defaultStyles); + } + /* * Now that we've got a WmsCatalogue, we can pass this request to the * super implementation which will handle things from here.