gps-0.6: For manipulating GPS coordinates and trails.

Data.GPS

Description

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

Synopsis

# Types

type Distance = DoubleSource

Distances are expressed in meters

type Heading = DoubleSource

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

type Speed = DoubleSource

Speed is hard coded as meters per second

type Trail a = [a]Source

# Constants

North is 0 radians

South, being 180 degrees from North, is pi.

East is 270 degrees from North

West is 90 degrees (pi/2)

radius of the earth in meters

# Coordinate Functions

Arguments

 :: (Lat a, Lon a) => a -> a -> Heading 0 = North, pi/2 = West...

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

distance :: (Lat a, Lon a) => a -> a -> DistanceSource

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

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

Reads a GPX file (using the GPX library) by simply concatenating all the tracks, segments, and points (`trkpts`, `trksegs`, `trks`) into a single `Trail`.