summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2014-12-05 19:22:05 +0100
committerFélix Sipma <felix.sipma@no-log.org>2014-12-05 19:22:05 +0100
commite1c1725152ca2464ee694ce7bbff68864003ff69 (patch)
tree3ee4031304d99f06c30a96a68cb297fb26ad12d3
parent80e8026048b49ca6e0659f4843ad1f05e18eca5e (diff)
remove geojson dependency
-rw-r--r--Model.hs42
-rw-r--r--mokupona.cabal1
2 files changed, 21 insertions, 22 deletions
diff --git a/Model.hs b/Model.hs
index b8b52b5..2432473 100644
--- a/Model.hs
+++ b/Model.hs
@@ -8,7 +8,6 @@ import Shop.Amount.Types (Amount)
import Shop.Quantity.Types (Quantity)
import Shop.Place.Types (Point (..))
import Data.Aeson ((.:?))
-import qualified Data.Geospatial as G
-- You can define all of your database entities in the entities file.
-- You can find more information on persistent and how to declare entities
@@ -37,26 +36,27 @@ instance FromJSON Shop where
parseJSON _ = mzero
-toGeoFeature :: Entity Place -> G.GeoFeature Value
-toGeoFeature (Entity pid p) = G.GeoFeature
- Nothing
- (G.Point $ G.GeoPoint pointpos)
- (object
- [ "id" .= (String $ toPathPiece pid)
- , "ident" .= (String $ placeIdent p)
- ])
- Nothing
- where
- pointpos =
- [ pntLon $ placeLocation p
- , pntLat $ placeLocation p
- ] ++ maybeToList (pntEle $ placeLocation p)
-
instance ToJSON (Entity Place) where
- toJSON = toJSON . toGeoFeature
-
-toGeoFeatureCollection :: [Entity Place] -> G.GeoFeatureCollection Value
-toGeoFeatureCollection l = G.GeoFeatureCollection Nothing $ map toGeoFeature l
+ toJSON (Entity pid p) = object
+ [ "geometry" .= object
+ [ "type" .= String "Point"
+ , "coordinates" .= [ toJSON $ pntLon $ placeLocation p, toJSON $ pntLat $ placeLocation p ]
+ ]
+ , "type" .= String "Feature"
+ , "properties" .= object
+ [ "id" .= (String $ toPathPiece pid)
+ , "ident" .= (String $ placeIdent p)
+ ]
+ ]
instance ToJSON [Entity Place] where
- toJSON = toJSON . toGeoFeatureCollection
+ toJSON l = object
+ [ "crs" .= object
+ [ "type" .= String "name"
+ , "properties" .= object
+ [ "name" .= String "urn:ogc:def:crs:OGC:1.3:CRS84"
+ ]
+ ]
+ , "type" .= String "FeatureCollection"
+ , "features" .= map toJSON l
+ ]
diff --git a/mokupona.cabal b/mokupona.cabal
index d8c9842..8be72fe 100644
--- a/mokupona.cabal
+++ b/mokupona.cabal
@@ -115,7 +115,6 @@ library
, random >= 1.0.1.1
, esqueleto >= 1.4.1
, foreign-store >= 0.1
- , geojson >= 1.0
, parsec >= 3.0
executable mokupona