Constructor options for GeoJsonCodec.

Hierarchy

  • GeoJsonCodecConstructorOptions

Properties

encodeShapeListAsGeometryCollection?: boolean

The property defines how a LuciadRIA ShapeList instance should be encoded to the GeoJson format. By default, a LuciadRIA ShapeList instance is encoded to a specific GeoJson geometry, depending on its children:

  • if all children are Point instances -> MultiPoint
  • if all children are Polyline instances -> MultiLineString
  • if all children are ComplexPolygon instances -> MultiPolygons
  • otherwise -> GeometryCollection
Set the value to 'true' if you want to encode a LuciadRIA ShapeList always as a GeometryCollection.

Since

2022.0.1

generateIDs?: null | boolean

When true, the codec will always generate IDs during the decoding step for all the Features. When the Feature has already an ID, the existing ID will be replaced by a generated one. Feature IDs are provided by the GeoJsonCodecConstructorOptions.idProvider mechanism, or otherwise they are auto-generated by the internal ID generator.
When false, the codec will never generate IDs. The codec will throw an error whenever a Feature without ID is encountered.
When the flag is not set, or is set to null, the codec will generate IDs only for those Features that are without IDs.

idProvider?: FeatureIDProvider

Defines a custom callback function to provide IDs for decoded features that come without IDs. The mechanism takes into account the GeoJsonCodecConstructorOptions.generateIDs property. This callback is invoked by LuciadRIA with a decoded feature for which the ID should be returned. When the provided ID is invalid then the feature ID will be auto-generated.

Note: Having features in LuciadRIA with stable IDs that do not change on each query request is important for the performance sake. For example when features do not have intrinsic IDs on each query request then instead of adding/removing only relevant features, all the existing features are removed, and all the new ones are added.

// GeoJsonCodec will use IDs from a feature property.
const codec = new GeoJsonCodec({ idProvider: (feature: Feature) => feature.properties.id });

Since

2021.0

mode3D?: boolean

Setting this property to true will encode Shape instances as 3D GeoJSON geometry and decode GeoJSON geometries as 3D Shapes: if LuciadRIA Point instances have no z coordinate, 0 will be included as a third value in a GeoJSON position. if GeoJSON positions have a third value, it will be set as the z-coordinate in the LuciadRIA Point.

Default

false

Defines the CoordinateReference for Feature.shape when decoding GeoJSON data. It's crucial that the reference specified for your FeatureModel aligns with the reference for this codec. Note that setting this property does not perform any coordinate transformations. Instead, it takes the provided GeoJSON data and decodes it directly into features using the assigned reference.

Since

2022.0

swapAxes?: string[]

Indicates whether the codec should swap x and y axes for the specified reference identifier(s) when decoding or encoding features in the GeoJSON format. Normally axes should always be in x,y[,z] order when in GeoJSON, but not all servers follow this rule (depending on the reference system).