Request to have a WMS layer also available as WMTS layer

57 views
Skip to first unread message

Christian Riesen

unread,
Oct 17, 2022, 4:06:38 AM10/17/22
to GeoAdminCh API
Hello

I'm using leaflet (1.9.3) and this plugin to access WMTS layers: https://github.com/rkaravia/Leaflet.TileLayer.Swiss
That works great and the dev did a wonderful job. All layers from https://wmts.geo.admin.ch/EPSG/2056/1.0.0/WMTSCapabilities.xml work excellently.

Now I would like to use the layer ch.bfe.elektrizitaetsproduktionsanlagen and that one is only accessible as a WMS layer. Technically leaflet should be able to handle WMS layers but so far I have not been able to get it to work "right". They issues are numerous and I can go into detail there, but wondering if perhaps there is a simpler (for me) solution: Can the ch.bfe.elektrizitaetsproduktionsanlagen layer also be exposed as WMTS layer?

I'm also interested in separated layers, for example just the solar production facilities, and not all then other ones smushed into the same layer as well. However that would be a more nice to have.

I did find a WMS example but that is using a leaflet version that is over 9 years old now, which then no longer works with other plugins and tools that I'm using. However if someone has a modern example of how to put the ch.bfe.elektrizitaetsproduktionsanlagen WMS layer into modern leaflet, I'd be very grateful as well.

Greetings,
Christian Riesen

Pascal Barth

unread,
Oct 17, 2022, 9:03:28 AM10/17/22
to geoadm...@googlegroups.com
Hi Christian,

It should be pretty straighforward to add a WMS layer to leaflet, here's a more modern exemple I just made : https://codesandbox.io/s/wms-and-wmts-layer-with-leaflet-1-9-48y6mu

Regarding the way the layer is compiled (and that it's not possible to sort stuff out, like solar facilities, or other types) I don't think there's a solution to that, currently. You can maybe get in touch with the BFE to see if they would be willing to share their data as GeoJSON, it would then be way easier to sort things out on the fly.

Best regards,
Pascal Barth

--
You received this message because you are subscribed to the Google Groups "GeoAdminCh API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/ef347a21-4763-4f3d-be1a-5cb8bd498d6an%40googlegroups.com.

David...@swisstopo.ch

unread,
Oct 17, 2022, 9:11:19 AM10/17/22
to geoadm...@googlegroups.com, Geoinfo...@bfe.admin.ch

Hi Christian

 

Since ch.bfe.elektrizitaetsproduktionsanlagen is updated quite frequently and it is a vector layer, we did not yet add it as wmts ( or WMS-C)

However, you can download it your self via STAC API  https://data.geo.admin.ch/api/stac/v0.9/collections/ch.bfe.elektrizitaetsproduktionsanlagen (browser https://data.geo.admin.ch/browser/index.html#/collections/ch.bfe.elektrizitaetsproduktionsanlagen/items/elektrizitaetsproduktionsanlagen ) and use it as well locally. Just make sure you check for updates frequently

 

BFE is in cc—they might give us the task to add it as WMTS

 

Cheers

Dave

Christian Riesen

unread,
Oct 17, 2022, 2:54:35 PM10/17/22
to GeoAdminCh API
Thank you for the example. I do get however a very strange behavior here. In your example itself you can see how the tiles are somehow wonky. I highlighted a veritcal and a horizontal line in the top left to illustrate.

sample-1.jpg

When I do this, I get a similar result.

sample-2.jpg

With the added bonus strangeness that I only see the layer at zoom 18 or less (further zoomed out). As soon as I get to zoom 19 the entire layer vanishes. In the layer control it even grays out the checkbox at that point. Completely strange.


sample-3.jpg

So something is going haywire and I haven't a clue what I could do to make this work.

Christian Riesen

unread,
Oct 17, 2022, 2:57:36 PM10/17/22
to GeoAdminCh API
Hello Dave

Thanks for the info. I have found that data before, it's just a lot. Having a ready layer is much easier prospect at this point.

Greetings,
Christian Riesen

Pascal Barth

unread,
Oct 18, 2022, 3:05:49 AM10/18/22
to geoadm...@googlegroups.com
The issue is that leaflet automatically requests the WMS in a tile oriented fashion. Meaning that labels that are on the edge of a tile will be cropped. I've added a little Leaflet plugin that asks for the entire screen worth of data in one go, as there is no solution like a gutter implemented in Leaflet.
It should look alright now.

Best regards,
Pascal

Christian Riesen

unread,
Oct 27, 2022, 4:49:37 AM10/27/22
to GeoAdminCh API
I sent a request for WMS support from the plugin developer that I use the WMTS layers from already. And wow, he delivered. Here is the link to his very detailed reply on what is happening with examples and everything to make it work the way it's expected to within leaflet. Big props to him. If anyone has the same or a similar problem, this might help them as well.

He also mentioned something about a configuration that perhaps is server side that could be improved. I'm not steeped deep enough in it to know anything about it, but could be good to have a look at.

David Oesch

unread,
Oct 27, 2022, 11:31:56 AM10/27/22
to geoadm...@googlegroups.com
Thanks !
Yes the gutter option is one kind of a Hack—- don’t know if we will change it in the future. Will ask in the team- Pascal - any hint we need this in the Next version of the viewer?

Pascal Barth

unread,
Oct 28, 2022, 1:45:13 AM10/28/22
to geoadm...@googlegroups.com
Nice! Props to the dev of this plugin.

@Dave, with our new viewer : we should be doing it the same way, as we are once again using OpenLayers that has this gutter option. So I wouldn't see why we would want to change that right now, at least on the frontend side of things.
Maybe we could ask our data team if a more accurate tile WMS rendering is possible, including margin management, with newer version of our libraries / WMS server? But that's a technical field I'm totally unaware of.

GeoAdminCh API

unread,
Oct 28, 2022, 3:17:10 AM10/28/22
to GeoAdminCh API
Since it is OL related and we will use OL in the nextGen viewer https://github.com/geoadmin/web-mapviewer and the backend did not change: we will stick to the gutter option for the time beeing.
Reply all
Reply to author
Forward
0 new messages