jord-1.0.0.0: Geographical Position Calculations

Copyright(c) 2020 Cedric Liegeois
LicenseBSD3
MaintainerCedric Liegeois <ofmooseandmen@yahoo.fr>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Data.Geo.Jord.Position

Contents

Description

Position of points in specified models (e.g. WGS84) and conversion functions between coordinate system (geodetic to/from geocentric).

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

See Earth Coordinates

Synopsis

The Position type

data Position a Source #

Coordinates of a position in a specified Model. A position provides both geodetic latitude & longitude, height and geocentric coordinates. The horizontal position (i.e. coordinates at the surface of the celestial body) is also provided as n-vector.

The "show" instance gives position in degrees, minutes, seconds, milliseconds (Angle "show" instance), height (Length "show" instance) and the model (Model "show" instance).

The "eq" instance returns True if and only if, both positions have the same horizontal position, height and model.

Instances
Model a => Eq (Position a) Source # 
Instance details

Defined in Data.Geo.Jord.Position

Methods

(==) :: Position a -> Position a -> Bool #

(/=) :: Position a -> Position a -> Bool #

Model a => Show (Position a) Source # 
Instance details

Defined in Data.Geo.Jord.Position

Methods

showsPrec :: Int -> Position a -> ShowS #

show :: Position a -> String #

showList :: [Position a] -> ShowS #

latitude :: Position a -> Angle Source #

geodetic latitude

longitude :: Position a -> Angle Source #

geodetic longitude

height :: Position a -> Length Source #

height above the surface of the celestial body

nvec :: Position a -> Vector3d Source #

n-vector representing the horizontal coordinates of the position

gcvec :: Position a -> Vector3d Source #

vector representing the geocentric coordinates of the position (metres)

model :: Position a -> a Source #

model (e.g. WGS84)

n-vector

data NVector Source #

normal vector to the surface of a celestial body.

Orientation: z-axis points to the North Pole along the body's rotation axis, x-axis points towards the point where latitude = longitude = 0.

Instances
Show NVector Source # 
Instance details

Defined in Data.Geo.Jord.Position

nx :: NVector -> Double Source #

x-component of the given n-vector.

ny :: NVector -> Double Source #

y-component of the given n-vector.

nz :: NVector -> Double Source #

z-component of the given n-vector.

nvector :: Model a => Position a -> NVector Source #

nvector p returns the horizontal position of p as a n-vector.

Examples

Expand
>>> import Data.Geo.Jord.Position
>>> 
>>> nvector (northPole S84)
n-vector {0.0, 0.0, 1.0}
>>> nvector (wgs84Pos 54 154 (metres 1000))
n-vector {-0.5282978852629286, 0.2576680951131586, 0.8090169943749475}

Geocentric coordinates

data Geocentric Source #

Geocentric (cartesian) coordinates in the fixed-body coordinates system.

x-y plane is the equatorial plane, x is on the prime meridian, and z on the polar axis.

On a spherical celestial body, an n-vector is equivalent to a normalised version of an geocentric cartesian coordinate.

Note: For Earth, this is known as the Earth-Centred Earth Fixed coordinates system (ECEF).

Instances
Show Geocentric Source # 
Instance details

Defined in Data.Geo.Jord.Position

gx :: Geocentric -> Length Source #

x-coordinate of the given Geocentric coordinates.

gy :: Geocentric -> Length Source #

y-coordinate of the given Geocentric coordinates.

gz :: Geocentric -> Length Source #

z-coordinate of the given Geocentric coordinates.

geocentric :: Model a => Position a -> Geocentric Source #

geocentric p returns the Geocentric coordinates of position p.

Examples

Expand
>>> import Data.Geo.Jord.Position
>>> 
>>> geocentric (wgs84Pos 54 154 (metres 1000))
geocentric {-3377.4908375km, 1647.312349km, 5137.5528484km}

Smart constructors

latLongPos :: Model a => Double -> Double -> a -> Position a Source #

Ground Position from given geodetic latitude & longitude in decimal degrees in the given model.

Latitude & longitude values are first converted to Angle to ensure a consistent resolution with the rest of the API, then wrapped to their respective range.

This is equivalent to:

    latLongHeightPos lat lon zero model

latLongHeightPos :: Model a => Double -> Double -> Length -> a -> Position a Source #

Position from given geodetic latitude & longitude in decimal degrees and height in the given model

Latitude & longitude values are first converted to Angle to ensure a consistent resolution with the rest of the API, then wrapped to their respective range.

latLongPos' :: Model a => Angle -> Angle -> a -> Position a Source #

Ground Position from given geodetic latitude & longitude in the given model. Latitude & longitude values are wrapped to their respective range.

This is equivalent to:

    latLongHeightPos' lat lon zero model

latLongHeightPos' :: Model a => Angle -> Angle -> Length -> a -> Position a Source #

Position from given geodetic latitude & longitude and height in the given model. Latitude & longitude values are wrapped to their respective range.

wgs84Pos :: Double -> Double -> Length -> Position WGS84 Source #

Position from given geodetic latitude & longitude in decimal degrees and height in the WGS84 datum.

Latitude & longitude values are first converted to Angle to ensure a consistent resolution with the rest of the API, then wrapped to their respective range.

This is equivalent to:

    latLongHeightPos lat lon h WGS84

wgs84Pos' :: Angle -> Angle -> Length -> Position WGS84 Source #

Position from given geodetic latitude & longitude and height in the WGS84 datum. Latitude & longitude values are wrapped to their respective range.

This is equivalent to:

    latLongHeightPos' lat lon h WGS84

s84Pos :: Double -> Double -> Length -> Position S84 Source #

Position from given latitude & longitude in decimal degrees and height in the spherical datum derived from WGS84.

Latitude & longitude values are first converted to Angle to ensure a consistent resolution with the rest of the API, then wrapped to their respective range.

This is equivalent to:

    latLongHeightPos lat lon h S84

s84Pos' :: Angle -> Angle -> Length -> Position S84 Source #

Position from given latitude & longitude and height in the spherical datum derived from WGS84. Latitude & longitude values are wrapped to their respective range.

This is equivalent to:

    latLongHeightPos' lat lon h S84

nvectorPos :: Model a => Double -> Double -> Double -> a -> Position a Source #

Position from given n-vector x, y, z coordinates in the given model. Vector (x, y, z) will be normalised to a unit vector to get a valid n-vector.

This is equivalent to:

    nvectorHeightPos lat lon zero model

nvectorHeightPos :: Model a => Double -> Double -> Double -> Length -> a -> Position a Source #

Position from given n-vector x, y, z coordinates and height in the given model. Vector (x, y, z) will be normalised to a unit vector to get a valid n-vector.

geocentricPos :: Model a => Length -> Length -> Length -> a -> Position a Source #

Position from given geocentric coordinates x, y and z in the given model.

geocentricMetresPos :: Model a => Double -> Double -> Double -> a -> Position a Source #

Position from given geocentric coordinates x, y and z in metres in the given model.

x, y, z lengths are first converted to Length to ensure a consistent resolution with the rest of the API.

nvh :: Model a => Vector3d -> Length -> a -> Position a Source #

position from n-vector, height and model; this method is to be used only if

Read/Show points

readPosition :: Model a => String -> a -> Maybe (Position a) Source #

Reads a Position from the given string using positionP.

positionP :: Model a => a -> ReadP (Position a) Source #

Parses and returns a Position.

Supported formats:

  • DD(MM)(SS)[N|S]DDD(MM)(SS)[E|W] - e.g. 553621N0130002E or 0116S03649E or 47N122W
  • Angle[N|S] Angle[E|W] - e.g. 55°36'21''N 13°0'02''E or 11°16'S 36°49'E or 47°N 122°W

Additionally the string may end by a valid Length.

Examples

Expand
>>> import Data.Geo.Jord.Position
>>> 
>>> readPosition "55°36'21''N 013°00'02''E" WGS84
Just 55°36'21.000"N,13°0'2.000"E 0.0m (WGS84)
>>> 
>>> readPosition "55°36'21''N 013°00'02''E 1500m" WGS84
Just 55°36'21.000"N,13°0'2.000"E 1500.0m (WGS84)

Vector3d conversions

nvectorFromLatLong :: (Angle, Angle) -> Vector3d Source #

nvectorFromLatLong ll returns n-vector equivalent to the given (latitude, longitude) pair ll.

You should prefer using:

    nvector (latLongPos lat lon model)

nvectorToLatLong :: Vector3d -> (Angle, Angle) Source #

nvectorToLatLong nv returns (latitude, longitude) pair equivalent to the given n-vector nv.

You should prefer using:

    latLong (nvectorPos x y z model)

Latitude is always in [-90°, 90°] and longitude in [-180°, 180°].

nvectorFromGeocentric :: Vector3d -> Ellipsoid -> (Vector3d, Length) Source #

nvectorFromGeocentric g e returns the n-vector equivalent to the geocentric coordinates g using the ellispoid e.

You should prefer using:

    nvector (geocentricMetresPos x y z model)

nvectorToGeocentric :: (Vector3d, Length) -> Ellipsoid -> Vector3d Source #

nvectorToGeocentric (nv, h) e returns the geocentric coordinates equivalent to the given n-vector nv and height h using the ellispoid e.

You should prefer using:

    geocentric (nvectorHeightPos x y z h model)

Misc.

antipode :: Model a => Position a -> Position a Source #

antipode p computes the antipodal position of p: the position which is diametrically opposite to p.

latLong :: Model a => Position a -> (Double, Double) Source #

(latitude, longitude) pair in decimal degrees from given position.

latLong' :: Model a => Position a -> (Angle, Angle) Source #

(latitude, longitude) pair from given position.

northPole :: Model a => a -> Position a Source #

Horizontal position of the North Pole in the given model.

southPole :: Model a => a -> Position a Source #

Horizontal position of the South Pole in the given model.

nvNorthPole :: Vector3d Source #

Horizontal position of the North Pole (n-vector).

nvSouthPole :: Vector3d Source #

Horizontal position of the South Pole (n-vector).

re-exported for convenience