Skip to content

Commit dc7a23f

Browse files
committed
Update requirements matrix H.2 - use GetTile / text/mapml for rasters
Prune tiles returned for a tile-shaped GetMap to just the one Add formats.raster = text/mapml to advertised_formats.properties
1 parent 2be7d47 commit dc7a23f

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLDocumentBuilder.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,10 +1643,7 @@ private void generateWMTSClientLinks(MapMLLayerMetadata mapMLLayerMetadata) {
16431643
params.put("tilematrix", "{z}");
16441644
params.put("TileCol", "{x}");
16451645
params.put("TileRow", "{y}");
1646-
// if it's a raster layer, use the image format even if features are requested
1647-
boolean isRasterLayer = mapMLLayerMetadata.getLayerInfo() != null
1648-
&& mapMLLayerMetadata.getLayerInfo().getResource() instanceof CoverageInfo;
1649-
if (mapMLLayerMetadata.isUseFeatures() && !isRasterLayer) {
1646+
if (mapMLLayerMetadata.isUseFeatures()) {
16501647
params.put("format", MAPML_MIME_TYPE);
16511648
params.put(
16521649
"format_options",

src/extension/mapml/src/main/java/org/geoserver/mapml/MapMLFeatureUtil.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585

8686
public class MapMLFeatureUtil {
8787
private static final Logger LOGGER = Logging.getLogger(MapMLFeatureUtil.class);
88+
private static final double IS_TILE_TOL = 0.002D;
8889
public static final String STYLE_CLASS_PREFIX = ".";
8990
public static final String STYLE_CLASS_DELIMITER = " ";
9091
public static final String BBOX_DISPLAY_NONE = ".bbox {display:none}";
@@ -324,7 +325,13 @@ public static Mapml layerContextsToMapMLDocument(
324325
}
325326
}
326327
Collections.sort(tiles);
327-
featuresOrTiles.addAll(tiles);
328+
boolean isTile = (getMapRequest.getWidth() == getMapRequest.getHeight()
329+
&& tiles.get(0).getDistance() < IS_TILE_TOL);
330+
if (isTile) {
331+
featuresOrTiles.add(tiles.get(0));
332+
} else {
333+
featuresOrTiles.addAll(tiles);
334+
}
328335
}
329336
} catch (FactoryException | GeoWebCacheException | TransformException e) {
330337
throw new ServiceException("Error while looking up MapML gridset", e);

src/extension/mapml/src/main/resources/org/geoserver/gwc/advertised_formats.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
# for more info.
55
formats.vector = text/mapml
66
formats.layergroup = text/mapml
7+
formats.raster = text/mapml

src/extension/mapml/src/test/java/org/geoserver/mapml/MapMLFormatOptionsMatrixTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,12 @@ public void testScenarioH2_RasterWithCache() throws Exception {
403403
// For cached raster: should have GetTile URL
404404
assertXpathExists("//html:map-link[@rel='tile']", doc);
405405

406-
// Verify that the tile link contains "GetTile"
407-
String tileUrl = xpath.evaluate("//html:map-link[@rel='tile']/@tref", doc);
406+
// Verify that the tile link contains "GetTile" and has type=text/mapml
407+
String tileUrl = xpath.evaluate("//html:map-link[@rel='tile'][@type='text/mapml']/@tref", doc);
408408
assertTrue("Tile URL should contain GetTile", tileUrl.contains("GetTile"));
409409

410-
// Verify that the tile link uses image format for rasters
411-
assertTrue("Tile URL should use image format for rasters", tileUrl.contains("image/png"));
410+
// Verify that the tile link uses text/mapml for rasters with mapmlusefeatures:true
411+
assertTrue("Tile URL should use text/mapml for vector tiles", tileUrl.contains("text/mapml"));
412412

413413
} finally {
414414
disableTileCaching(new QName(MockData.CITE_URI, "World"), getCatalog());

0 commit comments

Comments
 (0)