gtfs/internal/geojson

GeoJSON Parser for locations.geojson

Parses GeoJSON files according to RFC 7946. Used for GTFS-Flex locations.geojson file. Source: GTFS reference.md - Dataset Files > locations.geojson

Types

A GeoJSON Feature

pub type Feature {
  Feature(
    id: option.Option(String),
    properties: dict.Dict(String, String),
    geometry: Geometry,
  )
}

Constructors

A GeoJSON FeatureCollection

pub type FeatureCollection {
  FeatureCollection(features: List(Feature))
}

Constructors

  • FeatureCollection(features: List(Feature))

Errors that can occur during GeoJSON parsing

pub type GeoJsonError {
  InvalidJson(reason: String)
  MissingField(field: String)
  InvalidGeometryType(got: String, expected: String)
  InvalidCoordinates(reason: String)
  InvalidPolygon(reason: String)
  InvalidFeature(reason: String)
}

Constructors

  • InvalidJson(reason: String)

    Invalid JSON syntax

  • MissingField(field: String)

    Missing required field

  • InvalidGeometryType(got: String, expected: String)

    Invalid geometry type

  • InvalidCoordinates(reason: String)

    Invalid coordinates

  • InvalidPolygon(reason: String)

    Invalid polygon (not closed, wrong winding, etc.)

  • InvalidFeature(reason: String)

    Invalid feature

GeoJSON Geometry types supported for GTFS

pub type Geometry {
  Polygon(rings: List(List(types.Coordinate)))
  MultiPolygon(polygons: List(List(List(types.Coordinate))))
}

Constructors

Values

pub fn parse(
  content: String,
) -> Result(FeatureCollection, GeoJsonError)

Parse a GeoJSON string into a FeatureCollection

Search Document