Skip to content

Commit

Permalink
html output was missing feature and tiles and multi
Browse files Browse the repository at this point in the history
  • Loading branch information
turingtestfail committed Feb 5, 2025
1 parent 846efa4 commit ab3d432
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,11 @@ private MapMLLayerMetadata layerToMapMLLayerMetadata(RawLayer layer, String styl
*/
@SuppressWarnings("unchecked")
private static boolean useFeatures(RawLayer layer, GetMapRequest getMapRequest) {
Optional useFeaturesOptional =
Optional.ofNullable(getMapRequest.getFormatOptions().get(MAPML_USE_FEATURES_REP));
Optional useFeaturesOptional = Optional.ofNullable(getMapRequest
.getFormatOptions()
.getOrDefault(
MAPML_USE_FEATURES_REP.toUpperCase(),
getMapRequest.getFormatOptions().get(MAPML_USE_FEATURES_REP.toLowerCase())));
return (Boolean.parseBoolean((String) useFeaturesOptional.orElse(MAPML_USE_FEATURES_REP_DEFAULT.toString())))
&& (PublishedType.VECTOR == layer.getPublishedInfo().getType());
}
Expand All @@ -636,8 +639,11 @@ private static boolean useFeatures(RawLayer layer, GetMapRequest getMapRequest)
*/
@SuppressWarnings("unchecked")
private static boolean useTiles(RawLayer layer, GetMapRequest getMapRequest) {
Optional useTilesOptional =
Optional.ofNullable(getMapRequest.getFormatOptions().get(MAPML_USE_TILES_REP));
Optional useTilesOptional = Optional.ofNullable(getMapRequest
.getFormatOptions()
.getOrDefault(
MAPML_USE_TILES_REP.toUpperCase(),
getMapRequest.getFormatOptions().get(MAPML_USE_TILES_REP.toLowerCase())));
return Boolean.TRUE.equals(
Boolean.parseBoolean((String) useTilesOptional.orElse(MAPML_USE_TILES_REP_DEFAULT.toString())));
}
Expand Down Expand Up @@ -1766,6 +1772,8 @@ public String getMapMLHTMLDocument() {
String cqlFilter = "";
Double latitude = 0.0;
Double longitude = 0.0;
boolean useTiles = false;
boolean useFeatures = false;
ReferencedEnvelope projectedBbox = this.projectedBox;
ReferencedEnvelope geographicBox = new ReferencedEnvelope(DefaultGeographicCRS.WGS84);
List<String> headerContent = getPreviewTemplates(MAPML_PREVIEW_HEAD_FTL, getFeatureTypes());
Expand Down Expand Up @@ -1795,6 +1803,8 @@ public String getMapMLHTMLDocument() {
} catch (TransformException | FactoryException e) {
throw new ServiceException("Unable to transform bbox to WGS84", e);
}
useTiles = mapMLLayerMetadata.isUseTiles();
useFeatures = mapMLLayerMetadata.isUseFeatures();
}
// remove trailing commas
layerLabel = layerLabel.replaceAll(",$", "");
Expand All @@ -1810,7 +1820,16 @@ public String getMapMLHTMLDocument() {
}
MapMLHTMLOutput htmlOutput = new MapMLHTMLOutput.HTMLOutputBuilder()
.setSourceUrL(buildGetMap(
layer, projectedBbox, width, height, escapeHtml4(proj), styleName, format, cqlFilter))
layer,
projectedBbox,
width,
height,
escapeHtml4(proj),
styleName,
format,
cqlFilter,
useTiles,
useFeatures))
.setProjType(projType)
.setLatitude(latitude)
.setLongitude(longitude)
Expand Down Expand Up @@ -1903,7 +1922,9 @@ private String buildGetMap(
String proj,
String styleName,
Optional<Object> format,
String cqlFilter) {
String cqlFilter,
boolean useTiles,
boolean useFeatures) {
Map<String, String> kvp = new LinkedHashMap<>();
kvp.put("LAYERS", escapeHtml4(layer));
kvp.put("BBOX", toCommaDelimitedBbox(projectedBbox));
Expand All @@ -1916,7 +1937,9 @@ private String buildGetMap(
}
kvp.put("FORMAT", MAPML_MIME_TYPE);
String formatOptions =
MapMLConstants.MAPML_WMS_MIME_TYPE_OPTION + ":" + escapeHtml4((String) format.orElse(imageFormat));
MapMLConstants.MAPML_WMS_MIME_TYPE_OPTION + ":" + escapeHtml4((String) format.orElse(imageFormat)) + ";"
+ MapMLConstants.MAPML_MULTILAYER_AS_MULTIEXTENT + ":" + isMultiExtent + ";"
+ MAPML_USE_TILES_REP + ":" + useTiles + ";" + MAPML_USE_FEATURES_REP + ":" + useFeatures;
kvp.put("format_options", formatOptions);
kvp.put("SERVICE", "WMS");
kvp.put("REQUEST", "GetMap");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
public class MapMLFormatLink extends CommonFormatLink {

public static final String FORMAT_OPTIONS = "format_options";
public static final String FORMAT_OPTION_TRUE = "=true";
public static final String FORMAT_OPTION_FALSE = "=false";
public static final String FORMAT_OPTION_TRUE = ":true";
public static final String FORMAT_OPTION_FALSE = ":false";
public static final String LAYERINFO_LAYERS = "layers";
public static final String FORMAT_OPTION_DEFAULT = "false";

Expand Down Expand Up @@ -61,6 +61,10 @@ void customizeRequest(GetMapRequest request, Map<String, String> params) {
metadata.get(MapMLConstants.MAPML_USE_FEATURES) != null
? metadata.get(MapMLConstants.MAPML_USE_FEATURES).toString()
: FORMAT_OPTION_DEFAULT);
boolean useTiles = Boolean.parseBoolean(
metadata.get(MapMLConstants.MAPML_USE_TILES) != null
? metadata.get(MapMLConstants.MAPML_USE_TILES).toString()
: FORMAT_OPTION_DEFAULT);
// set the format
params.put("format", MapMLConstants.MAPML_HTML_MIME_TYPE);
// set the format_options
Expand All @@ -72,9 +76,15 @@ void customizeRequest(GetMapRequest request, Map<String, String> params) {
}
formatOptions.append(";");
if (useFeatures) {
formatOptions.append(MapMLConstants.MAPML_FEATURE_FO).append(FORMAT_OPTION_TRUE);
formatOptions.append(MapMLConstants.MAPML_USE_FEATURES_REP).append(FORMAT_OPTION_TRUE);
} else {
formatOptions.append(MapMLConstants.MAPML_USE_FEATURES_REP).append(FORMAT_OPTION_FALSE);
}
formatOptions.append(";");
if (useTiles) {
formatOptions.append(MapMLConstants.MAPML_USE_TILES_REP).append(FORMAT_OPTION_TRUE);
} else {
formatOptions.append(MapMLConstants.MAPML_FEATURE_FO).append(FORMAT_OPTION_FALSE);
formatOptions.append(MapMLConstants.MAPML_USE_TILES_REP).append(FORMAT_OPTION_FALSE);
}
params.put(FORMAT_OPTIONS, formatOptions.toString());
// check if we can use a native MapML CRS, otherwise fall back to WGS84 to
Expand Down

0 comments on commit ab3d432

Please sign in to comment.