Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KML file produced by amateur/telemetry endpoint appears to be partly invalid #151

Open
darksidelemm opened this issue Dec 31, 2024 · 2 comments

Comments

@darksidelemm
Copy link
Member

Grab KML file from here: https://api.v2.sondehub.org/amateur/telemetry/VE3SVF?format=kml&datetime=1735671880&last=9420

Visit https://earth.google.com/ and attempt to load in KML file.
It will give an error: "The document cannot be parsed due to a formatting error. Please double check the file structure and try again"
The same file loads ok in the Google Earth application, but that application is known to be quite tolerant of parsing issues.

It'd be good to find out what in particular is incorrect in the file.

@darksidelemm
Copy link
Member Author

Had a go at using XmlValidate - https://github.com/docjason/XmlValidate

~/XmlValidate$ java -classpath "build/libs/*" org.mitre.xml.validate.XmlValidate -kml -home=. -map=./ns.map VE3SVF.kml 

Check: VE3SVF.kml
http://www.opengis.net/kml/2.2
ERROR: SAXParseException org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 21; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.opengis.net/kml/2.2":visibility}'. One of '{"http://www.opengis.net/kml/2.2":AbstractViewGroup, "http://www.opengis.net/kml/2.2":AbstractTimePrimitiveGroup, "http://www.opengis.net/kml/2.2":styleUrl, "http://www.opengis.net/kml/2.2":AbstractStyleSelectorGroup, "http://www.opengis.net/kml/2.2":Region, "http://www.opengis.net/kml/2.2":Metadata, "http://www.opengis.net/kml/2.2":ExtendedData, "http://www.opengis.net/kml/2.2":AbstractFeatureSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractFeatureObjectExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractContainerSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractContainerObjectExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractFeatureGroup, "http://www.opengis.net/kml/2.2":FolderSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":FolderObjectExtensionGroup}' is expected.
Line: 7, column: 21
7: <kml:visibility>***1</kml:visibility>
ERROR: SAXParseException org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 21; cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://www.opengis.net/kml/2.2":visibility}'. One of '{"http://www.opengis.net/kml/2.2":AbstractViewGroup, "http://www.opengis.net/kml/2.2":AbstractTimePrimitiveGroup, "http://www.opengis.net/kml/2.2":styleUrl, "http://www.opengis.net/kml/2.2":AbstractStyleSelectorGroup, "http://www.opengis.net/kml/2.2":Region, "http://www.opengis.net/kml/2.2":Metadata, "http://www.opengis.net/kml/2.2":ExtendedData, "http://www.opengis.net/kml/2.2":AbstractFeatureSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractFeatureObjectExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractContainerSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractContainerObjectExtensionGroup, "http://www.opengis.net/kml/2.2":AbstractFeatureGroup, "http://www.opengis.net/kml/2.2":FolderSimpleExtensionGroup, "http://www.opengis.net/kml/2.2":FolderObjectExtensionGroup}' is expected.
Line: 7, column: 21
ERROR: SAXParseException org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 40; cvc-datatype-valid.1.2.1: 'Flight Path ID' is not a valid value for 'NCName'.
Line: 8, column: 40
8: <kml:Placemark id="Flight Path ID">***
ERROR: SAXParseException org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 40; cvc-attribute.3: The value 'Flight Path ID' of attribute 'id' on element 'kml:Placemark' is not valid with respect to its type, 'ID'.
Line: 8, column: 40
ERROR: SAXParseException org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 40; cvc-datatype-valid.1.2.1: 'Flight Path ID' is not a valid value for 'NCName'.
Line: 8, column: 40
ERROR: SAXParseException org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 40; cvc-attribute.3: The value 'Flight Path ID' of attribute 'id' on element 'kml:Placemark' is not valid with respect to its type, 'ID'.
Line: 8, column: 40

Errors: 6  Warnings: 0  Files: 1  Time: 331 ms
Valid files 0/1 (0%)

@TheSkorm
Copy link
Member

TheSkorm commented Jan 4, 2025

<?xml version="1.0" encoding="UTF-8"?><!-- addition of this line -->
<kml xmlns:kml="http://www.opengis.net/kml/2.2"><!-- create a new wrap element kml -->
    <Document> <!-- remove all the kml: -->
        <Folder id="VE3SVF"> <!-- this shouldn't have spaces of symbols in the id -->
            <name>2024-12-31T16:27:40 VE3SVF</name>
            <description>Flight Path</description>
            <Placemark id="FlightPathID">
                <name>2024-12-31T16:27:40 VE3SVF</name>
                <visibility>1</visibility>
                <Style>
                    <LineStyle>
                        <color>aaffffff</color>
                        <width>2.0</width>
                    </LineStyle>
                    <PolyStyle>
                        <color>20000000</color>
                        <fill>1</fill>
                        <outline>1</outline>
                    </PolyStyle>
                </Style>
                <LineString>
                    <extrude>1</extrude>
                    <altitudeMode>absolute</altitudeMode>
                    <coordinates>
                         -79.521248,43.669426,93.0
....
                    </coordinates>
                </LineString>
            </Placemark>
        </Folder>
    </Document>
</kml>    
mwheeler@foxbook XmlValidate % java -jar ./build/libs/XmlValidate-1.0.2.jar -schema=./schemas/kml22.xsd -ns=http://www.opengis.net/kml/2.2 -kml /Users/mwheeler/Downloads/fix.kml   

Errors: 0  Warnings: 0  Files: 1  Time: 273 ms
Valid files 1/1 (100%)
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants