LuciadRIA (2026.1.02)
    Preparing search index...

    Class GMLCodec<TFeature>

    A GMLCodec decodes a GML document object into a set of LuciadRIA Feature objects containing LuciadRIA geometries and properties, and encodes Feature objects back to GML 3.2.

    The codec decodes GML geometries to LuciadRIA shapes as follows:

    • Point is mapped to a Point.
    • LineString is mapped to a Polyline.
    • LinearRing is mapped to a Polygon.
    • Polygon and PolygonPatch are mapped to a Polygon if no interior Ring is defined, or to a ComplexPolygon, if at least one interior Ring is present.
    • Curve is mapped to a Polyline, Arc, Circle, or a ShapeList if multiple curve segments are defined.
    • Surface is mapped to 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 mapped to ShapeList instances containing the corresponding decoded shapes.

    Circles defined by Circle or CircleByCenterPoint are represented as Circle shapes. Arc segments defined by ArcByCenterPoint are represented as Arc shapes. Circle and Arc geometries are interpolated only when processing curves as part of polygon ring construction.

    The current implementation of GMLCodec supports both decoding and encoding of features containing the aforementioned geometry elements.

    encode produces a gml:FeatureCollection string suitable for standalone GML export.

    Supported geometry types are: Point, Polyline, Polygon, ComplexPolygon, Circle (circular), Arc (circular), and ShapeList. Other shape types, including elliptical Arc instances, throw a ProgrammingError. GML 3.2 ArcByCenterPoint supports circular arcs only. Array and object property values are stringified without a defined format.

      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 GML 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);

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

    • The reference passed to decode. Use this if you want to override the reference for a specific decode() request.
    • The reference passed to the constructor. This allows you to explicitly set a reference, overriding any reference specified in the data. You can still override it for a particular decode() call, as described in the previous step.
    • The reference specified in the data with the legacy crs field. This is used if no reference is provided in the previous steps.
    • If none of the above are specified, the specification’s default WGS 84 reference is used.

    When a Curve contains ArcByCenterPoint segments, the arc direction can be controlled via the curveArcInterpretation option. See CurveArcInterpretation for the available modes and their semantics.

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

    • The files must adhere to the Simple Feature Level-0 profile. In addition, selected curve segment types are supported: Circle, CircleByCenterPoint, and ArcByCenterPoint.
    • All geometries are assumed to use the same reference.
    • Envelopes are not decoded.

    Type Parameters

    • TFeature extends Feature = Feature

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

    Hierarchy (View Summary)

    Constructors

    Properties

    Methods

    handleAs: "string"

    Specifies how stores should read the response body before passing it to decode. All RIA stores support this option and use its value automatically. Codecs for binary formats should override it to arraybuffer.

    • string - passes a string primitive. This is the default and fallback value.
    • arraybuffer - passes an ArrayBuffer object.
    • blob - passes a raw Blob object.
    • json - parses the content into a JavaScript object.
    class ProtobufCodec extends Codec {
    // Advertise to stores that the response body should be delivered as an ArrayBuffer.
    override readonly handleAs = "arraybuffer" as const;

    decode({content}: CodecDecodeOptions): Cursor<Feature> {
    const buffer = content as ArrayBuffer;
    const features: Feature[] = [];
    // ... parse buffer and populate features
    return new ArrayCursor(features);
    }

    2026.1