Hi all,
I’m writing this mail to start a discussion on some GSIP we want to make later down the
line (that is, not by Jan 21) and that would result in a full refactor of the KML generation
subsystem in GeoServer, which is a big amount of work, but luckily for us, funded, too,
in the direction to give the KML subsystem better support for the future, both in
terms of evolutions and maintenance: it is no big secret that few (none?) developers
are happy to work in that portion of the code base.
The starting point is of course to setup some design that everybody would be happy with,
then we’ll make a proposal and do the work.
So, this is the phase in which we’re trying to gather as much feedback as possible
from the community in order to make the KML subsystem better
A good starting point could be David’s retired proposal on this very topic, here:
http://geoserver.org/display/GEOS/GSIP+21±+KML+Vector+Transformer+Refactoring
Some ideas I’d certainly like to reuse:
- factor out code shared with streaming renderer in helper classes to avoid duplication
- add some selected extension points to make it easier to interact with the kml generator
- the idea of classifications is a nice one, but a bit out of the scope of the refactoring work
- pluggable placemark generation is also interesting, thought we’d have to figure out
a way for the various listeners to work togheter intead of encoding twice the same element/attribute
One aspect that is not considered in the proposal above, but which is imho key to
untangle the existing code, is to have a clear separation between the code that’s
writing the KML and the one that manipulates the feature collections and styles
in order to get the desired result.
To make some parallels, the WMS renderer, StreamingRenderer, does something
similar, but it’s not actually painting pixels at the low level, it’s telling a Graphics2D
to do so.
Now, a clean way to do so could be to create an object model of KML, have the
main code build the tree representing the KML output, and then have a second
bit of code doing the XML encoding.
This has some advantages, for example, having a target object model means
that we can have N listeners/plugins manipulate the structure iteratively
without the risk of generating in output the same information multiple time.
It has of course a deadly drawback: we’d have to keep everyting in memory
to follow this approach, breaking information streaming.
That of course cannot be, but there may be some compromise between that
and a solution that embeds in same code chunk feature/style manipulation
and XML writing.
Ideas:
- have an object model, but work with it in chunks. Like, build in memory
a placemark, serialize it to xml, and then move to the next, and so on
(and something similar would happen to Document and Link objects) - have a set of nested “builders” that write the XML, and have the main
code call upon them, these builders would have methods dealing
with KML concepts as opposed to low level XML ones
I also had a look at xsd-kml, but it seems to me that it’s geared towards
parsing and there is no concept of “streaming writing” using it?
Well, that’s enough for a first cut in the discussion.
Feedback appreciated
Cheers
Andrea
–
==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it