nrenner / brouter-web

Web client for BRouter, a routing engine based on OpenStreetMap
https://brouter.de/brouter-web/
MIT License
360 stars 68 forks source link

Adding WMTS overlay #294

Open ddand opened 4 years ago

ddand commented 4 years ago

Hi, I'm trying to add a WMTS shading layer from the polish map server 'Geoportal'. In the JOSM software working URL has the following form: https://mapy.geoportal.gov.pl/wss/service/PZGIK/NMT/GRID1/WMTS/ShadedRelief?REQUEST=GetCapabilities&SERVICE=WMTS{header(User-Agent,Mozilla/5.0 (JOSM)}

Unfortunately this link doesn't work as a overlay in the Brouter web client. Is it possible to rebuild this link to make it work?

Daniel

nrenner commented 4 years ago

A WMTS service compatible with the OSM/Leaflet tile definition and projection should work, like that: http://gpp3-wxs.ign.fr/6qyeeg75b526mac4g4qmjazn/wmts?LAYER=GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}

But this one is special as it only supports a local projection.

There are also two WMTS plugins for Leaflet (our map library): https://github.com/alexandre-melard/leaflet.TileLayer.WMTS https://github.com/GeoportalPL/leaflet.projwmts

The latter even is from geoportal.gov.pl, but it requires additional options to be set:

var epsg2180 = '+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs';
proj4.defs('EPSG:2180', epsg2180);
var crs = new L.Proj.CRS("EPSG:2180", epsg2180, {});

L.tileLayer.projwmts('https://mapy.geoportal.gov.pl/wss/service/PZGIK/NMT/GRID1/WMTS/ShadedRelief', {
    crs: crs,
    origin: [850000.0, 100000.0],
    scales: [7559538.928571429, 3779769.4642857146, 1889884.7321428573, 944942.3660714286, 472471.1830357143, 236235.59151785716, 94494.23660714286, 47247.11830357143, 23623.559151785714, 9449.423660714287, 4724.711830357143, 1889.8847321428573, 944.9423660714286, 472.4711830357143],
    tilematrixSet: 'EPSG:2180',
}).addTo(map);

These could probably be parsed from the metadata of a GetCapapilities request like returned from your URL: https://mapy.geoportal.gov.pl/wss/service/PZGIK/NMT/GRID1/WMTS/ShadedRelief?REQUEST=GetCapabilities&SERVICE=WMTS

In addition, a lookup for the definition of the EPSG code would need to be made.

So extra work would need to be done to support such services in other projections, but not sure I want to be doing this, and it should really be supported by the plugin itself.