Options
All
  • Public
  • Public/Protected
  • All
Menu

A GeoJsonCodec is responsible for 2 things:

  • encode a Feature instance to a JavaScript object that adheres to the GeoJSON specification
  • decode a GeoJSON JavaScript object to a Feature.

    Since a 1-on-1 mapping from a GeoJSON geometry to a LuciadRIA shape does not exist, the codec decodes GeoJSON geometries to shapes as follows:

    The codec encodes the shape of the feature to GeoJSON geometries as follows:

    • Point and Polyline instances are mapped to GeoJSON Points and LineStrings respectively.
    • Polygon and ComplexPolygon instances are all mapped to GeoJSON Polygons.
    • ShapeList that consist solely of Point or Polyline instances are mapped to MultiPoint and MultiLineString geometries respectively.
    • ShapeList that consist of a mix of Polygon and ComplexPolygon instances are mapped to GeoJSON MultiPolygons.
    • ShapeList that contain an arbitrary mix of shapes are mapped to GeoJSON GeometryCollections.

    GeoJSON does not support any other shapes than Point, Linestring, Polygon, MultiPoint, MultiLinestring, MultiPolygon, GeometryCollection. As such, it cannot support all shapes of LuciadRIA. For example, a Circle cannot be represented directly as a circle in GeoJSON. To deal with such shapes, a custom codec is required. The CreateEdit sample shows how you can create a custom codec for such shapes.

Supported versions

LuciadRIA supports the full feature set of GeoJSON with the following limitations:

  • CRS reference annotations are not supported.

Hierarchy

Overview

Constructors

constructor

  • Creates a GeoJSON codec. By default, a GeoJSON Codec decodes 2D geometry which means the z coordinates of points (which usually contains height) is ignored. If the z coordinate must be encoded or decoded as well, pass true to the mode3D property in the options object.

    Parameters

    Returns GeoJsonCodec

Methods

decode

  • Decodes the server response - which is valid GeoJSON - to a Cursor of Feature instances. This method delegates to decodeGeometryObject.

    Parameters

    Returns Cursor

    featureCursor A Cursor of Features corresponding to the server response.

decodeGeometry

  • Decodes a GeoJSON geometry string to a Shape.

    Parameters

    • geometry: string

      The string representation of a shape. The codec assumes this string adheres to the GeoJSON specification

    • reference: CoordinateReference

      The spatial reference in which the Geometry is defined.

    Returns Shape

    the corresponding LuciadRIA Shape.

decodeGeometryObject

  • Decodes a GeoJSON geometry object to a Shape.

    Parameters

    • geometry: object

      A GeoJSON object, as a JSON object.

    • reference: CoordinateReference

      The spatial reference in which the Geometry is defined.

    Returns Shape

    the corresponding LuciadRIA Shape.

decodeObject

  • Decodes an object - which is valid GeoJSON - to a Cursor of Feature instances. This method delegates to decodeGeometryObject.

    Parameters

    Returns Cursor

    featureCursor A Cursor of Features corresponding to the server response.

encode

  • (featureCursor: Cursor): { content: string; contentType: string }
  • Encodes a Cursor of Feature instances into GeoJSON. This method delegates to encodeShape.

    Parameters

    • featureCursor: Cursor

      a Cursor of LuciadRIA Features which must be encoded to the arbitrary representation

    Returns { content: string; contentType: string }

    An object containing two properties:

    • content: the encoded content as a String. This is valid GeoJSON
    • contentType: the mime type as a String. It equals "application/json"
    • content: string

      The encoded content as a String

    • contentType: string

      The mime type describing how the content was encoded as a String

encodeShape

  • (shape: Shape): object | null
  • Encodes a LuciadRIA Shape to a valid GeoJSON geometry.

    Parameters

    • shape: Shape

      A Shape to be encoded to GeoJSON.

    Returns object | null

    the GeoJSON representation of a shape (as an object, not as a 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