GeoServer

Unable to send WMS request for multiple layers of same feature with different filter

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.6.4
  • Fix Version/s: 1.6.5, 1.7.0-RC2
  • Component/s: WMS
  • Labels:
    None
  • Number of attachments :
    1

Description

Trying to create a WMS call with multiple layers of the same feature with different filters. The code that builds the urls in WMSRequest.java does a couple of searches through the request looking for the layer being built by iterating the request layers and looking for the current layer name. However there are multiple layers with the same name (only the filter is different). This causes the default style to be appended as many times as the layername matches and the filters to be the first that matches the layername.

The WMSRequest.java getMapUrl method really needs a layer index to specifically tell it which of the layers in the request we are currently building. That way we can get the correct filter and only append the style once.

I can supply a candidate patch if this sounds reasonable. Or maybe there is a better way???

Activity

Hide
Chris Holmes added a comment -

If you could supply a patch against 1.7.x that would be great. 1.6.x is really close to end of life, but we are releasing 1.6.5 next week, so we can hopefully squeeze this fix in. Let's see if Andrea or Justin have anything to say about doing it a better way. But if they agree and you can get a patch and a unit test exposing the problem in by the end of this week we will do all we can to include the fix.

Show
Chris Holmes added a comment - If you could supply a patch against 1.7.x that would be great. 1.6.x is really close to end of life, but we are releasing 1.6.5 next week, so we can hopefully squeeze this fix in. Let's see if Andrea or Justin have anything to say about doing it a better way. But if they agree and you can get a patch and a unit test exposing the problem in by the end of this week we will do all we can to include the fix.
Hide
Matt Bucknam added a comment -

Please see the following test URLs which duplicate the problem:

Does not work:
http://localhost:8080/geoserver/kml/wms?layers=topp:states,topp:states

Partial stack trace:
org.vfny.geoserver.wms.WmsException: No such style: populationpopulation
at org.geoserver.wms.kvp.GetMapKvpRequestReader.parseStyles(GetMapKvpRequestReader.java:1177)
at org.geoserver.wms.kvp.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:258)
at org.geoserver.ows.Dispatcher.parseRequestKVP(Dispatcher.java:1016)
at org.geoserver.ows.Dispatcher.dispatch(Dispatcher.java:385)
at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:185)

Once this problem is fixed by putting a simple break after line 227 in org.geoserver.wms.util.WMSRequests.java, the filter problem comes into play. I originally fixed this locally and before I could file a bug I ran into the filter problem

The same URL above with the addition of two filters (already URL-escaped for the greater than sign):

http://localhost:8080/geoserver/kml/wms?layers=topp:states,topp:states&CQL_FILTER=LAND_KM%3E400000;LAND_KM%3DLAND_KM

This filter should result in two different layers, the first showing calif and tex and the second showing all states. The two network links created can be individually inspected and will show that both layers were written with the first filter in the list.

The solution involved adding a layer index to the WMSRequest helper methods. This involved some amount of refactoring and some places in the call hierarchy I was unable to determine a layer index to send through. In those cases, I defaulted a 0 which may not be completely correct. I added some code to minimize the chances that this fix causes side effects which, in essence, uses the old logic if the request does not contain multiple layers with the same name. This should be refactored out eventually since it kind of complicates the code.

Show
Matt Bucknam added a comment - Please see the following test URLs which duplicate the problem: Does not work: http://localhost:8080/geoserver/kml/wms?layers=topp:states,topp:states Partial stack trace: org.vfny.geoserver.wms.WmsException: No such style: populationpopulation at org.geoserver.wms.kvp.GetMapKvpRequestReader.parseStyles(GetMapKvpRequestReader.java:1177) at org.geoserver.wms.kvp.GetMapKvpRequestReader.read(GetMapKvpRequestReader.java:258) at org.geoserver.ows.Dispatcher.parseRequestKVP(Dispatcher.java:1016) at org.geoserver.ows.Dispatcher.dispatch(Dispatcher.java:385) at org.geoserver.ows.Dispatcher.handleRequestInternal(Dispatcher.java:185) Once this problem is fixed by putting a simple break after line 227 in org.geoserver.wms.util.WMSRequests.java, the filter problem comes into play. I originally fixed this locally and before I could file a bug I ran into the filter problem The same URL above with the addition of two filters (already URL-escaped for the greater than sign): http://localhost:8080/geoserver/kml/wms?layers=topp:states,topp:states&CQL_FILTER=LAND_KM%3E400000;LAND_KM%3DLAND_KM This filter should result in two different layers, the first showing calif and tex and the second showing all states. The two network links created can be individually inspected and will show that both layers were written with the first filter in the list. The solution involved adding a layer index to the WMSRequest helper methods. This involved some amount of refactoring and some places in the call hierarchy I was unable to determine a layer index to send through. In those cases, I defaulted a 0 which may not be completely correct. I added some code to minimize the chances that this fix causes side effects which, in essence, uses the old logic if the request does not contain multiple layers with the same name. This should be refactored out eventually since it kind of complicates the code.
Hide
Matt Bucknam added a comment -

This patch was created against the 1.6.4 9008 tag from Subversion

Show
Matt Bucknam added a comment - This patch was created against the 1.6.4 9008 tag from Subversion
Hide
Gabriel Roldán added a comment - - edited

Applied the patch with some slight modifications to 1.7.x, also noted that the styles were not being respected if present in the request so fixed that too.

A request like the following should give you the two complementary layers with different styling:
http://localhost:8080/geoserver/kml/wms?layers=topp:states,topp:states&CQL_FILTER=LAND_KM<400000;LAND_KM>400000&styles=green,polygon

Show
Gabriel Roldán added a comment - - edited Applied the patch with some slight modifications to 1.7.x, also noted that the styles were not being respected if present in the request so fixed that too. A request like the following should give you the two complementary layers with different styling: http://localhost:8080/geoserver/kml/wms?layers=topp:states,topp:states&CQL_FILTER=LAND_KM<400000;LAND_KM>400000&styles=green,polygon
Hide
Gabriel Roldán added a comment -

The fix is commited on 1.6.x, 1.7.x and trunk.

Thanks Matt for the patch, had to tweak it here and there but overall it was great.

Show
Gabriel Roldán added a comment - The fix is commited on 1.6.x, 1.7.x and trunk. Thanks Matt for the patch, had to tweak it here and there but overall it was great.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: