Class GeoJsonModelDecoder

java.lang.Object
com.luciad.formats.geojson.GeoJsonModelDecoder

public final class GeoJsonModelDecoder extends Object
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

Extension Description
*.geojson GeoJSON file
*.json GeoJSON or other JSON
*.js GeoJSON as JavaScript

Supported root types

Root type Result
FeatureCollection All features decoded
Feature Single-feature collection
Geometry type Feature collection with one synthetic Feature

Supported geometries

GeoJSON geometry type CPillar geometry
Point Point
MultiPoint MultiGeometry of Points
LineString Polyline
MultiLineString MultiGeometry of Polylines
Polygon Polygon (exterior ring + optional holes)
MultiPolygon MultiGeometry of Polygons
GeometryCollection MultiGeometry (heterogeneous, recursive)
missing Feature without geometry

Feature properties

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

JSON property value Decoded as
String a string property
Integer number a long property
Fractional number a double property
Boolean a boolean property
null the property is left unset for that feature
Array of primitive values a list property, with an element type inferred like a scalar
Array of objects a list property with an element type is a composite
Object a 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 property Combined type
42 then "high" string
1 (integer) then 1.5 (fractional) double
a boolean then a number string
list [1] then list [1.5] double list
[1, "two", true] in one array string 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 model Example
incompatible shapes in different features 42 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:
  • Method Details

    • decode

      @NotNull public static IFeatureModel decode(@NotNull String source) throws IOException, UnsupportedOperationException
      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:
      source - The path, URL, or logical identifier for the GeoJSON data.
      Returns:
      the newly created feature model.
      Throws:
      IOException - when creation of the model fails.
      UnsupportedOperationException - when the source cannot be handled (for example, an unsupported scheme or root type).
    • decode

      @NotNull public static IFeatureModel decode(@NotNull String source, @NotNull GeoJsonModelDecoderOptions options) throws IOException, UnsupportedOperationException
      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:
      source - The path, URL, or logical identifier for the GeoJSON data.
      options - Options controlling how the source is resolved.
      Returns:
      the newly created feature model.
      Throws:
      IOException - when creation of the model fails.
      UnsupportedOperationException - when the source cannot be handled (for example, an unsupported scheme or root type).
      Since:
      2026.1