Decode GeoJson into an Elm data structure where you can operate on it further. Most of this module defines types that collectively define that data structure.
After using GeoJson.decoder you can either traverse the data structure
directly (recommended if you're working with 2D positions and not using
properties) or use Json.Decode.andThen to transform it into a more convenient
representation specific to your use case (recommended if you find yourself with
a lot of Maybes or impossible cases using the first approach).
An encode function is also provided, mostly for completeness and testing.
Neither encoding nor decoding attempt to enforce minimum array lengths
(excluding positions, whose minimum length is enforced by their type).
All union types are fully exposed so you can inspect them as necessary.
The root representation of GeoJSON in Elm. It consists of a GeoJsonObject and an optional Bbox.
A GeoJsonObject contains the primary data, and is either a Geometry, a
FeatureObject, or a list of FeatureObjects.
Note that the tag for FeatureObject is just Feature, to avoid a name
collision.
A FeatureObject represents a geographic feature. The geometry field is
allowed to have null instead of actual geometry, which is represented as
Nothing. The properties may be any JSON object but no attempt is made to
inspect it. The id is an optional "commonly used identifier". It is permitted
by the RFC to be either a string or a number; if the latter this implementation
converts it to a string.
The heart of GeoJSON: geometry objects. The union tags reflect the
type field of the JSON, and carries the value of the coordinates field (or
geometries for GeometryCollection).
The specification imposes minimum lengths for some of the arrays (lists in Elm). This representation does not express those guarantees, on the theory that you will likely be working with a valid GeoJson file rather than generating one of your own.
A Position is the fundamental geometry construct. The specification
represents positions as arrays of numbers that must contain at least two
elements. This tuple allows the compiler to provide a similar guarantee, so that
one avoids Maybes when working with a 2D dataset.
RFC 7946 suggests that positions not contain more than three elements, but this library accepts them. The RFC also states that "[t]he first two elements are longitude and latitude, or easting and northing, precisely in that order".
A Bounding Box is represented as a simple list of floats. No attempt is made to validate that its length is twice the length of the geometrys' positions, or that low values are preceded by high values.
Encode GeoJSON into Elm. This is mostly for completeness and roundtrip testing.
Decode GeoJSON into Elm. The decoded value is expressed in the types defined by this module.