LuciadCPillar C# 2026.1.02
Loading...
Searching...
No Matches
Luciad.Formats.Geojson.GeoJsonModelDecoder Class Reference

This class can be used to decode GeoJSON data into an IFeatureModel. More...

Static Public Member Functions

static Luciad.Models.Features.IFeatureModel Decode (string source)
 Creates a GeoJSON feature model, or returns information about why this model cannot be created.
static Luciad.Models.Features.IFeatureModel Decode (string source, Luciad.Formats.Geojson.GeoJsonModelDecoderOptions options)
 Creates a GeoJSON feature model, or returns information about why this model cannot be created.

Detailed Description

This class can be used to decode GeoJSON data into an IFeatureModel.

Supports RFC 7946 GeoJSON and the legacy 2008 GeoJSON specification for CRS handling.

Supported file extensions

ExtensionDescription
*.geojsonGeoJSON file
*.jsonGeoJSON or other JSON
*.jsGeoJSON as JavaScript

Supported root types

Root typeResult
FeatureCollectionAll features decoded
FeatureSingle-feature collection
Geometry typeFeature collection with one synthetic Feature

Supported geometries

GeoJSON geometry typeCPillar geometry
PointPoint
MultiPointMultiGeometry of Points
LineStringPolyline
MultiLineStringMultiGeometry of Polylines
PolygonPolygon (exterior ring + optional holes)
MultiPolygonMultiGeometry of Polygons
GeometryCollectionMultiGeometry (heterogeneous, recursive)
missingFeature without geometry

@javalink Luciad.Models.Features.Feature Feature} properties

Each JSON property value is decoded into a DataProperty, with a type that is inferred from the value:

JSON property valueDecoded as
Stringa string property
Integer numbera long property
Fractional numbera double property
Booleana boolean property
nullthe property is left unset for that feature
Array of primitive valuesa list property, with an element type inferred like a scalar
Array of objectsa list property with an element type is a composite
Objecta composite property with a type that mirrors the object

The feature DataType is the union of the properties seen across all features. The rest of this section covers how the decoder combines a property's values across features, and what it does with a value that it cannot model as a typed property.

Combining mixed value types

When a property holds different value types in different features, they are combined into a single type. The same rule combines a list's element type, both within a single array and across features. A null is ignored while combining, and a null array element is kept as an empty entry so element positions are preserved.

Values seen for a propertyCombined type
42 then "high"string
1 (integer) then 1.5 (fractional)double
a boolean then a numberstring
list [1] then list [1.5]double list
[1, "two", true] in one arraystring list

Combining applies only while the value keeps the same shape: scalar, list, or composite object.

Values preserved as raw JSON

A value that fits no typed property is preserved losslessly as a string property holding its raw JSON text, tagged with JsonDataAnnotation so a consumer can tell it apart from a plain string:

Value the decoder cannot modelExample
incompatible shapes in different features42 in one feature, {"nested": 1} in another
a list mixing primitive and object elements[1, 2] in one feature, [{"a": 1}] in another
an array with elements that are themselves arrays[[1, 2], [3, 4]]
a list empty or all-null in every feature[] in every feature
an object with no modelable members{}, or members that are all null

A property that is null in every feature carries no value and is left out of the schema entirely. This differs from the empty-list case above, which is preserved as raw JSON.

Nested objects

A property with a value that is a JSON object becomes a composite property. The decoder infers a nested DataType from the object's members, unioned across features and applied recursively to objects within objects. Each nested type is named after the path that leads to it, joining the feature type name and the field names with underscores: an "address" object yields Feature_address, and a "location" object nested inside it yields Feature_address_location. An array of objects becomes a list property of which the element type is that composite, built with the same naming and recursion. The raw-JSON fallback applies per member, so a modelable member stays typed while an unmodelable sibling beside it is preserved as raw JSON.

Special property names

A top-level id member becomes a string property named "id". A property named "geometry" is skipped because it conflicts with the reserved geometry property.

CRS handling

When no legacy "crs" member is present, the decoder falls back to a user-supplied default model reference, which you can set through GeoJsonModelDecoderOptions.Builder.DefaultModelReference. If none is set, the decoder falls back to WGS 84 (EPSG:4326 for 2D data, EPSG:4979 for 3D data). When a legacy "crs" member is present, its named CRS identifier is resolved through CoordinateReferenceProvider, and any user-supplied default is ignored.

Since
2026.1
See also
GeoJsonModelDecoder.Decode for more details.

Member Function Documentation

◆ Decode() [1/2]

Luciad.Models.Features.IFeatureModel Luciad.Formats.Geojson.GeoJsonModelDecoder.Decode ( string source)
inlinestatic

Creates a GeoJSON feature model, or returns information about why this model cannot be created.

This is a convenience overload equivalent to calling decode(source, GeoJsonModelDecoderOptions.newBuilder().build()).

Parameters
sourceThe path, URL, or logical identifier for the GeoJSON data.
Returns
the newly created feature model.
Exceptions
System.IO.IOExceptionwhen creation of the model fails.
System.NotSupportedExceptionwhen the source cannot be handled (for example, an unsupported scheme or root type).

◆ Decode() [2/2]

Luciad.Models.Features.IFeatureModel Luciad.Formats.Geojson.GeoJsonModelDecoder.Decode ( string source,
Luciad.Formats.Geojson.GeoJsonModelDecoderOptions options )
inlinestatic

Creates a GeoJSON feature model, or returns information about why this model cannot be created.

When the GeoJsonModelDecoderOptions contain a dataLoader, the decoder first attempts to resolve the source string through that loader. If the loader returns ErrorCode.Unsupported, the decoder falls back to file-based or URL-based loading. All other loader errors are propagated.

Parameters
sourceThe path, URL, or logical identifier for the GeoJSON data.
optionsOptions controlling how the source is resolved.
Returns
the newly created feature model.
Exceptions
System.IO.IOExceptionwhen creation of the model fails.
System.NotSupportedExceptionwhen the source cannot be handled (for example, an unsupported scheme or root type).
Since
2026.1