There are some KML classes you can look into; it is one of the the xsd-kml
modules has the details.
- http://svn.osgeo.org/geotools/trunk/modules/extension/xsd/xsd-kml/
They uses the same tech base as the GML parsing code ... I really recommend
looking at the test cases
for running examples; and then please report back to the email list with your
findings :-)
To start with here is a test case:
-
http://svn.osgeo.org/geotools/trunk/modules/extension/xsd/xsd-kml/src/test/java/org/geotools/kml/KMLParsingTest.java
StreamingParser parser = new StreamingParser(new KMLConfiguration(),
getClass().getResourceAsStream("states.kml"), KML.Placemark);
int count = 0;
SimpleFeature f = null;
while ((f = (SimpleFeature) parser.parse()) != null) {
FeatureTypeStyle style = (FeatureTypeStyle) f.getAttribute("Style");
assertNotNull(style);
Symbolizer[] syms = style.getRules()[0].getSymbolizers();
assertEquals(3, syms.length);
count++;
}
assertEquals(49, count);
And output:
Encoder encoder = new Encoder(new KMLConfiguration());
encoder.setIndenting(true);
ByteArrayOutputStream out = new ByteArrayOutputStream();
encoder.encode(features, KML.kml, out );
System.out.println( new String( out.toByteArray() ));
There is also a "literate" api for KML which is the work of a masters student.
- http://code.google.com/p/kmlframework/
Jody
On 02/07/2010, at 8:41 PM, LSA wrote:
> Hello everyone,
>
> How can I convert features of shapefile to KML format? Are there special
> classes for this purpose in geotools?
>
> Thanks
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users