Options
All
  • Public
  • Public/Protected
  • All
Menu

Decodes KML and KMZ files (strings, ArrayBuffers, and Blobs) into a Cursor of KMLPlacemarkFeatures. Other features are emitted from events:

A KMLCodec is typically used by a Store to decode strings into LuciadRIA KMLFeatures. Consult the class documentation of the Store 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.

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>" });
since

2020.1

Hierarchy

Implements

Overview

Constructors

Events

Methods

Constructors

constructor

  • Creates a KML codec that can decode KML 2.3 strings.

    since

    2020.1

    Parameters

    Returns KMLCodec

Events

on

  • (event: "KMLNetworkLink", callback: (networkLink: KMLNetworkLinkFeature) => void, context?: object, options?: object): Handle
  • (event: "KMLTree", callback: (rootArray: KMLFeature[]) => void, context?: object, options?: object): Handle
  • (event: "KMLGroundOverlay", callback: (groundOverlay: KMLGroundOverlayFeature) => void, context?: object, options?: object): Handle
  • 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.

    Parameters

    • event: "KMLNetworkLink"

      Always set to "KMLNetworkLink" for this event type.

    • callback: (networkLink: KMLNetworkLinkFeature) => void

      The callback function to be executed when KMLNetworkLinkFeature objects are decoded by the KMLCodec.decode function.

    • Optional context: object

      The context in which the callback function should be invoked.

    • Optional options: object

      Options that may influence the callback registration.

    Returns Handle

    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 "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.

    Parameters

    • event: "KMLTree"

      Always set to "KMLTree" for this event type.

    • callback: (rootArray: KMLFeature[]) => void

      The callback function to be executed when the KMLCodec.decode function is called.

    • Optional context: object

      The context in which the function should be invoked.

    • Optional options: object

      Options that may influence the callback registration.

    Returns Handle

    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 "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.

    Parameters

    • event: "KMLGroundOverlay"

      Always set to "KMLGroundOverlay" for this event type.

    • callback: (groundOverlay: KMLGroundOverlayFeature) => void

      The callback function to be executed when the KMLCodec.decode function is called.

    • Optional context: object

      The context in which the function should be invoked.

    • Optional options: object

      Options that may influence the callback registration.

    Returns Handle

    a handle to the registered callback with a single function 'remove'. This function can be used to unregister the callback function.

Methods

decode

  • Converts content from a string, ArrayBuffer, or Blob into a cursor of KMLPlacemarkFeatures.

    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.

    Supported versions

    The current version of LuciadRIA supports the KML 2.3 standard.

    Limitations

    • This KML Codec will only decode the following features:
      • Placemarks and internal styles
      • Shared Styles
      • NetworkLinks (references to other KML files)
      • KMZ files that consist of a single zipped KML-file; KML files that reference packaged resources are not currently supported.
      • GroundOverlays
    • Cross-Origin requests that do not contain an "Access-Control-Allow-Origin" header in the response can not be loaded.
    • Camera positions are not supported.
    • LOD regions are not supported.
    • TimeStamp and TimeSpan are not supported.
    • Collada models are not supported.
    • ScreenOverlays and PhotoOverlays are not supported.

    Parameters

    • options: CodecDecodeOptions

      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.

    Returns Cursor | Promise<Cursor>

encode

  • (cursor: Cursor): { content: string; contentType: string }
  • This is not yet implemented and will throw a ProgrammingError if it is used.

    Parameters

    Returns { content: string; contentType: string }

    The encoded version of the features.

    • content: string
    • contentType: string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method