Hi Lorenzo,
XSD modules can be pretty asymmetric, some can parse but not encode, others
do both but with significantly different success rate.

I believe gt-xsd-kml might be of the latter type... nothing else is using
it in GeoTools,
in GeoServer the only supported module using it is the importer, which only
uses
the read (parse) side of it.

There is also an unsupported kmlppio module that can encode KML, but... I
believe
it has not received usage in ages.

Long story short... fixes welcomed.

Cheers
Andrea

On Mon, Feb 21, 2022 at 3:46 PM Lorenzo Di Giacomo <loridi...@gmail.com>
wrote:

> 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%7DstyleUrl> 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
>


-- 

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts!

Visit http://bit.ly/gs-services-us for more information.
==

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions Group
phone: +39 0584 962313

fax:     +39 0584 1660272

mob:   +39  333 8128928

https://www.geosolutionsgroup.com/

http://twitter.com/geosolutions_it

-------------------------------------------------------

Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE
2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si
precisa che ogni circostanza inerente alla presente email (il suo
contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è
riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il
messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra
operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is
addressed and may contain information that is privileged, confidential or
otherwise protected from disclosure. We remind that - as provided by
European Regulation 2016/679 “GDPR” - copying, dissemination or use of this
e-mail or the information herein by anyone other than the intended
recipient is prohibited. If you have received this email by mistake, please
notify us immediately by telephone or e-mail
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to