Creates a GML codec. This codec has support for the GML 3.1.1 and GML 3.2.1 with a simple feature profile level SF-0.
Optionaloptions: GMLCodecConstructorOptions
an object literal that contains configuration settings for the codec.
ReadonlyhandleSpecifies 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);
}
Decodes the server response with valid GML into Feature instances.
The ID of each decoded feature is retrieved from the gml:id attribute.
If this attribute is not present, the ID is automatically generated using
GMLCodecConstructorOptions.idProvider.
This method is invoked as part of a Store.query call, with the options parameter containing the data to decode.
If the CodecDecodeOptions.reference option is provided, the decoded feature shapes are created using that reference.
the decoding options
a Cursor of Feature instances corresponding to the server response
Encodes all features from the cursor into a GML 3.2 gml:FeatureCollection.
the features to encode
Optionaloptions: GMLEncodeOptions
controls the feature element and geometry property names
encoded GML 3.2 content with contentType "application/gml+xml; version=3.2"
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:
Pointis mapped to a Point.LineStringis mapped to a Polyline.LinearRingis mapped to a Polygon.PolygonandPolygonPatchare mapped to a Polygon if no interiorRingis defined, or to a ComplexPolygon, if at least one interiorRingis present.Curveis mapped to a Polyline, Arc, Circle, or a ShapeList if multiple curve segments are defined.Surfaceis mapped to Polygon instances (if the GML geometry does not define the interiorRing), and ComplexPolygon instances (if the GML geometry defines at least one interiorRing).MultiPoint,MultiLineString,MultiPolygon,MultiCurveandMultiSurfaceare mapped to ShapeList instances containing the corresponding decoded shapes.Circles defined by
CircleorCircleByCenterPointare represented as Circle shapes. Arc segments defined byArcByCenterPointare 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.
Encoding
encode produces a
gml:FeatureCollectionstring suitable for standalone GML export.Supported geometry types are:
Point,Polyline,Polygon,ComplexPolygon,Circle(circular),Arc(circular), andShapeList. Other shape types, including ellipticalArcinstances, throw aProgrammingError. GML 3.2ArcByCenterPointsupports circular arcs only. Array and object property values are stringified without a defined format.A GMLCodec can also be used to decode a file directly from a url, using a UrlStore:
Spatial reference
The reference used for the shape decoding process is determined in the following order:
decode()request.decode()call, as described in the previous step.crsfield. This is used if no reference is provided in the previous steps.Arc interpretation
When a
CurvecontainsArcByCenterPointsegments, the arc direction can be controlled via thecurveArcInterpretationoption. See CurveArcInterpretation for the available modes and their semantics.Supported versions
LuciadRIA supports the GML 3.1 and GML 3.2 specifications, with the following characteristics:
Circle,CircleByCenterPoint, andArcByCenterPoint.