geojson-types: GeoJSON data types including JSON/BSON conversion.
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
Iso
/ 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 _Position
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
:
_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 Point
.
instance HasGeoJSON Point Double Location where geoJSON = to $ \loc -> (locationLat loc, locationLon loc) ^. _Position . _Point
Downloads
- geojson-types-0.1.3.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
Versions [RSS] | 0.1, 0.1.1, 0.1.2, 0.1.3 |
---|---|
Dependencies | aeson (>=0.11), base (>=4.8 && <4.9), bson (>=0.3), bytestring (>=0.10), lens (>=4.14), text (>=1.2) [details] |
Tested with | ghc ==7.10.3 |
License | BSD-3-Clause |
Copyright | Copyright (c) 2016 Markus Barenhoff |
Author | Markus Barenhoff |
Maintainer | Markus Barenhoff <mbarenh@alios.org> |
Category | Data |
Home page | https://github.com/alios/geojson-types/ |
Bug tracker | https://github.com/alios/geojson-types/issues |
Uploaded | by alios at 2016-05-16T18:00:42Z |
Distributions | |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Downloads | 2594 total (14 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2016-05-16 [all 1 reports] |