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 Great Circle.
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.
TODO:
- alongTrackDistance :: Position -> GreatArc -> Length
- intersection :: GreatArc -> GreatArc -> Maybe Position
- nearestPoint :: Position -> GreatArc -> Position
- area :: [Position] -> Surface
- closestApproach
Synopsis
- data GreatCircle
- class Position a where
- greatCircle :: (Eq a, Position a, Show a) => a -> a -> GreatCircle
- greatCircleE :: (Eq a, Position a) => a -> a -> Either String GreatCircle
- greatCircleF :: (Eq a, MonadFail m, Position a) => a -> a -> m GreatCircle
- greatCircleBearing :: Position a => a -> Angle -> GreatCircle
- antipode :: Position a => a -> a
- crossTrackDistance :: Position a => a -> GreatCircle -> Length
- crossTrackDistance' :: Position a => a -> GreatCircle -> Length -> Length
- 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
- intersections :: Position a => GreatCircle -> GreatCircle -> Maybe (a, 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 GreatCircle
type
data GreatCircle Source #
A circle on the surface of the Earth which lies in a plane passing through the Earth's centre. Every two distinct and non-antipodal points on the surface of the Earth define a Great Circle.
It is internally represented as its normal vector - i.e. the normal vector to the plane containing the great circle.
See greatCircle
, greatCircleE
, greatCircleF
or greatCircleBearing
constructors.
Instances
Eq GreatCircle Source # | |
Defined in Data.Geo.Jord.GreatCircle (==) :: GreatCircle -> GreatCircle -> Bool # (/=) :: GreatCircle -> GreatCircle -> Bool # | |
Show GreatCircle Source # | |
Defined in Data.Geo.Jord.GreatCircle showsPrec :: Int -> GreatCircle -> ShowS # show :: GreatCircle -> String # showList :: [GreatCircle] -> ShowS # |
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 GeoPos
and to get back
the same class instance.
fromNVector :: NVector -> a Source #
Smart constructors
greatCircle :: (Eq a, Position a, Show a) => a -> a -> GreatCircle Source #
greatCircleE :: (Eq a, Position a) => a -> a -> Either String GreatCircle Source #
greatCircleF :: (Eq a, MonadFail m, Position a) => a -> a -> m GreatCircle Source #
greatCircleBearing :: Position a => a -> Angle -> GreatCircle Source #
GreatCircle
passing by the given Position
and heading on given bearing.
Geodesic calculations
crossTrackDistance :: Position a => a -> GreatCircle -> Length Source #
crossTrackDistance'
assuming a radius of meanEarthRadius
.
crossTrackDistance' :: Position a => a -> GreatCircle -> Length -> Length Source #
Signed distance from given Position
to given GreatCircle
.
Returns a negative Length
if position if left of great circle,
positive Length
if position if right of great circle; the orientation of the
great circle is therefore important:
let gc1 = greatCircle (latLongDecimal 51 0) (latLongDecimal 52 1) let gc2 = greatCircle (latLongDecimal 52 1) (latLongDecimal 51 0) crossTrackDistance p gc1 == (- crossTrackDistance p gc2)
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 #
intersections :: Position a => GreatCircle -> GreatCircle -> Maybe (a, a) Source #
Computes the intersections between the two given GreatCircle
s.
Two GreatCircle
s intersect exactly twice unless there are equal (regardless of orientation),
in which case Nothing
is returned.
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 #
a, b,c => a b, a, c, b, c | Mean Earth radius: 6,371,008.8 metres.