Hi Robert and welcome to GeoTools.

> I am a newbie to geotools, so appreciate any support.  Does anybody have any
> code examples that can programmatically create WKT strings from iterating a
> FeatureCollection?

Here's one way to do it...

    public void getWKT(FeatureCollection<SimpleFeatureType,
SimpleFeature> collection)
            throws IOException {
        FeatureVisitor visitor = new FeatureVisitor() {

            WKTWriter writer = new WKTWriter();

            public void visit(Feature feature) {
                Geometry geom = (Geometry)
feature.getDefaultGeometryProperty().getValue();
                String wkt = writer.writeFormatted(geom);
                System.out.println(wkt);
            }
        };

        collection.accepts(visitor, null);
    }


Michael

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to