Micromata.openkis.kml - 如何从kml解析gx:simplearraydata

时间:2016-04-26 13:32:26

标签: java parsing kml

即时使用micromata kml框架

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

我正在尝试解析以下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>

Xml有效。我的问题是我无法从文件中获取gx:simpleyArraydata。

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();

我使用框架错了吗?

任何帮助都会受到极大的重视。 感谢

0 个答案:

没有答案