Class: LatLonEllipsoidal

latlon-ellipsoidal~LatLonEllipsoidal(lat, lon, heightopt)

Latitude/longitude points on an ellipsoidal model earth, with ellipsoid parameters and methods for converting points to/from cartesian (ECEF) coordinates. This is the core class, which will usually be used via LatLonEllipsoidal_Datum or LatLonEllipsoidal_ReferenceFrame.

Constructor

new LatLonEllipsoidal(lat, lon, heightopt)

Creates a geodetic latitude/longitude point on a (WGS84) ellipsoidal model earth.
Parameters:
Name Type Attributes Default Description
lat number Latitude (in degrees).
lon number Longitude (in degrees).
height number <optional>
0 Height above ellipsoid in metres.
Source:
Throws:
Invalid lat/lon/height.
Type
TypeError
Example
import LatLon from '/js/geodesy/latlon-ellipsoidal.js';
  const p = new LatLon(51.47788, -0.00147, 17);

Members

(static) datums

Datums; this module only defines WGS84 datum, hence no datum transformations.
Source:
Example
const a = LatLon.datums.WGS84.ellipsoid.a; // 6377563.396

(static) ellipsoids

Ellipsoids with their parameters; this module only defines WGS84 parameters a = 6378137, b = 6356752.314245, f = 1/298.257223563.
Source:
Example
const a = LatLon.ellipsoids.WGS84.a; // 6378137

height

Height in metres above ellipsoid.
Source:

lat

Latitude in degrees north from equator (including aliases lat, latitude): can be set as numeric or hexagesimal (deg-min-sec); returned as numeric.
Source:

lon

Longitude in degrees east from international reference meridian (including aliases lon, lng, longitude): can be set as numeric or hexagesimal (deg-min-sec); returned as numeric.
Source:

Methods

(static) parse(lat|latlon, lonopt, heightopt) → {LatLon}

Parses a latitude/longitude point from a variety of formats. Latitude & longitude (in degrees) can be supplied as two separate parameters, as a single comma-separated lat/lon string, or as a single object with { lat, lon } or GeoJSON properties. The latitude/longitude values may be numeric or strings; they may be signed decimal or deg-min-sec (hexagesimal) suffixed by compass direction (NSEW); a variety of separators are accepted. Examples -3.62, '3 37 12W', '3°37′12″W'. Thousands/decimal separators must be comma/dot; use Dms.fromLocale to convert locale-specific thousands/decimal separators.
Parameters:
Name Type Attributes Default Description
lat|latlon number | string | Object Latitude (in degrees), or comma-separated lat/lon, or lat/lon object.
lon number <optional>
Longitude (in degrees).
height number <optional>
0 Height above ellipsoid in metres.
Source:
Throws:
Invalid coordinate.
Type
TypeError
Returns:
Latitude/longitude point on WGS84 ellipsoidal model earth.
Type
LatLon
Example
const p1 = LatLon.parse(51.47788, -0.00147);              // numeric pair
  const p2 = LatLon.parse('51°28′40″N, 000°00′05″W', 17);   // dms string + height
  const p3 = LatLon.parse({ lat: 52.205, lon: 0.119 }, 17); // { lat, lon } object numeric + height

equals(point) → {bool}

Checks if another point is equal to ‘this’ point.
Parameters:
Name Type Description
point LatLon Point to be compared against this point.
Source:
Throws:
Invalid point.
Type
TypeError
Returns:
True if points have identical latitude, longitude, height, and datum/referenceFrame.
Type
bool
Example
const p1 = new LatLon(52.205, 0.119);
  const p2 = new LatLon(52.205, 0.119);
  const equal = p1.equals(p2); // true

toCartesian() → {Cartesian}

Converts ‘this’ point from (geodetic) latitude/longitude coordinates to (geocentric) cartesian (x/y/z) coordinates.
Source:
Returns:
Cartesian point equivalent to lat/lon point, with x, y, z in metres from earth centre.
Type
Cartesian

toString(formatopt, dpopt, dpHeightopt) → {string}

Returns a string representation of ‘this’ point, formatted as degrees, degrees+minutes, or degrees+minutes+seconds.
Parameters:
Name Type Attributes Default Description
format string <optional>
d Format point as 'd', 'dm', 'dms', or 'n' for signed numeric.
dp number <optional>
4|2|0 Number of decimal places to use: default 4 for d, 2 for dm, 0 for dms.
dpHeight number <optional>
null Number of decimal places to use for height; default is no height display.
Source:
Throws:
Invalid format.
Type
RangeError
Returns:
Comma-separated formatted latitude/longitude.
Type
string
Example
const greenwich = new LatLon(51.47788, -0.00147, 46);
  const d = greenwich.toString();                        // 51.4779°N, 000.0015°W
  const dms = greenwich.toString('dms', 2);              // 51°28′40″N, 000°00′05″W
  const [lat, lon] = greenwich.toString('n').split(','); // 51.4779, -0.0015
  const dmsh = greenwich.toString('dms', 0, 0);          // 51°28′40″N, 000°00′06″W +46m