Hi all, following the guide:
https://docs.geotools.org/latest/userguide/extension/xsd/kml.html
i successfully read using StreamParser the states.kml used in the example.
But when i tried to write the features read previously i got:
Exception in thread "main" java.lang.RuntimeException: Failed to get
property:














*{http://www.opengis.net/kml/2.2}styleUrl
<http://www.opengis.net/kml/2.2}styleUrl> at
org.geotools.xsd.impl.GetPropertyExecutor.visit(GetPropertyExecutor.java:102)
at
org.geotools.xsd.impl.BindingWalker$BindingExecutionChain.execute(BindingWalker.java:220)
at org.geotools.xsd.impl.BindingWalker.walk(BindingWalker.java:186) at
org.geotools.xsd.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:65)
at
org.geotools.xsd.impl.BindingVisitorDispatch.walk(BindingVisitorDispatch.java:45)
at
org.geotools.xsd.impl.BindingPropertyExtractor.properties(BindingPropertyExtractor.java:93)
at org.geotools.xsd.Encoder.encode(Encoder.java:987) at
org.geotools.xsd.Encoder.encode(Encoder.java:549) at
my.conversion.vector.streamWriters.KMLStreamWriter.writeFeatures(KMLStreamWriter.java:38)
at Example.main(Example.java:65)Caused by: java.lang.ClassCastException:
org.geotools.styling.FeatureTypeStyleImpl cannot be cast to java.net.URI at
org.geotools.kml.bindings.FeatureTypeBinding.getProperty(FeatureTypeBinding.java:299)
at
org.geotools.xsd.impl.GetPropertyExecutor.visit(GetPropertyExecutor.java:100)
... 9 more*
Looking at the code *org.geotools.kml.bindings.FeatureTypeBinding.java :299
*i noticed that the problem is:

if (KML.styleUrl.getLocalPart().equals(name.getLocalPart())) {
    URI uri = (URI) feature.getAttribute("Style");
    if (uri != null) {
        return styleMap.get(uri);
    }
}

The attribute "Style" is of type FeatureTypeStyle as described also in the
guide above, so why should be cast to URI? Is probably a bug and instead of
Style there should be "styleUrl".

Thanks
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to