commit 0e7406f7aa538d67f9f8faf6fa63168b2883e674
parent 5995a4083af5c5d99a6d25b882747dc5c207d05b
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 4 Nov 2024 23:36:43 +0000
switch from Float to Double
anticipating that the storage will prefer doubles
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/Track.hs b/lib/Track.hs
@@ -32,7 +32,7 @@ import Text.Read (readMaybe)
import Text.XML
import Text.XML.Cursor as Cursor
-data Pos = Pos Float Float (Maybe Float) deriving (Show, Eq)
+data Pos = Pos Double Double (Maybe Double) deriving (Show, Eq)
type Power = Maybe Int
@@ -64,12 +64,12 @@ instance Exception BadFile
elToPoint :: Cursor -> Either SomeException Point
elToPoint c =
- let lat = listToMaybe (attribute "lat" c) >>= asFloat
- lon = listToMaybe (attribute "lon" c) >>= asFloat
+ let lat = listToMaybe (attribute "lat" c) >>= asDouble
+ lon = listToMaybe (attribute "lon" c) >>= asDouble
ts =
listToMaybe (child c >>= element (gpxNS "time") >>= child >>= content)
>>= (Data.Time.ISO8601.parseISO8601 . Data.Text.unpack)
- ele = listToMaybe (child c >>= element (gpxNS "ele") >>= child >>= content) >>= asFloat
+ ele = listToMaybe (child c >>= element (gpxNS "ele") >>= child >>= content) >>= asDouble
gpxtpx =
child c
>>= element (gpxNS "extensions")
@@ -93,7 +93,7 @@ elToPoint c =
(listToMaybe hr >>= asInt)
else Left (toException (BadFile "missing a required attribute"))
where
- asFloat v = (readMaybe :: String -> Maybe Float) (Data.Text.unpack v)
+ asDouble v = (readMaybe :: String -> Maybe Double) (Data.Text.unpack v)
asInt v = (readMaybe :: String -> Maybe Int) (Data.Text.unpack v)
getPoints :: Cursor -> Either SomeException [Point]