nathan-gs / ha-map-card

A Map Card for Home Assistant
https://community.home-assistant.io/t/map-card-a-slightly-improved-map-card/693088
MIT License
19 stars 4 forks source link

Not working for french geoservices? #18

Closed vingerha closed 2 months ago

vingerha commented 2 months ago

Hi, I played around with the examples and really enjoyed that. After a bit of digging into local options, I found this site https://geoservices.ign.fr/services-geoplateforme-diffusion There are 2 wms services, raster and vector and along the xml they both cover layer EPSG:27572 But neither of them show in the card...any idea why?


type: custom:map-card
zoom: 8
card_size: 6
wms:
  - url: >-
      https://data.geopf.fr/wms-v/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities
    options:
      layers:
        - EPSG:27572
      format: image/png
tile_layer_url: https://basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png
entities:
  - entity: zone.home
    display: icon
    size: 50
nathan-gs commented 2 months ago

I changed your code to the following

type: custom:map-card
zoom: 8
card_size: 6
wms:
  - url: https://data.geopf.fr/wms-v/ows?SERVICE=WMS
    options:
      layers:
        - EPSG:27572
      format: image/png
      attribution: GEOPF
      version: 1.3.0
x: 48.856697
'y': 2.351462

and if I then take a look at a request (https://data.geopf.fr/wms-v/ows?SERVICE=WMS&service=WMS&request=GetMap&layers=EPSG%3A27572&styles=&format=image%2Fpng&transparent=false&version=1.3.0&width=256&height=256&crs=EPSG%3A3857&bbox=-156543.03392804097,6105178.3231936,0,6261721.357121641):

<ServiceExceptionReport version="1.3.0" xsi:schemaLocation="http://www.opengis.net/ogc https://data.geopf.fr/wms-v/schemas/wms/1.3.0/exceptions_1_3_0.xsd">
<ServiceException code="LayerNotDefined" locator="layers"> Could not find layer EPSG:27572 </ServiceException>
</ServiceExceptionReport>

So the layer is not correct.

vingerha commented 2 months ago

What do you mean with not correct'...is this not correct for the card or is this incorrect for a WMS? If the latter, why would such a large organization deviate from a (is there) standard?

nathan-gs commented 2 months ago

The layer you specify is not the correct one, according to the error msg.

The card and server are following the WMS spec, but you have to use the right options of course. I did not immediately see which layer you should use though.

nathan-gs commented 2 months ago

The list of WMS layers is published on the page itself: https://geoservices.ign.fr/services-geoplateforme-diffusion#:~:text=Donn%C3%A9es%20du%20Service%20d'images%20WMS-Vecteur

(title Données du Service d'images WMS-Vecteur)

type: custom:map-card
zoom: 8
card_size: 6
wms:
  - url: https://data.geopf.fr/wms-v/ows
    options:
      layers: CLEFVERTE
      format: image/png
      attribution: GEOPF
      version: 1.3.0
      transparent: true
x: 48.856697
'y': 2.351462

gives this result

CLEFVERTE

vingerha commented 2 months ago

OK thanks, so the xml-inside section with layer ids is 'misleading' ? And maybe a continued stupid question....how would I have had to find out to not use this, which the website states

https://data.geopf.fr/wms-v/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetCapabilities

but use this what you mention above:

https://data.geopf.fr/wms-v/ows

EDIT: othe question... would you be able to explain why one layer works and the other does not? e.g.

vingerha commented 2 months ago

Hi, I have tested some 20 different 'layers' and about 50% do not work...or: I cannot get them do display anything. Now, I really like what you started and would like to know how I can debug and contribute to this ... but I need a bit of direction here (asides the time) Another thing I am questoning is wth is presented by these layers. No clue if they are up to date or what their color means (from dark blue to red)

nathan-gs commented 2 months ago

A good intro can be found here (and the QGIS part): https://leafletjs.com/examples/wms/wms.html

The docs of the GeoPF website are a bit short and out of date, might be best to contact them.

vingerha commented 2 months ago

Thanks... is on my to-learn-list now. Another thing I am interested in is the validity of the overlays. In the link above there are plenty of them that from the naming-only refer to 'current' data but I cannot find out what that means. As an example your Belgian air quality overlay, how would you know 'when' this was measured....could be years old as well ?

vingerha commented 2 months ago

Adding ideas... I would like to extract all layers into a select list for HA so that I can dynamically change the overlay. Would you know if there is a standardized (you may laugh out loud) way to publish layers?

nathan-gs commented 2 months ago

To be honest this will be very hard to implement since leaflet doesn't have that capability either. Not sure if there are any other javascript WMS libraries.

Closing for now, as it works as intended.