Creates a KML codec that can decode KML 2.3 strings.
an object literal that contains configuration settings for the codec.
Registers a callback function for the "KMLNetworkLink" event to process KMLNetworkLinkFeatures.
This event is fired by the cursor when it identifies a <NetworkLink>
element in
the document.
Always set to "KMLNetworkLink" for this event type.
The callback function to be executed when KMLNetworkLinkFeature objects are decoded by the KMLCodec.decode function.
The context in which the callback function should be invoked.
Registers a callback function for the "KMLTree" event. The callback function receives an array of KMLFeatures. This event is fired when the cursor has finished processing, and contains all of the previously processed and emitted nodes from that cursor.
Always set to "KMLTree" for this event type.
The callback function to be executed when the KMLCodec.decode function is called.
The context in which the function should be invoked.
Registers a callback function for the "KMLGroundOverlay" event, that allows a listener to process
KMLGroundOverlayFeatures. This event is triggered by the cursor whenever it identifies a
<GroundOverlay>
element in the document.
Always set to "KMLGroundOverlay" for this event type.
The callback function to be executed when the KMLCodec.decode function is called.
The context in which the function should be invoked.
Registers a callback function for the "KMLScreenOverlay" event, that allows a listener to process
KMLScreenOverlayFeatures. This event is triggered by the cursor whenever it identifies a
<ScreenOverlay>
element in the document.
Always set to "KMLScreenOverlay" for this event type.
The callback function to be executed when the KMLCodec.decode function is called.
The context in which the function should be invoked.
a handle to the registered callback with a single function 'remove'. This function can be used to unregister the callback function.
Registers a callback function for the "KMLFatalError" event, that allows a listener to process errors which cause the KMLCodec to abort operations.
Always set to "KMLFatalError" for this event type.
The callback function to be executed when the KMLCodec encounters a fatal error.
The context in which the function should be invoked.
Converts content from a string, ArrayBuffer, or Blob into a cursor of KMLPlacemarkFeatures KMLScreenOverlayFeatures and KMLGroundOverlayFeatures.
KML Network Link elements are emitted as KMLNetworkLinkFeature objects with the "KMLNetworkLink" event. KML Ground Overlay elements are emitted as KMLGroundOverlayFeature objects with the "KMLGroundOverlay" event. KML Screen overlay elements are emitted as KMLScreenOverlayFeature objects with the "KMLScreenOverlay" event.
The content to decode. Note that CodecDecodeOptions.reference will be ignored, as the KML specification stipulates that all KML coordinates should be interpreted using WGS 84. The CodecDecodeOptions.contentType is also unnecessary, and the codec will automatically determine whether the content is a KMZ that must be uncompressed before attempting to parse it. If the content is a KMZ file, then it will be uncompressed in memory and then parsed as a KML file.
This is not yet implemented and will throw a ProgrammingError if it is used.
Defines the Cursor of LuciadRIA KMLFeatures to be encoded.
The encoded version of the features.
Decodes KML and KMZ files (strings, ArrayBuffers, and Blobs) into a Cursor of KMLPlacemarkFeatures, KMLScreenOverlayFeatures and KMLGroundOverlayFeatures. Other features are emitted from events:
"KMLNetworkLink"
event. Network Links are separate KML Files that should be decoded separately in a new LuciadRIA model and layer (e.g. KMLModel and KMLLayer."KMLGroundOverlay"
event. Ground Overlays should be handled in a layer, cf createGroundOverlayLayer."KMLTree"
event. These features are used to represent the structure of the KML file, complete with the traversed KMLPlacemarkFeatures and previously-emitted KMLNetworkLinkFeatures, KMLScreenOverlayFeatures and KMLGroundOverlayFeatures. These "container" features are not rendered on the map, and are used to facilitate the creation of a GUI.A
KMLCodec
is typically used by a Store to decode strings into LuciadRIAKMLFeature
s. Consult the class documentation of theStore
class for more information.Styles are resolved according to the KML specification, as long as they are defined in the original KML file. Externally referenced styles are not resolved.
Supported versions
The current version of LuciadRIA supports the KML 2.3 standard.
Limitations
NOTE: This codec only handles well-formed, serialized KML documents and does not handle extensions to the KML Specification.
const codec = new KMLCodec(); const nlHandle = codec.on(KMLNetworkLinkEvent, (networkLink: KMLNetworkLinkFeature) => {}); const cursor = codec.decode({ content: "<kml>...</kml>" });
2020.1