Conversation
|
@pjonsson Thanks for the review! I've updated the PR. |
nf-s
left a comment
There was a problem hiding this comment.
Thanks @sidneygijzen !
Just one code comment, and can you please add a warning message in shortReport if the layer limit has been hit? Just so users know if a WMS item has been configured with too many layers
Thanks 🙂
| @computed | ||
| get layerLimit() { | ||
| const gcStratum: WebMapServiceCapabilitiesStratum | undefined = | ||
| this.strata.get( | ||
| GetCapabilitiesMixin.getCapabilitiesStratumName | ||
| ) as WebMapServiceCapabilitiesStratum; | ||
|
|
||
| return gcStratum?.layerLimit; | ||
| } | ||
|
|
There was a problem hiding this comment.
Instead of pulling layerLimit out of the WebMapServiceCapabilitiesStratum, it would be better to create a layerLimit trait in WebMapServiceCatalogItemTraits.
This would allow the user to configure it (in a JSON catalog), and then you can remove this get layerLimit in WebMapServiceCatalogItem.
While there are a few instances of using the WebMapServiceCapabilitiesStratum directly in WebMapServiceCatalogItem, this is not ideal, and should be considered an anti-pattern, at some point we'll refactor it 🙂
|
@nf-s thank you for the review! I appreciate it that you're explaining why something should be in a specific spot in the codebase. I will look into adding a warning message in Concerning the code comment, I am afraid I am a bit confused. A WMS LayerLimit is configured - and visible in the WMS GetCapabilities - by the organisation operating the WMS server. For example: see this section about Where it gets confusing for me, is that you refer to "allow the user to configure it (in a JSON catalog)". I am assuming that by "the user" you are referring to a person who is deploying TerriaJS. In my honest opinion there is no configuration to be made in this regard by the organisation/person deploying TerriaJS. It is not possible to change the The aforementioned is the reason why I chose to pull the layer limit out of the What do you think? |
|
In my view both approaches are valid and could both be implemented:
My suggestion would be to start with this, and then implement the second scenario in a separate PR, unless the approaches are conflicting... |
|
@sidneygijzen, @pvgenuchten, one approach we can try here is to introduce a trait for LayerLimit, allowing users to define their value as part of the JSON configuration. And if the layerLimit is defined as part of WMS Capabilities, use that as the default value if not supplied by the user. But let me check with @nf-s what he thinks about this and get back to this |
|
Sorry for the late reply @sidneygijzen It is less about being able to manually configure the Also, if you define a You can look at If you are unsure how the model layer/traits system works - we have some documentation available here
In short, you should define a @primitiveTrait({
type: "number",
name: "Layer limit",
description: "The maximum number of layers that can be requested simultaneously."
})
layerLimit?: number;And then you should delete the After both of those things, you will be able to use Thanks! |
|
Thank you for the detailed response @nf-s. I appreciate it a lot! I will have a closer look in the coming weeks and update this PR accordingly. |
|
I've thinking about this PR a while now, but the more I work on it, I'm not convinced the current implementation is correct. The current implementation limits the layers array, however I think the limitation is set too early in the process. A better implementation would be when a user would like to view multiple layers simultaneously, not when listing the available layers. So, following that line of thought, I am thinking of the following: 1) reverting the change to the layers array and 2) checking the layer limit when the user actually wants to add a layer to the map, e.g by checking the layerlimit in the Because of the above, I've converted this PR to draft state. |
What this PR does
This PR proposes an approach for implementing the WMS layer limit. One of the goals is trying to mitigate the resource-intensive requests - as reported in #6866 and #7320 - by enabling a WMS server administrator to make use of the WMS layer limit.
My initial thought was to modify the
WebMapServiceCatalogItemvalidLayersgetter, but during manual testing the styles URL param went awry. From what I can tell it is because theWebMapServiceCatalogItemlayersArrayis used in theWebMapServiceCapabilitiesStratumlegendsgetter. Therefore I chose to check for a layer limit in thelayersArray.A note on the modified XML test files; during the implementation a couple of unrelated tests errored out. A small number of xml files contained a
<LayerLimit>1</LayerLimit>. I have opted to remove the<LayerLimit>1</LayerLimit>elements from the XML file instead of adjusting the tests.Finally, I am not sure if it fully addresses #5267, because I haven't looked at the MagdaReference model.
Test me
Aside from the added unit test, I tested this manually by configuring a wms-group as a wms. Please see this gist for a test config. With this "wrong" config I try to simulate what is happening in #7320, which is that the CswCatalogGroup currently has no knowledge of the concept of a WMS-group. The WMS below has a WMS layer limit defined, so only one wms layer is requested in this case.
Checklist
- [ ] I've updated relevant documentation indoc/.