Copyright | (c) 2018 Cedric Liegeois |
---|---|

License | BSD3 |

Maintainer | Cedric Liegeois <ofmooseandmen@yahoo.fr> |

Stability | experimental |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell2010 |

Types and functions for working with positions.

All functions are implemented using the vector-based approached described in Gade, K. (2010). A Non-singular Horizontal Position Representation

This module assumes a spherical earth.

- class Position a where
- angularDistance :: NVector -> NVector -> Maybe NVector -> Angle
- antipode :: Position a => a -> a
- destination :: Position a => a -> Angle -> Length -> a
- destination' :: Position a => a -> Angle -> Length -> Length -> a
- distance :: Position a => a -> a -> Length
- distance' :: Position a => a -> a -> Length -> Length
- finalBearing :: Position a => a -> a -> Angle
- initialBearing :: Position a => a -> a -> Angle
- interpolate :: Position a => a -> a -> Double -> a
- isInside :: (Eq a, Position a) => a -> [a] -> Bool
- mean :: Position a => [a] -> Maybe a
- meanEarthRadius :: Length
- northPole :: Position a => a
- southPole :: Position a => a

# The `Position`

type

class Position a where Source #

The `Position`

class defines 2 functions to convert a position to and from a `NVector`

.
All functions in this module first convert `Position`

to `NVector`

and any resulting `NVector`

back
to a `Position`

. This allows the call site to pass either `NVector`

or `LatLong`

and to get back
the same class instance.

fromNVector :: NVector -> a Source #

# Geodetic calculations

destination :: Position a => a -> Angle -> Length -> a Source #

`destination'`

assuming a radius of `meanEarthRadius`

.

distance' :: Position a => a -> a -> Length -> Length Source #

Computes the surface distance (length of geodesic) in `Meters`

assuming a
spherical Earth between the two given `Position`

s and using the given earth radius.

finalBearing :: Position a => a -> a -> Angle Source #

Computes the final bearing arriving at given destination `p2`

`Position`

from given `Position`

`p1`

.
the final bearing will differ from the `initialBearing`

by varying degrees according to distance and latitude.
Returns 180 if both position are equals.

initialBearing :: Position a => a -> a -> Angle Source #

interpolate :: Position a => a -> a -> Double -> a Source #

isInside :: (Eq a, Position a) => a -> [a] -> Bool Source #

Determines whether the given `Position`

is inside the polygon defined by the given list of `Position`

s.
The polygon is closed if needed (i.e. if `head ps /= last ps`

).

Uses the angle summation test: on a sphere, due to spherical excess, enclosed point angles will sum to less than 360°, and exterior point angles will be small but non-zero.

Always returns `False`

if positions does not at least defines a triangle.

mean :: Position a => [a] -> Maybe a Source #

Computes the geographic mean `Position`

of the given `Position`

s if it is defined.

The geographic mean is not defined for the antipodals positions (since they cancel each other).

Special conditions:

mean [] == Nothing mean [p] == Just p mean [p1, p2, p3] == Just circumcentre mean [p1, .., antipode p1] == Nothing

# Misc.

meanEarthRadius :: Length Source #

Mean Earth radius: 6,371,008.8 metres.