A basic GPS library with calculations for distance and speed along with helper functions for filtering/smoothing trails. All distances are in meters and time is in seconds. Speed is thus meters/second

- type Distance = Double
- type Heading = Double
- type Speed = Double
- type Vector = (Distance, Heading)
- type Trail a = [a]
- north :: Heading
- south :: Heading
- east :: Heading
- west :: Heading
- radiusOfEarth :: Double
- heading :: (Lat a, Lon a) => a -> a -> Heading
- distance :: (Lat a, Lon a) => a -> a -> Distance
- speed :: (Lat loc, Lon loc, Time loc) => loc -> loc -> Maybe Speed
- addVector :: (Lat c, Lon c) => Vector -> c -> c
- getRadianPair :: (Lat p, Lon p) => p -> (LatitudeType, LongitudeType)
- getDMSPair :: (Lat c, Lon c) => c -> (LatitudeType, LongitudeType)
- divideArea :: (Lat c, Lon c) => Distance -> Distance -> c -> c -> [[c]]
- totalDistance :: (Lat a, Lon a) => [a] -> Distance
- restLocations :: (Lat a, Lon a, Time a) => Distance -> NominalDiffTime -> Trail a -> [Trail a]
- closestDistance :: (Lat a, Lon a) => Trail a -> Trail a -> Maybe Distance
- filterByMaxSpeed :: (Lat loc, Lon loc, Time loc) => Speed -> Trail loc -> Trail loc
- convexHull :: (Eq c, Lat c, Lon c) => [c] -> [c]
- readGPX :: FilePath -> IO (Trail WptType)
- module Data.Geo.GPX

# Types

Angles are expressed in radians from North.
0 == North
pi/2 == West
pi == South
(3*2)pi == East == - (pi * 2)

# Constants

radius of the earth in meters

# Coordinate Functions

Direction two points aim toward (0 = North, pi*2 = West, pi = South, 3pi*2 = East)

speed :: (Lat loc, Lon loc, Time loc) => loc -> loc -> Maybe SpeedSource

Speed in meters per second, only if a `Time`

was recorded for each waypoint.

addVector :: (Lat c, Lon c) => Vector -> c -> cSource

Given a vector and coordinate, computes a new coordinate. Within some epsilon it should hold that if

dest = addVector (dist,heading) start

then

heading == dmsHeading start dest

dist == distance start dest

getRadianPair :: (Lat p, Lon p) => p -> (LatitudeType, LongitudeType)Source

Provides a lat/lon pair of doubles in radians

getDMSPair :: (Lat c, Lon c) => c -> (LatitudeType, LongitudeType)Source

divideArea :: (Lat c, Lon c) => Distance -> Distance -> c -> c -> [[c]]Source

`divideArea vDist hDist nw se`

divides an area into a grid of equally
spaced coordinates within the box drawn by the northwest point (nw) and
southeast point (se). Because this uses floating point there might be a
different number of points in some rows (the last might be too far east based
on a heading from the se point).

# Trail Functions

totalDistance :: (Lat a, Lon a) => [a] -> DistanceSource

Find the total distance traveled

restLocations :: (Lat a, Lon a, Time a) => Distance -> NominalDiffTime -> Trail a -> [Trail a]Source

Creates a list of trails all of which are within the given distance of each other spanning atleast the given amount of time.

For example `restLocations 50 600`

would return lists of all points that are within 50 meters of each other and
span at least 10 minutes (600 seconds).

Note this gives points within fifty meters of the earliest point - wandering in a rest area with a 50 meter radius could result in several rest points ([a,b..]) or even none if the distance between individual points exceeds 50m.

closestDistance :: (Lat a, Lon a) => Trail a -> Trail a -> Maybe DistanceSource

Returns the closest distance between two trails (or Nothing if a trail is empty) O( (n * m) * log (n * m) )

filterByMaxSpeed :: (Lat loc, Lon loc, Time loc) => Speed -> Trail loc -> Trail locSource

Filter out all points that result in a speed greater than a given value (the second point is dropped)

convexHull :: (Eq c, Lat c, Lon c) => [c] -> [c]Source

Uses Grahams scan to compute the convex hull of the given points. This operation requires sorting of the points, so don't try it unless you have notably more memory than the list of points will consume.

# Other helpers

module Data.Geo.GPX