private void adjustTileMatrixSetInfo(LayerDefinition layerDefinition, Map<String, ?> layerObj) { if (layerObj == null) { return; } Map<String, ?> contents = (Map<String, ?>) layerObj.get("contents"); if (contents == null) { return; } /* find REST url information for selected layer */ /* tileMatrixSetData may contain other layer specs as well */ Object rawLayers = contents.get("layers"); if (rawLayers == null) { return; } Map<String, ?> wmtsLayerSpec = null; if (rawLayers instanceof List) { String layerName = layerDefinition.getWmsname(); List<Map<String, ?>> wmtsLayers = (List<Map<String, ?>>) rawLayers; for (Map<String, ?> wmtsLayerListEl : wmtsLayers) { if (!layerName.equals(wmtsLayerListEl.get("identifier"))) { continue; } wmtsLayerSpec = wmtsLayerListEl; break; } } else { wmtsLayerSpec = (Map<String, ?>) rawLayers; } if (wmtsLayerSpec == null) { return; } /* */ { Map<String, ?> resourceUrl = (Map<String, ?>) wmtsLayerSpec.get("resourceUrl"); if (resourceUrl == null) { return; } Map<String, ?> resourceTileInfo = (Map<String, ?>) wmtsLayerSpec.get("tile"); if (resourceTileInfo != null) { String format = (String) resourceTileInfo.get("format"); if (format != null) { layerDefinition.setFormat(format); String template = (String) resourceTileInfo.get("template"); if (template != null) { layerDefinition.setUrlTemplate(format, template); } } } } List<Map<String, ?>> resourceUrls = (List<Map<String, ?>>) wmtsLayerSpec.get("resourceUrls"); if (resourceUrls == null) { return; } for (Map<String, ?> resourceTileInfo : resourceUrls) { String format = (String) resourceTileInfo.get("format"); if (format != null) { if (layerDefinition.getFormat() == null) { layerDefinition.setFormat(format); } String template = (String) resourceTileInfo.get("template"); if (template != null) { layerDefinition.setUrlTemplate(format, template); } } } /* * "resourceUrl": { "tile": { "format": "image/png", "template": * "http://karttamoottori.maanmittauslaitos.fi/maasto/wmts/1.0.0/taustakartta/default/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png" * , "resourceType": "tile" } }, "resourceUrls": [ { "format": * "image/png", "template": * "http://karttamoottori.maanmittauslaitos.fi/maasto/wmts/1.0.0/taustakartta/default/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}.png" * , "resourceType": "tile" } ] */ }