Package-level declarations

Core GeoJSON data structures including geometry types (Point, LineString, Polygon, and their Multi- variants), Feature, FeatureCollection, and GeometryCollection with kotlinx.serialization support for JSON.

Types

Link copied to clipboard
@Serializable(with = BoundingBoxSerializer::class)
class BoundingBox : Iterable<Double>

Represents an area bounded by a northeast and southwest.

Link copied to clipboard
@Serializable(with = FeatureSerializer::class)
data class Feature<out G : Geometry?, out P> @JvmOverloads constructor(val geometry: G, val properties: P, val id: FeatureId? = null, val bbox: BoundingBox? = null) : GeoJsonObject

A Feature object represents a spatially bounded thing.

Link copied to clipboard
@Serializable(with = FeatureCollectionSerializer::class)
data class FeatureCollection<out G : Geometry?, out P> @JvmOverloads constructor(val features: List<Feature<G, P>> = emptyList(), val bbox: BoundingBox? = null) : Collection<Feature<G, P>> , GeoJsonObject

A FeatureCollection object is a collection of Feature objects. This class implements the Collection interface and can be used as a collection directly. The list of Feature objects contained in this FeatureCollection is also accessible through the features property.

Link copied to clipboard
typealias FeatureId = @Serializable(with = FeatureIdSerializer::class) JsonPrimitive

Represents the identifier for a GeoJSON Feature. According to the GeoJSON specification, a Feature may have an identifier that can be a string or number.

Link copied to clipboard
data object GeoJson

Main entry point for encoding and decoding GeoJsonObject objects.

Link copied to clipboard
@Serializable(with = GeoJsonObjectSerializer::class)
sealed interface GeoJsonObject
Link copied to clipboard
@Serializable(with = GeometrySerializer::class)
sealed interface Geometry : GeoJsonObject

A Geometry object represents points, curves, and surfaces in coordinate space.

Link copied to clipboard
@Serializable(with = GeometryCollectionSerializer::class)
data class GeometryCollection<out G : Geometry> @JvmOverloads constructor(val geometries: List<G>, val bbox: BoundingBox? = null) : Geometry, Collection<G>

A GeometryCollection contains multiple, heterogeneous Geometry objects.

Link copied to clipboard
@Serializable(with = LineStringSerializer::class)
data class LineString @JvmOverloads constructor(val coordinates: List<Position>, val bbox: BoundingBox? = null) : SingleGeometry, LineStringGeometry

A LineString geometry represents a curve in coordinate space with two or more Position objects.

Link copied to clipboard
@Serializable(with = LineStringGeometrySerializer::class)
sealed interface LineStringGeometry : Geometry

A Geometry that contains a single or multiple curves, i.e. a union type for LineString and MultiLineString.

Link copied to clipboard
@Serializable(with = MultiGeometrySerializer::class)
sealed interface MultiGeometry : Geometry

A Geometry that contains multiple homogenous points, curves, or surfaces, i.e. a union type for MultiPoint, MultiLineString, and MultiPolygon.

Link copied to clipboard
@Serializable(with = MultiLineStringSerializer::class)
data class MultiLineString @JvmOverloads constructor(val coordinates: List<List<Position>>, val bbox: BoundingBox? = null) : MultiGeometry, LineStringGeometry, Collection<LineString>

A MultiLineString geometry represents multiple curves in coordinate space.

Link copied to clipboard
@Serializable(with = MultiPointSerializer::class)
data class MultiPoint @JvmOverloads constructor(val coordinates: List<Position>, val bbox: BoundingBox? = null) : MultiGeometry, PointGeometry, Collection<Point>

A MultiPoint geometry represents multiple points in coordinate space.

Link copied to clipboard
@Serializable(with = MultiPolygonSerializer::class)
data class MultiPolygon @JvmOverloads constructor(val coordinates: List<List<List<Position>>>, val bbox: BoundingBox? = null) : MultiGeometry, PolygonGeometry, Collection<Polygon>

A MultiPolygon geometry represents multiple surfaces in coordinate space.

Link copied to clipboard
@Serializable(with = PointSerializer::class)
data class Point @JvmOverloads constructor(val coordinates: Position, val bbox: BoundingBox? = null) : SingleGeometry, PointGeometry

A Point geometry represents a single Position in coordinate space.

Link copied to clipboard
@Serializable(with = PointGeometrySerializer::class)
sealed interface PointGeometry : Geometry

A Geometry that contains a single or multiple points, i.e. a union type for Point and MultiPoint.

Link copied to clipboard
@Serializable(with = PolygonSerializer::class)
data class Polygon @JvmOverloads constructor(val coordinates: List<List<Position>>, val bbox: BoundingBox? = null) : SingleGeometry, PolygonGeometry

A Polygon geometry represents a surface in coordinate space bounded by linear rings.

Link copied to clipboard
@Serializable(with = PolygonGeometrySerializer::class)
sealed interface PolygonGeometry : Geometry

A Geometry that contains a single or multiple surfaces, i.e. a union type for Polygon and MultiPolygon.

Link copied to clipboard
@Serializable(with = PositionSerializer::class)
class Position : Iterable<Double>

A Position is the fundamental geometry construct.

Link copied to clipboard
@Serializable(with = SingleGeometrySerializer::class)
sealed interface SingleGeometry : Geometry

A Geometry that contains a single point, curve, or surface, i.e. a union type for Point, LineString, and Polygon.

Functions

Link copied to clipboard
inline fun <T : GeoJsonObject> T.toJson(): String

Converts this GeoJsonObject to a JSON string representation.