Wednesday, April 03, 2013

Auto ordering point layers on top of line/polygon layers in GeoExplorer

Once in a while we get this question for GeoExplorer (GXP):

 Force the webviewer to draw points over lines over polygons regardless of the layer menu structure
Off course i get the idea, one will not hide the point layer by overlaying it with polygon features. But still implementing this feature is far les obvious as expected.

This feature is not common in Geo, one will not find it in common libraries. Impact will be quite high to change it code-wise in GXP. One would need a) a procedure to determine the featuretype of a layer (point/line/polygon/mixed/grid) and b) a procedure to reorder the layers triggered by a layer-add/move event, without altering the tree-structure. I'm not even sure a. is obvious, since featuretype is not advertised by default in WMS capabilities.

This might be one of those points where you'll have to decide if the GXP library is suitable for you, it presumes some default GIS workflow, and it's quite impactfull to change it. In such a case using the plain components OpenLayers/Geoext might solve your challenge more easily. But leaving you with a viewer with far less functionality by default.

If a question like this pops up, check the use case! Maybe there are alternatives to get similar behaviour, which do fit the common GIS workflow. For example similar behaviour could be managed by configuration, where one should configure all point layers on top.

By the way, in most usecases I'm not in favour of having tens of layers in a TOC. In most usecases I prefer to have just a couple of layers in a map and present the user another map with an alternative set of layers if they are working in another context (WMC/OWSContext). But give them the possibility of adding additional layers to the context via a CSW-interface.

2 comments:

Bart van den Eijnden said...

Funny, this request was also made for the Rijkswaterstaat MapViewer and I tried to postpone it as long as possible.
Getting the feature type for a WMS layer should be trivial in GXP, since it already does SLD WMS DescribeLayer, which tells you if it is raster or vector. And thenif vector it does WFS DescribeFeatureType, which tells you (if properly configured) the geometry type.

Paul said...

Thanx for the comment Bart, I guess this would work nicely in Geoserver, where for each wms also a wfs is available. But this will be less obvious in products only supporting wms. But even then, reordering the openlayers display order without changing the tree-viewporder is still quite impactfull