Skip to content

Native KML altitude modes unsupported #8

@swiss-knight

Description

@swiss-knight

I'm not able to validate this in Python 3.6.9 / Ubuntu 18.04 (pykml 0.2.0 installed from pip):

from lxml import etree
from pykml import parser
from pykml.parser import Schema
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import GX_ElementMaker as GX

kml = KML.kml(
    KML.Document(
        KML.Placemark(
            KML.name('my marker'),
            KML.Camera(
                KML.longitude(7.5),
                KML.latitude(30.2),
                KML.altitude(202.5),
                KML.heading(10.),
                KML.tilt(92.0),
                KML.roll(0.0),
                KML.altitudeMode('absolute'),
            )
        )
    )
)
kml_string = etree.tostring(kml)

 # validation:
schema_gx = Schema("kml22gx.xsd")
parser.fromstring(kml_string, schema_gx)

It raises this error:

XMLSyntaxError: Element '{http://www.google.com/kml/ext/2.2}altitudeMode': [facet 'enumeration'] The value 'absolute' is not an element of the set {'clampToSeaFloor', 'relativeToSeaFloor'}.

But according to: https://developers.google.com/kml/documentation/altitudemode#absolute

<altitudeMode>absolute</altitudeMode> seems valid.

And here https://developers.google.com/kml/documentation/cameras, you can read:

<!-- kml:altitudeModeEnum: clampToGround, relativeToGround, absolute --> 
<!-- or, gx:altitudeMode can be substituted: clampToSeaFloor, relativeToSeaFloor -->

so it seems that even if I'm using KML.altitudeMode it falls back on GX.altitudeMode which allow for these complementary altitude modes (clampToSeaFloor and relativeToSeaFloor).

So clampToGround, relativeToGround and absolute should be accepted in the KML altitudeMode namespace.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions