I would check the test cases for additional examples and see what kind of data
they are working in.
I also recommend the GeoServer code base for straight up KML generation (the
code is GML but has more capabilities than what has been provided in GeoTools
here).
Q: KML supports <Data>, <SchemaData> and raw XML; what format are you expecting
the a and b to come out in?
--
Jody Garnett
On Monday, 23 January 2012 at 9:08 PM, Rainer Suddendorf wrote:
> Hi,
>
> I am trying to export features to KML for reuse in googleearth.
>
> The ID and the geometry is exported successfully, but the attributes "a"
> and "b" not.
>
> How can that be done?
>
> Thanks for Your support.
>
> Rainer
>
> public static void main(String[] args) throws IOException {
> SimpleFeatureTypeBuilder stb = new SimpleFeatureTypeBuilder();
> stb.setName("test");
> stb.add("the_geom", Point.class);
> stb.add("a", String.class);
> stb.add("b", String.class);
> SimpleFeatureType type = stb.buildFeatureType();
> SimpleFeatureBuilder sb = new SimpleFeatureBuilder(type);
> DefaultFeatureCollection fc = new
> DefaultFeatureCollection("test", type);
> GeometryFactory geomFac=new GeometryFactory();
> fc.add(sb.buildFeature("1", new Object[]
> {geomFac.createPoint(new Coordinate(1,1)), "a1", "b1" }));
> fc.add(sb.buildFeature("2", new Object[]
> {geomFac.createPoint(new Coordinate(2,2)), "a2", "b2" }));
>
> KMLConfiguration con = new KMLConfiguration();
>
> Encoder encoder = new Encoder(con);
> encoder.setIndenting(true);
> encoder.encode(fc, KML.kml, System.out);
> }
>
> --
> SDDB Consulting GmbH
> Wilhelm-Busch Str. 3
> 31832 Springe
>
> Phone +49 5045 962773
> Mobil +49 178 716 20 11
> Mail [email protected] (mailto:[email protected])
>
>
>
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> (mailto:[email protected])
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users