Maintainer | Dom De Re |
---|---|
Safe Haskell | None |
Refer to the GeoJSON Spec http:www.geojson.org/geojson-spec.html
- type Latitude = Double
- type Longitude = Double
- type Easting = Double
- type Northing = Double
- type Altitude = Double
- type GeoPositionWithoutCRS = [Double]
- data GeoPosition
- newtype GeoPoint = GeoPoint {}
- newtype GeoMultiPoint = GeoMultiPoint {
- _unGeoMultiPoint :: [GeoPoint]
- newtype GeoPolygon = GeoPolygon {}
- newtype GeoMultiPolygon = GeoMultiPolygon {}
- newtype GeoLine = GeoLine {}
- newtype GeoMultiLine = GeoMultiLine {
- _unGeoMultiLine :: [GeoLine]
- data GeospatialGeometry
- type Name = Text
- type Code = Int
- type Href = Text
- type FormatString = Text
- type ProjectionType = Text
- data CRSObject
- type FeatureID = Text
- type BoundingBoxWithoutCRS = [Double]
- data GeoFeature a = GeoFeature {}
- data GeoFeatureCollection a = GeoFeatureCollection {}
- stripCRSFromPosition :: GeoPosition -> GeoPositionWithoutCRS
- defaultCRS :: CRSObject
- unGeoPoint :: Iso' GeoPoint GeoPositionWithoutCRS
- unGeoMultiPoint :: Iso' GeoMultiPoint [GeoPoint]
- unGeoPolygon :: Iso' GeoPolygon [LinearRing GeoPositionWithoutCRS]
- unGeoLine :: Iso' GeoLine [GeoPositionWithoutCRS]
- unGeoMultiLine :: Iso' GeoMultiLine [GeoLine]
- unGeoMultiPolygon :: Iso' GeoMultiPolygon [GeoPolygon]
- bbox :: forall a. Lens' (GeoFeature a) (Maybe BoundingBoxWithoutCRS)
- geometry :: forall a. Lens' (GeoFeature a) GeospatialGeometry
- properties :: forall a a. Lens (GeoFeature a) (GeoFeature a) a a
- featureId :: forall a. Lens' (GeoFeature a) (Maybe FeatureID)
- boundingbox :: forall a. Lens' (GeoFeatureCollection a) (Maybe BoundingBoxWithoutCRS)
- geofeatures :: forall a a. Lens (GeoFeatureCollection a) (GeoFeatureCollection a) [GeoFeature a] [GeoFeature a]
- _NoGeometry :: Prism' GeospatialGeometry ()
- _Point :: Prism' GeospatialGeometry GeoPoint
- _MultiPoint :: Prism' GeospatialGeometry GeoMultiPoint
- _Polygon :: Prism' GeospatialGeometry GeoPolygon
- _MultiPolygon :: Prism' GeospatialGeometry GeoMultiPolygon
- _Line :: Prism' GeospatialGeometry GeoLine
- _MultiLine :: Prism' GeospatialGeometry GeoMultiLine
- _Collection :: Prism' GeospatialGeometry [GeospatialGeometry]
- _NoCRS :: Prism' CRSObject ()
- _NamedCRS :: Prism' CRSObject Name
- _EPSG :: Prism' CRSObject Code
- _LinkedCRS :: Prism' CRSObject (Href, FormatString)
Types
type GeoPositionWithoutCRS = [Double]Source
(GeoPositionWithoutCRS
is a catch all for indeterminate CRSs and for expression of positions
before a CRS has been determined
data GeoPosition Source
see Section 2.1.1 Position in the GeoJSON Spec, I make the assumption here that the only position types we will use will involve easting or northing (+ve or -ve Altitude) or lon or lat (+ve or -ve Altitude)
newtype GeoMultiPoint Source
newtype GeoPolygon Source
newtype GeoMultiPolygon Source
newtype GeoMultiLine Source
data GeospatialGeometry Source
See section 2.1 Geometry Objects in the GeoJSON Spec.
NoGeometry | |
Point GeoPoint | |
MultiPoint GeoMultiPoint | |
Polygon GeoPolygon | |
MultiPolygon GeoMultiPolygon | |
Line GeoLine | |
MultiLine GeoMultiLine | |
Collection [GeospatialGeometry] |
Eq GeospatialGeometry | |
Show GeospatialGeometry | |
ToJSON GeospatialGeometry | encodes and Geometry Objects to GeoJSON (refer to source to see the values for the test values)
|
FromJSON GeospatialGeometry | encodes and decodes Geometry Objects to and from GeoJSON (refer to source to see the values for the test values)
Aeson doesnt decode null into decode' null :: Maybe GeospatialGeometry Just NoGeometry |
type FormatString = TextSource
type ProjectionType = TextSource
See Section 3 Coordinate Reference System Objects in the GeoJSON Spec
NoCRS
is required because no crs
attribute in a GeoJSON feature is NOT the same thing as
a null crs
attribute. no crs
value implies the default CRS, while a null CRS means
you cannot assume a CRS, null will mapped to NoCRS
while a non-existent attribute will
be mapped to a Nothing
Maybe
value
Eq CRSObject | |
Show CRSObject | |
ToJSON CRSObject | encode CRS Objects to GeoJSON
|
FromJSON CRSObject | encode and decodes CRS Objects to and from GeoJSON
Aeson doesnt decode null to (A.decode . BS.pack) null == Just NoCRS True |
type BoundingBoxWithoutCRS = [Double]Source
See Section 4 Bounding Boxes of the GeoJSON spec, The length of the list/array must be 2*n where n is the dimensionality of the position type for the CRS with min values first followed by the max values, wich both the min/max sets following the same axis order as the CRS, e.g for WGS84: minLongitude, minLatitude, maxLongitude, maxLatitude The spec mentions that it can be part of a geometry object too but doesnt give an example, This implementation will ignore bboxes on Geometry objects, they can be added if required.
data GeoFeature a Source
See Section 2.2 Feature Objects of the GeoJSON spec. Parameterised on the property type
Eq a => Eq (GeoFeature a) | |
Show a => Show (GeoFeature a) | |
ToJSON a => ToJSON (GeoFeature a) | encodes Feature objects to and from GeoJSON
|
FromJSON a => FromJSON (GeoFeature a) | decodes Feature objects to and from GeoJSON
|
data GeoFeatureCollection a Source
See Section 2.3 Feature Collection Objects of the GeoJSON spec
Eq a => Eq (GeoFeatureCollection a) | |
Show a => Show (GeoFeatureCollection a) | |
ToJSON a => ToJSON (GeoFeatureCollection a) | Encodes FeatureCollection objects to and from GeoJSON
|
FromJSON a => FromJSON (GeoFeatureCollection a) | Decodes FeatureCollection objects to and from GeoJSON
|
Functions
stripCRSFromPosition :: GeoPosition -> GeoPositionWithoutCRSSource
the GeoPosition
is a bit special in that when you convert it to GeoJSON,
it will lose the CRS info attached to it and cannot be read back in
from the GeoJSON. Hence it is ineligible for the FromJSON
type class,
so this function will strip it down to a GeoPositionWithoutCRS
, which is eligible
The default CRS according to Section 3 Coordinate Reference System Objects is WGS84 which I believe, from http://spatialreference.org/ref/epsg/4326/ which translates to this in JSON: http://spatialreference.org/ref/epsg/4326/json/) is represented thus:
Lenses
Geometry Lenses
Feature Lenses
bbox :: forall a. Lens' (GeoFeature a) (Maybe BoundingBoxWithoutCRS)Source
geometry :: forall a. Lens' (GeoFeature a) GeospatialGeometrySource
properties :: forall a a. Lens (GeoFeature a) (GeoFeature a) a aSource
boundingbox :: forall a. Lens' (GeoFeatureCollection a) (Maybe BoundingBoxWithoutCRS)Source
geofeatures :: forall a a. Lens (GeoFeatureCollection a) (GeoFeatureCollection a) [GeoFeature a] [GeoFeature a]Source