Geotools contains some packages dealing with KML: org.geotools.kml and org.geotools.kml.bindings. I assume it was designed to parse KML data.
Do you know how to use it?
|
Geotools contains some packages dealing with KML: org.geotools.kml and org.geotools.kml.bindings. I assume it was designed to parse KML data. Do you know how to use it? |
||||
|
|
|
The KML support is tied into the XML facilities for encoding and parsing geometry. The GeoTools user guide has replaced the wiki links provided by Ian above - with a nice clear page devoted to wrangling geometry and XML: http://docs.geotools.org/latest/userguide/library/xml/geometry.html One of the headings on that page is devoted to KML (http://docs.geotools.org/latest/userguide/library/xml/geometry.html#kml). Site policy here asks that we include the answer rather than just provide links. With that in mind:
Or to parse KML you need to consider geometry and style as KML includes both. Here is an example that fetches a collection of features back.
You can also ask it for a stream of results (incase the file is bigger than memory):
Best of luck (and if in doubt review the test cases). |
|||
|
|
There is a KMLExample at http://svn.osgeo.org/geotools/trunk/demo/example/src/main/java/org/geotools/demo/xml/KMLExample.java which shows the KML bindings in use for writing. From other discussions on the user list it seems that the KML bindings work in a similar way to the GML bindings so look at http://docs.codehaus.org/display/GEOTDOC/GML+XML+Support for more clues. When you get a solution feel free to post it to the GeoTools wiki. |
|||
|