GeoJSON data types including JSON/BSON conversion. https://github.com/alios/geojson-types/
|Latest on Hackage:||0.1.3|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
Provides data types, lens operators and (de)serialization of GeoJSON data to/from JSON and BSON using aeson and bson.
This library uses a the lens library a lot. It provides
Prism to convert from and to GeoJSON objects.
e.g. to convert a latitude/longitude given as a pair of
Double to a
Position, use the
Iso as a
Getter on that pair:
_Position :: BaseType t => Iso' (t, t) (Position t) pos :: Position Double pos = (57.324, 7.2342) ^. _Position
to then convert it to a
Point object use
_Point :: Iso' (Position t) (GeoJSON Point t) p :: GeoJSON Point Double p = pos ^. _Point ps :: GeoJSON MultiPoint Double ps = [p,p,p,p] ^. _MultiPoint
The library also provides type classes for working polymorphic over user defined data types.
e.g. for a data type:
data Location = Location locationName :: String, locationLat :: Double, locationLon :: Double
one can implement the type class
HasGeoJSON to provide a
Getter to a any GeoJSON object. In this example a
instance HasGeoJSON Point Double Location where geoJSON = to $ \loc -> (locationLat loc, locationLon loc) ^. _Position . _Point