switch from Float to Double
anticipating that the storage will prefer doubles
This commit is contained in:
parent
5995a4083a
commit
0e7406f7aa
10
lib/Track.hs
10
lib/Track.hs
@ -32,7 +32,7 @@ import Text.Read (readMaybe)
|
|||||||
import Text.XML
|
import Text.XML
|
||||||
import Text.XML.Cursor as Cursor
|
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
|
type Power = Maybe Int
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ instance Exception BadFile
|
|||||||
|
|
||||||
elToPoint :: Cursor -> Either SomeException Point
|
elToPoint :: Cursor -> Either SomeException Point
|
||||||
elToPoint c =
|
elToPoint c =
|
||||||
let lat = listToMaybe (attribute "lat" c) >>= asFloat
|
let lat = listToMaybe (attribute "lat" c) >>= asDouble
|
||||||
lon = listToMaybe (attribute "lon" c) >>= asFloat
|
lon = listToMaybe (attribute "lon" c) >>= asDouble
|
||||||
ts =
|
ts =
|
||||||
listToMaybe (child c >>= element (gpxNS "time") >>= child >>= content)
|
listToMaybe (child c >>= element (gpxNS "time") >>= child >>= content)
|
||||||
>>= (Data.Time.ISO8601.parseISO8601 . Data.Text.unpack)
|
>>= (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 =
|
gpxtpx =
|
||||||
child c
|
child c
|
||||||
>>= element (gpxNS "extensions")
|
>>= element (gpxNS "extensions")
|
||||||
@ -93,7 +93,7 @@ elToPoint c =
|
|||||||
(listToMaybe hr >>= asInt)
|
(listToMaybe hr >>= asInt)
|
||||||
else Left (toException (BadFile "missing a required attribute"))
|
else Left (toException (BadFile "missing a required attribute"))
|
||||||
where
|
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)
|
asInt v = (readMaybe :: String -> Maybe Int) (Data.Text.unpack v)
|
||||||
|
|
||||||
getPoints :: Cursor -> Either SomeException [Point]
|
getPoints :: Cursor -> Either SomeException [Point]
|
||||||
|
Loading…
Reference in New Issue
Block a user