Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Programmatically adding a WMS layer with custom URL string

Hello there udig-devel members. I hope in joining this mailing list you will be able to help me with some of my uDig woes.
 
As you maybe aware, GeoServer contains some non-standard WMS and SLD extensions that allow you to pass in parameters that allow you to customize how a getMap request is rendered.  For example, you can add "&env=param:value" to the end of the string to retrieve a map with customised colours or filter limits.  I would like to use this functionality in my uDig application, and i have not found anywhere in the GUI to add the custom parameters.
Right; so we would have to make one. 

One thing the GeoServer project has done wrong is introduce custom parameters without an associated description of them in the vendor specific options (i.e. as part of the GetCapabilities document). Even if they just had a flag indicating that the options were supported we could then "enable" a custom UI for geoserver :-)

Still with that rant out of the way we could just "guess" that these options are supported if the URL contains "geoserver/wms" in the path.
I would also like to add these layers automataically when my users configure the the application so that they can customize how my WMS server renders the map. At this point, using a WMF instead with a local SLD is not an option.
Thinking. So one thing to do is in your application you can add this GeoServer into the catalog; so your users can see it.
Or we can make a more general purpose approach that allows these options for any geoserver.  
I have determined that i should use ApplicationGIS.addLayersToMap() with an IGeoReference, but i am unable to get much further than that.  I believe the correct IGeoReference implementation i need is a WMSGeoReference but i cannot find where this class is located.
I am under the impression that you can add these layers to the map already; but you are missing the ability to apply these non-standard parameters.

Because the layer represents the same data with or without these settings applied; we would consider these settings to be part of the "style" used when rendering the layer.

So my strategy would be this review a good example and copy it for your additional parameters

1) Review the uDig code for handling of WMS "NamedStyle". This code is in three parts:
- An entry on the Layer StyleBlackboard (in this case a simple String) indicating which named style to use.
- A StyleConfigurationPage (this allows the user to choose which NamedStyle to use)
- Some code in the WMSRenderer which (when making a GetMapRequest) checks to see if a NamedStyle is available on the StyleBlackboard
2) So you could start by defining an object to hold your "GeoServerVendorOptions" (since you have more than just a simple String
3) Make a GeoServerVendorOptionsStyleConfigurationPage (not the best name I know) that allow you to set those vendor options
4) Update the WMS Renderer code to check on the styleblack board for your GeoServerVendorOptions (in addition to that named style) and to apply it to the GetMapRequest 
5) Note the GeoTools WebMapServer class may not allow easy access to additional parameters (but I think it allows additional key value pairs so that should be okay)

Finally to answer your question about how to do this for your users:
1) Make a plugin that has a workbench startup; and in that workbench startup you can check if you
2) For *your* web map server we can teach it how to make the correct GeoServerVendorOptions when a new layer is created. The trick is that when a new layer is created; the system goes through each possible style entry blackboard and asks the GeoResource if it has a good default value or not…
3) Make a ResolveAdaptorFactory that resolves from WMSLayer to GeoServerVendorOptions; in side that code you can check to ensure it is you web map server (if so you can return the defaults you want your users to see; if not you can return null).
I am very stuck at this point and I appreciate if someone could steer me in the correct direction to achieve my goal!
If you are having trouble getting started I recommend reviewing the tutorials; including the source code only tutorials on how the style blackboard works. 
- http://udig.refractions.net/confluence/display/DEV/7+Disk+to+Screen+Tutorials

In particular the tutorial on Render and Style is good background material; the source code is from our commercial training materials (available to academics free of charge); however I have update the wiki with pictures and diagrams so they should still be useful to you.

Jody

Back to the top