Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wms getlegendgraphic does not include custom parameters #7198

Open
pvgenuchten opened this issue Jun 17, 2024 · 4 comments · May be fixed by #7263
Open

wms getlegendgraphic does not include custom parameters #7198

pvgenuchten opened this issue Jun 17, 2024 · 4 comments · May be fixed by #7263

Comments

@pvgenuchten
Copy link

pvgenuchten commented Jun 17, 2024

our wms service https://maps.isric.org/mapserv?map=%2Fmap%2Faf250m_nutrient.map has a custom url parameter map, when this layer is added to the terria map, the legend graphic is not shown because the getlegendgraphic request does not include the custom map parameter.

This is quite unexpected, because the getcapabilities actually lists the correct legend url

image

@na9da
Copy link
Collaborator

na9da commented Aug 6, 2024

@pvgenuchten

Currently you need to tell Terria which style to use for the layers for it to pick the correct legend URL from the getcap response.
If you want to do this for the entire group, you could use a catalog definition like below:

{
      "type": "wms-group",
      "url": "https://maps.isric.org/mapserv?map=%2Fmap%2Faf250m_nutrient.map",
      "name": "Datasets",
      "itemProperties": {
        "styles": "default"
      }
}

Note the itemProperties setting which will apply to all items in the group. This works as long as all the layers have the same style named default.

Here's a test link to see it working - http://ci.terria.io/main/#share=s-kQIzjq2NX3icLFxujghRGyJcg0y&clean

Let me know if that works for you.

@pvgenuchten
Copy link
Author

pvgenuchten commented Aug 6, 2024

Hi Nanda, thanx for having a look. the problem seems a bit different from how you assessed it.

(although maybe i'm looking at it incorrectly)

The layer was added without any reference to a style or legend, I assume internally terriajs calculates the url of the legend by concatenating the wms url with ?request=getlegendgraphic. unfortunately it strips the required map=example parameter in that process, which is essential for this mapservice backend.

`${this.url}?service=WMS&version=1.1.0&request=GetLegendGraphic&format=image/png&transparent=True`
uses this.url as a starting point, instead it would need a procedure similar to getcapabilities at https://github.com/TerriaJS/terriajs/blob/f29650d8f0033a412ceebd90fc30763bbc1b4464/lib/Models/Catalog/Ows/WebMapServiceCatalogItem.ts#L306C17-L306C42 where typical parameters are removed from the request, and others are left

Also consider that the WMS capabilities advertises the legend url, so there is actually no need to assemble it by terria

Maybe @sidneygijzen, you can also have a look at this issue, to see if you can prepare a PR

@na9da
Copy link
Collaborator

na9da commented Aug 6, 2024

Yes, I think there are two issues here:

  • Stripping the extra URL parameters, which happens here. Not sure entirely why we do that but I guess if the user copy pastes a URL which contains extra WMS params then dropping the entire params is the simplest way to scrub them.
  • The legend from the getcap is not picked because the legends are defined under this hierarchy layer > style > legend. To know which legend to use, Terria needs to know the active style for the layer. When the style is not set explicitly, the WMS server uses a default style, but it doesn't advertise what this default style is and Terria cannot automatically pick any style > legend as it could be incorrect. However, I think if the layer has only a single style defined - like in this case - then Terria should probably assume it is the active style and automatically use the legend for it. (relevant code)

@sidneygijzen
Copy link

hello Nanda and Paul,

Thanks a lot for the detailed information. I will have a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants