switch from Float to Double

anticipating  that the storage will prefer doubles
This commit is contained in:
Daniel Barlow 2024-11-04 23:36:43 +00:00
parent 5995a4083a
commit 0e7406f7aa

View File

@ -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]