Hi all,
Just in time to coincide with Andrea’s KML refactoring I’ve been putting some time into the dynamic KML icon support I discussed previously. I still haven’t merged the refactoring into my branch, but for the sake of discussion I’ve put up my code here: https://github.com/dwins/geoserver/compare/kml-dynamic-icons . If you just want to use it, rebuild at least the restconfig and wms modules and request KML from GeoServer in vector mode. (The easiest way to do this, I think, is to use the layer preview to get a URL to a layer in a format with fewer format options and then just replace the format with ‘kml’.)
The basic approach that it takes is to extract “dynamic” styling properties from a style and encode them into a URL (along with the style name, to retrieve the original static properties.) Then a REST service interprets those URLs to generate icons on demand. (Depending on how long things take I’d like to take measures to normalize properties - for example scaling opacity to a limited precision - in order to increase the likelihood of a caching web client like Google Earth reusing icons that are visually similar between different features.)
The big gaps right now are:
- I’m not sure how to get a style’s identifier from within the KMLMapTransformer - AFAIK I just get the parsed Style. The existing code appears to use Style.getName to generate WMS links but I am 99% sure this is a bug. Even if .getName is correct, I would still need the workspace to fully identify a style when generating icon URLs. Alternatively to identifying styles I could encode static styling properties in URLs, but I am wary of making the icon service open-ended in this way.
- KMZ icons should be embedded in the KMZ directory structure rather than referenced via URL. (I am thinking I will simply hash the same information that would have gone into the icon urls to generate probably-unique icon file names.)
- Fix up the rest service so that it doesn’t require administrative authentication.
Of course there’s also still the small matter of dealing with the new kml module - I probably will not be able to investigate this today but it will be a priority for next week.
–
David Winslow
OpenGeo - http://opengeo.org/