Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Data.Coordinates exposing (..)
- import Json.Decode as Decode exposing (Decoder, float, Value)
- import Json.Encode as Encode
- import Json.Decode.Pipeline as Pipeline exposing (required)
- import Geolocation
- type alias Coordinates =
- { latitude : Float
- , longitude : Float
- }
- decode : Decoder Coordinates
- decode =
- Pipeline.decode Coordinates
- |> required "latitude" float
- |> required "longitude" float
- encode : Coordinates -> Value
- encode coordinates =
- Encode.object
- [ ("latitude", Encode.float coordinates.latitude)
- , ("longitude", Encode.float coordinates.longitude)
- ]
- fromGeolocation : Geolocation.Location -> Coordinates
- fromGeolocation loc =
- Coordinates loc.latitude loc.longitude
Add Comment
Please, Sign In to add comment