Thanks Jody!

Saving the KML or executing in a debugger I can see that the
application generates correctly the first placemark an writes it,
generates the second one and throws an error before write it. And the
application stops.

About Geoserver, from XML Geotools FAQ, I know that it works with "XML
Transform" and I want to work with "GeoTools XML (GTXML)" because it
makes possible "streaming content for MASSIVE content like feature
collections".

It's maybe a Geotools bug? I think the application is really simple.


Thanks.

On Fri, Jul 22, 2011 at 13:59, Jody Garnett <[email protected]> wrote:
> Not sure; did you try saving the KML and looking at it? Perhaps compare it
> to the KML in the geotools test cases.
> There is every chance that geoserver supports more interesting KML that that
> handled by GeoTools. KML is pretty whacky and can do a lot of stuff. Perhaps
> I should of said flexible...
> --
> Jody Garnett
>
> On Friday, 22 July 2011 at 7:13 PM, Eduardo Riesco wrote:
>
> Any ideas on this? It's a Geotools bug?
>
> Thanks
>
>
> On Tue, Jul 19, 2011 at 11:11, Eduardo Riesco <[email protected]>
> wrote:
>
> Hi community,
>
> I'm trying to encode some KML and I'm getting an error. I don't understand
> why. This is the error:
>
> Exception in thread "main" java.lang.NullPointerException
>     at
> org.geotools.xml.impl.SchemaIndexImpl.destroy(SchemaIndexImpl.java:100)
>     at org.geotools.xml.Encoder.encode(Encoder.java:1026)
>     at org.geotools.xml.Encoder.encode(Encoder.java:566)
>     at xsdtest.main(xsdtest.java:44)
>
>
> An this is my code:
>
> import java.io.ByteArrayOutputStream;
> import java.util.HashMap;
> import java.util.Map;
> import org.geotools.data.DataStoreFinder;
> import org.geotools.data.DataStore;
> import org.geotools.data.simple.SimpleFeatureIterator;
> import org.geotools.data.simple.SimpleFeatureSource;
> import org.geotools.data.simple.SimpleFeatureCollection;
> import org.geotools.kml.KML;
> import org.geotools.kml.KMLConfiguration;
> import org.geotools.xml.Encoder;
> import org.opengis.feature.simple.SimpleFeature;
>
> public class xsdtest {
>
>     public static void main(String[] args) throws Exception {
>
>         DataStore dataStore;
>         String server =
> "http://www.sogis1.so.ch:8080/geoserver/ows?service=WFS&request=GetCapabilities";;
>         String layer = "topp:states"; // Feature TypeName
>
>         Map<String, Object> connectionParameters = new HashMap<String,
> Object>();
>         connectionParameters.put("WFSDataStoreFactory:GET_CAPABILITIES_URL",
> server);
>         dataStore = DataStoreFinder.getDataStore(connectionParameters);
>
>         SimpleFeatureSource featureSource =
> dataStore.getFeatureSource(layer);
>         SimpleFeatureCollection featureCollection =
> featureSource.getFeatures();
>         SimpleFeatureIterator featuresIterator =
> featureCollection.features();
>
>         Encoder encoder = new Encoder(new KMLConfiguration());
>         ByteArrayOutputStream out = new ByteArrayOutputStream();
>
>         while (featuresIterator.hasNext()) {
>             SimpleFeature feature = featuresIterator.next();
>             encoder.encode(feature, KML.Placemark, out);
>             String kmlString = new String(out.toByteArray());
>             System.out.println(kmlString);
>         }
>     }
> }
>
>
>
> What I'm doing wrong? Any ideas?
> Thank you very much.
>
> Edu.
>
> ------------------------------------------------------------------------------
> 10 Tips for Better Web Security
> Learn 10 ways to better secure your business today. Topics covered include:
> Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
> security Microsoft Exchange, secure Instant Messaging, and much more.
> http://www.accelacomm.com/jaw/sfnl/114/51426210/
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>

------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to