summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2014-12-03 11:48:39 +0100
committerFélix Sipma <felix.sipma@no-log.org>2014-12-03 11:49:08 +0100
commite90e863c390dd6b63ba5fadc328b95afa3475355 (patch)
treeecb2b1073e4ee416de244ec850754becb45c77a9
parent196395e9026f80f98aeb9983d787aa4f92eedd4c (diff)
geojson
-rw-r--r--Handler/PlaceList.hs1
-rw-r--r--Model.hs13
-rw-r--r--mokupona.cabal1
3 files changed, 14 insertions, 1 deletions
diff --git a/Handler/PlaceList.hs b/Handler/PlaceList.hs
index ecade15..cb90d79 100644
--- a/Handler/PlaceList.hs
+++ b/Handler/PlaceList.hs
@@ -16,6 +16,7 @@ getPlaceListR = do
addScript $ StaticR js_leaflet_js
addStylesheet $ StaticR css_leaflet_css
$(widgetFile "place-list")
+ provideJson places
postPlaceListR :: Handler Html
postPlaceListR = error "Not yet implemented: postPlaceListR"
diff --git a/Model.hs b/Model.hs
index bc963f7..20a33f4 100644
--- a/Model.hs
+++ b/Model.hs
@@ -6,8 +6,9 @@ import Database.Persist.Quasi
import Shop.Unit.Types (Unit)
import Shop.Amount.Types (Amount)
import Shop.Quantity.Types (Quantity)
-import Shop.Place.Types (Point)
+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
@@ -35,3 +36,13 @@ instance FromJSON Shop where
<*> o .: "updated"
parseJSON _ = mzero
+
+instance ToJSON (Entity Place) where
+ toJSON (Entity pid p) = toJSON $ G.GeoFeature
+ Nothing
+ (G.Point $ G.GeoPoint [pntLat $ placeLocation p, pntLon $ placeLocation p])
+ (object
+ [ "id" .= (String $ toPathPiece pid)
+ , "ident" .= (String $ placeIdent p)
+ ])
+ Nothing
diff --git a/mokupona.cabal b/mokupona.cabal
index 1c33dbb..46df0f2 100644
--- a/mokupona.cabal
+++ b/mokupona.cabal
@@ -113,6 +113,7 @@ library
, random >= 1.0.1.1
, esqueleto >= 1.4.1
, foreign-store >= 0.1
+ , geojson >= 1.0.0
executable mokupona
if flag(library-only)