specify / specify7

Specify 7
https://www.specifysoftware.org/products/specify-7/
GNU General Public License v2.0
66 stars 36 forks source link

Add Swisstopo Integration #4761

Open grantfitzsimmons opened 7 months ago

grantfitzsimmons commented 7 months ago

🔴 At this time, this has not been identified as a blocker for GeoSpecify. This is a request for a future enhancement.

Is your feature request related to a problem? Please describe. We've heard from numerous Swiss institutions that being able to integrate with Swisstopo would be an incredibly useful utility for them. Since we already have integrated Leaflet into Specify, it seems natural to extend this to have all the Swisstopo base maps and layers so that they can effectively visualize their data on the maps provided by the service.

I've created a new leaflet layers JSON file that contains many of these maps as a starting point. From the troubleshooting I've done and based on discussions with Max, it seems that we'll need to add support for the coordinate projection system these maps rely on. When importing this file directly into Specify, it repeatedly reports that there is a bad request because tile is out of bounds.

image

topolayers.json.zip

Swisstopo uses the coordinate projection system LV95 (EPSG:2056), which is captured in the layerOptions as

"crs": "L.CRS.EPSG2056"

Fortunately, there is already a plugin that adds support for this CRS: https://leaflet-tilelayer-swiss.karavia.ch/installation

image

It may be as simple as studying the implementation done in this repository and adding it here: https://github.com/rkaravia/Leaflet.TileLayer.Swiss

I am happy to help create the default leaflet layers file after the CRS is supported.

For example, here's a snippet you can add in a new leaflet layer app resource for testing/evaluation: leaflet-layers-swisstopo.json.zip

{
  "baseMaps": {
    "Street Map (OpenStreetMap)": {
      "endpoint": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
      "serverType": "tileServer",
      "layerOptions": {
        "maxZoom": 23,
        "attribution": "Esri, HERE, Garmin, USGS, Intermap, INCREMENT P, NRCan, Esri Japan, METI, Esri China (Hong Kong), Esri Korea, Esri (Thailand), NGCC, (c) OpenStreetMap contributors, and the GIS User Community"
      },
      "styles": ["auto-dark-mode"]
    },
    "Street Map (ESRI)": {
      "endpoint": "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",
      "serverType": "tileServer",
      "layerOptions": {
        "maxZoom": 23,
        "attribution": "Esri, HERE, Garmin, USGS, Intermap, INCREMENT P, NRCan, Esri Japan, METI, Esri China (Hong Kong), Esri Korea, Esri (Thailand), NGCC, (c) OpenStreetMap contributors, and the GIS User Community"
      },
      "styles": ["auto-dark-mode"]
    },
    "Swisstopo": {
        "endpoint": "https://wmts0.geo.admin.ch/1.0.0/{layer}/default/{timestamp}/2056/{z}/{x}/{y}.{format}",
        "serverType": "tileServer",
        "layerOptions": {
            "minZoom": 17,
            "maxZoom": 27,
            "subdomains": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
            "attribution": "&copy; <a href='https://www.swisstopo.admin.ch/fr'>Swisstopo</a>",
            "format": "jpeg",
            "layer": "ch.swisstopo.pixelkarte-farbe",
            "timestamp": "current",
            "crs": "L.CRS.EPSG2056"
        },
        "styles": [
            "auto-dark-mode"
        ]
    }
  }
}

Reported By Several Swiss Museums of Natural History (Bern, Basel, Lausanne)

grantfitzsimmons commented 7 months ago

@maxpatiiuk – If you are available to spend some time looking at this with me sometime in the next few weeks/months, I would appreciate it. If you want to try and solve this alone, that is OK too 😉 . In any case, your insight is appreciated!

maxpatiiuk commented 7 months ago

(a message from out marketing deparment 😊)

-    "Street Map (ESRI)": {
+    "Street Map (Esri)": {
maxpatiiuk commented 7 months ago

It may be as simple as studying the implementation done in this repository and adding it here: https://github.com/rkaravia/Leaflet.TileLayer.Swiss

Looking at the code, it's not too complicated, but in this case I would favor using their library rather than doing that work on our own - Specify is not in a business of maintaining GIS code

Though, my suggestions about the implementation:

I don't like the idea of loading all those maps on every specify page load for every institution and having the layer list be populated with a hundred layers, of which almost all are usable only in one country at a narrow set of zoom levels