Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GMLCodec<TFeature>

A GMLCodec is responsible for decoding a GML document object into a set of LuciadRIA Feature objects containing LuciadRIA geometries and properties.

The codec decodes GML geometries to LuciadRIA shapes as follows:

  • 'Point' is mapped to a Point instance.
  • 'LineString' is mapped to a Polyline instance.
  • 'Polygon' and 'PolygonPatch' is mapped to a Polygon, if there is no interior 'Ring', or to a ComplexPolygon, if at least one interior 'Ring' is defined.
  • 'Curve' is mapped to a Polyline, Circle or a ShapeList, containing LuciadRIA Polyline and Circle instances.
  • 'Surface' is mapped to a ShapeList containing Polygon instances (if the GML geometry does not define the interior 'Ring'), and ComplexPolygon instances (if the GML geometry defines at least one interior 'Ring').
  • 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'MultiCurve' and 'MultiSurface' are all mapped to a ShapeList, containing LuciadRIA Point, Polyline, Polygon, ComplexPolygon or Circle instances.
  • Envelopes are mapped to Bounds.
The current implementation of GMLCodec is limited to the decoding of features containing the aforementioned geometry elements. Encoding is currently not supported.

A GMLCodec can be used in combination with a WFSFeatureStore to decode GML data directly from a WFS service.

  const storePromise = WFSFeatureStore.createFromURL("http://sampleservices.luciad.com/wfs", "usrivers", {
    codec: new GMLCodec(),
    outputFormat: "text/xml; subtype=gml/3.1.1"
  });

A GMLCodec can also be used to decode a file directly from a url, using a UrlStore:

  //Create a Store with a GeoJson codec to decode the data
  const store = new UrlStore({
    target: url,
    codec: new GMLCodec()
  });

  //Use the store to create a model
  const model = new FeatureModel(store);

  //Create a layer for the model
  const layer = new FeatureLayer(model);

  //Add the layer to the map
  map.layerTree.addChild(layer);

Spatial reference

The reference for shape decoding process is determined in the following way and order:

  • The reference passed to decode. Use it in case you want to override the reference for each decode request.
  • The reference passed to the constructor. Allows you to set the reference yourself, overriding what is in the data. If you still want to override for a particular decode() operation, you can still do it, because the step 1 allows it.
  • The reference specified in the data with the legacy crs field. This reference is used if you don't specify it in step 1 or 2.
  • The specification default WGS:84 reference is used.

Supported versions

LuciadRIA supports the GML 3.1 and GML 3.2 specifications, with the following limitations:

  • The files must adhere to the Simple Feature Level-0 profile.
  • It is assumed that all geometries use the same reference.
  • Envelopes are not decoded.

LuciadRIA supports the GML Circle (a circle defined by 3 points) and GML CircleByCenterPoint geometries, described in GML 3.2.1 specification. Circle geometries are interpolated to Polyline instances.

Type parameters

  • TFeature: Feature

    Represents the type of Feature instances that are decoded by the codec. Default type is Feature without restrictions on shape and properties.

Hierarchy

  • Codec<TFeature>
    • GMLCodec

Overview

Constructors

Methods

Constructors

constructor

  • Creates a GML codec. This codec has support for GML 3.1.1 and GML 3.2.1 with a simple feature profile level SF-0.

    Parameters

    Returns GMLCodec

Methods

decode

  • Decodes the server response, which is valid GML, to a Cursor of Feature instances.

    The ID of decoded feature is retrieved from the gml:id attribute. If the attribute does not exist, the ID is auto-generated using GMLCodecConstructorOptions.idProvider.

    A Store instance, used by a LuciadRIA feature layer, uses this method on each Store.query invocation, passing the options parameter containing the data to decode. If CodecDecodeOptions.reference option is present, the decoded features' shapes are encoded with this reference.

    Parameters

    Returns Cursor<TFeature>

    featureCursor a Cursor of Feature instances corresponding to the server response.

encode

  • (featureCursor: Cursor): { content: string; contentType: string }
  • Encoding is currently not supported. Calling this method will throw an error.

    Parameters

    Returns { content: string; contentType: string }

    • 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