Skip to content

Commit

Permalink
Set default styles parameter in GetMap requests
Browse files Browse the repository at this point in the history
Use "default" for the STYLES parameter of GetMap requests when the parameter is missing or empty. If not set, default-<type>/default (e.g. default-scalar/default) is used by edal-java, which does not take into account defaults set in wmsConfig.xml.

Fixes #552
  • Loading branch information
lesserwhirls committed Dec 19, 2024
1 parent 8280c92 commit 37f73e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tds/src/main/java/thredds/server/wms/ThreddsWmsServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,6 +71,8 @@
public class ThreddsWmsServlet extends WmsServlet {
private static final Logger logger = LoggerFactory.getLogger(ThreddsWmsServlet.class);

private static final Map<String, String> defaultStyles = Collections.singletonMap("styles", "default");

private static class CachedWmsCatalogue {
public final ThreddsWmsCatalogue wmsCatalogue;
public final long lastModified;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 37f73e3

Please sign in to comment.