Micromata.openkis.kml - How to parse gx:simplearraydata from kml

65 views
Skip to first unread message

Lukas Pfeffer

unread,
Apr 27, 2016, 7:20:31 AM4/27/16
to Java API for KML

im using the micromata kml framework


    <dependency>
        <groupId>de.micromata.jak</groupId>
        <artifactId>JavaAPIforKml</artifactId>
        <version>2.2.1</version>
    </dependency> 

and am trying to parse the following xml:


<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/kml/ext/2.2 https://developers.google.com/kml/schema/kml22gx.xsd">
    <Document>
        <name>2016-04-26T09:01:45Z</name>
        <Placemark>
            <gx:Track>
                <when>2016-04-26T09:01:45Z</when>
                <when>2016-04-26T09:03:58Z</when>
                <when>2016-04-26T09:04:28Z</when>
                <gx:coord>16.368757104501128 48.20182682946324 251.20000000000005</gx:coord>                
                <gx:coord>16.367655051872134 48.20342261809856 180.39999999999998</gx:coord>
                <gx:coord>16.36813810095191 48.203140273690224 174.60000000000002</gx:coord>
                <ExtendedData>
                    <SchemaData schemaUrl="#schema">
                        <gx:SimpleArrayData name="Accuracy">
                            <gx:value>15.0</gx:value>
                            <gx:value>22.0</gx:value>
                            <gx:value>15.0</gx:value>
                        </gx:SimpleArrayData>
                        <gx:SimpleArrayData name="Velocity">
                            <gx:value>0.375</gx:value>
                            <gx:value>0.5</gx:value>
                            <gx:value>2.375</gx:value>
                        </gx:SimpleArrayData>
                    </SchemaData>
                </ExtendedData>
            </gx:Track>
        </Placemark>
    </Document>
</kml>

The Xml is valid. My problem is that i cant get gx:simpleyArraydata out of the file.


Kml kml = Kml.unmarshal(file)
Document doc = (Document) kml.getFeature();
Placemark dfP = (Placemark) doc.getFeature().get(0);
Track t = (Track) dfP.getGeometry();
//works
List<String> whens = t.getWhen(); 
//works
List<String> coords = t.getCoord(); 
//does not work, is always empty
List<Object> simpleArrayData = t.getSchemaData().get(0).getSchemaDataExtension();

Do i use the Framework wrong?

Any help is greatly aprreciated. Thanks

Reply all
Reply to author
Forward
0 new messages