gleojson
Functions for working with GeoJSON data.
This module provides types and functions for encoding and decoding GeoJSON data. It supports all GeoJSON object types including Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection, Feature, and FeatureCollection.
Usage
To use this module, you can import it in your Gleam code:
import gleojson
Then you can use the provided functions to encode and decode GeoJSON data. Types
Types
A feature in a GeoJSON object.
pub type Feature {
Feature(
geometry: option.Option(Geometry),
properties: option.Option(dict.Dict(String, dynamic.Dynamic)),
id: option.Option(dynamic.Dynamic),
)
}
Constructors
-
Feature( geometry: option.Option(Geometry), properties: option.Option(dict.Dict(String, dynamic.Dynamic)), id: option.Option(dynamic.Dynamic), )
A collection of features in a GeoJSON object.
pub type FeatureCollection {
FeatureCollection(features: List(Feature))
}
Constructors
-
FeatureCollection(features: List(Feature))
A GeoJSON object.
pub type GeoJSON {
GeoJSONGeometry(Geometry)
GeoJSONFeature(Feature)
GeoJSONFeatureCollection(FeatureCollection)
}
Constructors
-
GeoJSONGeometry(Geometry)
-
GeoJSONFeature(Feature)
-
GeoJSONFeatureCollection(FeatureCollection)
A geometry in a GeoJSON object.
pub type Geometry {
GeometryPoint(Point)
GeometryMultiPoint(MultiPoint)
GeometryLineString(LineString)
GeometryMultiLineString(MultiLineString)
GeometryPolygon(Polygon)
GeometryMultiPolygon(MultiPolygon)
GeometryCollectionType(GeometryCollection)
}
Constructors
-
GeometryPoint(Point)
-
GeometryMultiPoint(MultiPoint)
-
GeometryLineString(LineString)
-
GeometryMultiLineString(MultiLineString)
-
GeometryPolygon(Polygon)
-
GeometryMultiPolygon(MultiPolygon)
-
GeometryCollectionType(GeometryCollection)
A collection of geometries in a GeoJSON object.
pub type GeometryCollection {
GeometryCollection(geometries: List(Geometry))
}
Constructors
-
GeometryCollection(geometries: List(Geometry))
A line string in a GeoJSON object.
pub type LineString {
LineString(coordinates: List(Position))
}
Constructors
-
LineString(coordinates: List(Position))
A multi-line string in a GeoJSON object.
pub type MultiLineString {
MultiLineString(coordinates: List(List(Position)))
}
Constructors
-
MultiLineString(coordinates: List(List(Position)))
A multi-point in a GeoJSON object.
pub type MultiPoint {
MultiPoint(coordinates: List(Position))
}
Constructors
-
MultiPoint(coordinates: List(Position))
A multi-polygon in a GeoJSON object.
pub type MultiPolygon {
MultiPolygon(coordinates: List(List(List(Position))))
}
Constructors
-
MultiPolygon(coordinates: List(List(List(Position))))
A point in a GeoJSON object.
pub type Point {
Point(coordinates: Position)
}
Constructors
-
Point(coordinates: Position)
A polygon in a GeoJSON object.
pub type Polygon {
Polygon(coordinates: List(List(Position)))
}
Constructors
-
Polygon(coordinates: List(List(Position)))
Functions
pub fn encode_feature(feature: Feature) -> Dynamic
Encodes a feature into a dynamic value.
pub fn encode_featurecollection(
collection: FeatureCollection,
) -> Dynamic
Encodes a feature collection into a dynamic value.
pub fn encode_geojson(geojson: GeoJSON) -> Dynamic
Encodes a GeoJSON object into a dynamic value.
pub fn encode_geometry(geometry: Geometry) -> Dynamic
Encodes a geometry into a dynamic value.
pub fn encode_geometrycollection(
collection: GeometryCollection,
) -> Dynamic
Encodes a geometry collection into a dynamic value.
pub fn encode_linestring(linestring: LineString) -> Dynamic
Encodes a line string into a dynamic value.
pub fn encode_multilinestring(
multilinestring: MultiLineString,
) -> Dynamic
Encodes a multi-line string into a dynamic value.
pub fn encode_multipoint(multipoint: MultiPoint) -> Dynamic
Encodes a multi-point into a dynamic value.
pub fn encode_multipolygon(multipolygon: MultiPolygon) -> Dynamic
Encodes a multi-polygon into a dynamic value.
pub fn encode_polygon(polygon: Polygon) -> Dynamic
Encodes a polygon into a dynamic value.
pub fn encode_position(position: List(Float)) -> Dynamic
Encodes a position into a dynamic value.
pub fn encode_positions(positions: List(List(Float))) -> Dynamic
Encodes a list of positions into a dynamic value.
pub fn encode_positions_list(
positions_list: List(List(List(Float))),
) -> Dynamic
Encodes a list of positions into a dynamic value.
pub fn encode_positions_list_list(
positions_list_list: List(List(List(List(Float)))),
) -> Dynamic
Encodes a list of lists of positions into a dynamic value.
pub fn feature_decoder(
dynamic_value: Dynamic,
) -> Result(Feature, List(DecodeError))
Decodes a feature from a dynamic value.
pub fn featurecollection_decoder(
dynamic_value: Dynamic,
) -> Result(FeatureCollection, List(DecodeError))
Decodes a feature collection from a dynamic value.
pub fn geojson_decoder(
dynamic_value: Dynamic,
) -> Result(GeoJSON, List(DecodeError))
Decodes a GeoJSON object from a dynamic value.
pub fn geometry_decoder(
dynamic_value: Dynamic,
) -> Result(Geometry, List(DecodeError))
Decodes a geometry from a dynamic value.
pub fn geometrycollection_decoder(
dynamic_value: Dynamic,
) -> Result(GeometryCollection, List(DecodeError))
Decodes a geometry collection from a dynamic value.
pub fn linestring_decoder(
dynamic_value: Dynamic,
) -> Result(LineString, List(DecodeError))
Decodes a line string from a dynamic value.
pub fn multilinestring_decoder(
dynamic_value: Dynamic,
) -> Result(MultiLineString, List(DecodeError))
Decodes a multi-line string from a dynamic value.
pub fn multipoint_decoder(
dynamic_value: Dynamic,
) -> Result(MultiPoint, List(DecodeError))
Decodes a multi-point from a dynamic value.
pub fn multipolygon_decoder(
dynamic_value: Dynamic,
) -> Result(MultiPolygon, List(DecodeError))
Decodes a multi-polygon from a dynamic value.
pub fn point_decoder(
dynamic_value: Dynamic,
) -> Result(Point, List(DecodeError))
Decodes a point from a dynamic value.
pub fn polygon_decoder(
dynamic_value: Dynamic,
) -> Result(Polygon, List(DecodeError))
Decodes a polygon from a dynamic value.
pub fn position_decoder(
dynamic_value: Dynamic,
) -> Result(List(Float), List(DecodeError))
Decodes a position from a dynamic value.
pub fn positions_decoder(
dynamic_value: Dynamic,
) -> Result(List(List(Float)), List(DecodeError))
Decodes a list of positions from a dynamic value.
pub fn positions_list_decoder(
dynamic_value: Dynamic,
) -> Result(List(List(List(Float))), List(DecodeError))
Decodes a list of lists of positions from a dynamic value.
pub fn positions_list_list_decoder(
dynamic_value: Dynamic,
) -> Result(List(List(List(List(Float)))), List(DecodeError))
Decodes a list of lists of lists of positions from a dynamic value.