Creates a GeoJSON codec. By default, a GeoJSON codec decodes 2D geometry, which means the z coordinates
of points (which usually contain height) are ignored. If the z coordinates must be encoded or decoded
as well, pass true
to the mode3D
property in the options
object.
Optional
options: GeoJsonCodecConstructorOptionsan object literal that contains configuration settings for the codec.
Decodes the server response, which is valid GeoJSON, into Feature instances. This method delegates to GeoJsonCodec.decodeGeometryObject.
A Store.query invocation, passing the options
parameter containing the data to decode.
If the CodecDecodeOptions.reference option is present, the decoded features' shapes are encoded with this reference.
the decoding options
featureCursor of Feature instances corresponding to the server response.
Decodes a GeoJSON geometry string into a Shape or null.
The string representation of a GeoJSON geometry.
The spatial reference in which the geometry
is defined.
The corresponding LuciadRIA Shape or null.
ProgrammingError If the input is not a valid GeoJSON geometry.
Decodes a GeoJSON geometry object into a Shape or null.
A GeoJSON geometry object, represented as a JSON object.
The spatial reference in which the geometry
is defined.
The corresponding LuciadRIA Shape or null.
ProgrammingError If the input is not a valid GeoJSON geometry object.
Decodes a valid GeoJSON object into a Cursor.
a GeoJSON object to be decoded
Optional
options: DecodeObjectOptionsan options object literal
featureCursor A Cursor corresponding to the decoded GeoJSON object.
Encodes Feature instances into GeoJSON. This method delegates to GeoJsonCodec.encodeShape.
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
".Encodes a LuciadRIA Shape into a valid GeoJSON geometry.
the GeoJSON representation of the shape (as an object, not as a string)
A GeoJsonCodec is responsible for main tasks:
Encoding Feature instances into a JavaScript object that adheres to the GeoJSON specification The codec encodes the shape of the feature to GeoJSON geometries as follows:
Otherwise ShapeList is mapped based on its contents:
Decoding a GeoJSON JavaScript object into a set of LuciadRIA Feature instances, each containing corresponding LuciadRIA geometries and properties.
Since there's no direct mapping from a GeoJSON geometry to a LuciadRIA shape, the codec decodes GeoJSON geometries as follows:
null
geometry translates into a Feature with a null shape.Note: According to the GeoJSON specification, the first and last position of a GeoJSON polygon must be equivalent. The codec removes this duplicate point when decoding the GeoJSON polygon to a LuciadRIA geometry.
Spatial reference
The reference used during the shape decoding process is determined in the following order:
crs
field. This will be used if no reference is provided in either of the first two steps.Limitations
GeoJSON does not support any other shapes than
Point
,LineString
,Polygon
,MultiPoint
,MultiLineString
,MultiPolygon
,GeometryCollection
. Therefore, it cannot support all LuciadRIA shapes. For instance, a Circle cannot be directly represented as a circle in GeoJSON. Handling such shapes requires a custom codec, as demonstrated in the CreateEdit sample.