Hi,
so Chris tasked me taking a stab at the KML experiments in OWS-5.
Basically I need to create a new KML encoder that:
1) encodes the new kml 2.2 data/schemadata stuff
2) encoders geometries in gml3 instead of the "sort of gml2"
format used in kml 2.2
Both of them are to be considered experiments and has to be done
quickly, so I would like to avoid rewriting the current encoder.
The basic idea is to subclass it and replace the relevant part
with new code.
Doing 1) seems easy enough, I just have to override KMLVectorTransfomer.encodePlacemark and add a call to a new
encodeExtendedData(...) method. It's so un-harmful that could
be conceived as a parameter of the current encoder.
Doing 2) is a little trickier, and I could use some hint.
The KML encoder as it stands is based on the GeoTools
Translator interface, and in particular with the TranslatorSupport class, that uses a org.xml.sax.ContentHandler implementation
to actually write the xml. Doing the chain the KML encoder
uses org.geotools.gml.producer.GeometryTransformer#GeometryTranslator
to do the GML2 encoding.
On the other side GML3 is encoded with the new framework, and
org.geotools.xml.Encoder takes a OutputStream that it will write
onto.
Yet I noticed that Encoder instantiates an XMLSerializer to actually
write and, surprise surprise, XMLSerialize _is a_ ContentHandler.
So my current idea about how to bridge the two beasts is
to make a GML3Transformer wrapping an Encoder. I would just need
to add a public method to Encoder that accepts a ContentHandler,
make it so it does not encode the namespaces, and I should be gold.
(Encoder uses just one method of XMLSerializer that's not in
ContentHandler, .setNamespaces(true), which can be setup only
if the method that accepts an output stream).
So, am I on a good road, or do the xml masters suggest a better
way to make the two collaborate?
Cheers
Andrea
Sounds like a good idea to me. So if i understand correctly all you need
added to the Encoder is:
setContentHandler(ContentHandler)
In encode, we can do an instance of check in conjunction with checking
the namespaceAware flag before calling setNamespaces(boolean).
Should be pretty straight forward.
Andrea Aime wrote:
Hi,
so Chris tasked me taking a stab at the KML experiments in OWS-5.
Basically I need to create a new KML encoder that:
1) encodes the new kml 2.2 data/schemadata stuff
2) encoders geometries in gml3 instead of the "sort of gml2"
format used in kml 2.2
Both of them are to be considered experiments and has to be done
quickly, so I would like to avoid rewriting the current encoder.
The basic idea is to subclass it and replace the relevant part
with new code.
Doing 1) seems easy enough, I just have to override
KMLVectorTransfomer.encodePlacemark and add a call to a new
encodeExtendedData(...) method. It's so un-harmful that could
be conceived as a parameter of the current encoder.
Doing 2) is a little trickier, and I could use some hint.
The KML encoder as it stands is based on the GeoTools
Translator interface, and in particular with the TranslatorSupport
class, that uses a org.xml.sax.ContentHandler implementation
to actually write the xml. Doing the chain the KML encoder
uses org.geotools.gml.producer.GeometryTransformer#GeometryTranslator
to do the GML2 encoding.
On the other side GML3 is encoded with the new framework, and
org.geotools.xml.Encoder takes a OutputStream that it will write
onto.
Yet I noticed that Encoder instantiates an XMLSerializer to actually
write and, surprise surprise, XMLSerialize _is a_ ContentHandler.
So my current idea about how to bridge the two beasts is
to make a GML3Transformer wrapping an Encoder. I would just need
to add a public method to Encoder that accepts a ContentHandler,
make it so it does not encode the namespaces, and I should be gold.
(Encoder uses just one method of XMLSerializer that's not in
ContentHandler, .setNamespaces(true), which can be setup only
if the method that accepts an output stream).
So, am I on a good road, or do the xml masters suggest a better
way to make the two collaborate?
Cheers
Andrea
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
!DSPAM:4007,4714b300236213668746562!
--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org
Justin Deoliveira ha scritto:
Sounds like a good idea to me. So if i understand correctly all you need
added to the Encoder is:
setContentHandler(ContentHandler)
I was thinking more of a:
class Encoder {
...
public void encode( Object object, QName name, ContentHandler handler )
What do you think?
Cheers
Andrea
Andrea++. I do like that better... its cleaner.
Andrea Aime wrote:
Justin Deoliveira ha scritto:
Sounds like a good idea to me. So if i understand correctly all you need
added to the Encoder is:
setContentHandler(ContentHandler)
I was thinking more of a:
class Encoder {
...
public void encode( Object object, QName name, ContentHandler handler )
What do you think?
Cheers
Andrea
!DSPAM:4007,4714df5916167180515871!
--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org