Coordinates
Class: Coordinates
A Coordinates position using at least latitude (lat) and longitude (lng). Optionnal fields are: altitude (alt) and level.
Basic geo methods are directly accessibles from here: distanceTo, bearingTo, toEcef...
Coordinates are WGS84 and every transformation here uses the ellipsoid, so the local up
axis is the ellipsoid normal and the ECEF / ENU geometry reads alt as a height above the
ellipsoid.
What alt actually carries is not settled across the SDK, and that predates this class:
the position providers put a height above the ground in it (Constants.DEFAULT_ALTITUDE is
1.6m, a phone in a hand), while GeoRef.localToWorld compares it against the absolute
floorAltitude / ceilingAltitude of a building level. Both cannot be right. Only differences
matter to the geometry here, which is why the ambiguity has never surfaced as a bug, but
level detection does depend on the answer.
(Until 2026-08 this class modelled the earth as a sphere of radius R_MAJOR for speed. That cost ~0.35% of anisotropic scale error at mid-latitude and tilted the local vertical by 11.5', i.e. ~33cm of altitude error per 100m of horizontal travel.)
Extended by
Constructors
Constructor
new Coordinates(
lat,lng,alt?,level?):Coordinates
Parameters
lat
number
lng
number
alt?
number | null
level?
Level_t = null
Returns
Coordinates
Properties
autoWrap
autoWrap:
boolean=true
Accessors
alt
Get Signature
get alt():
number|null
alt does not denote the altitude of a point but its height from the "level" field (if defined) or from the ground /!\ This is the providers' convention, not GeoRef's: see the class header.
Returns
number | null
Set Signature
set alt(
alt):void
Parameters
alt
number | null
Returns
void
ecef
Get Signature
get ecef():
Vector3_t
https://gist.github.com/klucar/1536194
Returns
Vector3_t
ecefToEnuRotation
Get Signature
get ecefToEnuRotation():
Quaternion_t
Returns
Quaternion_t
enuToEcefRotation
Get Signature
get enuToEcefRotation():
Quaternion_t
ECEF Transformations (WGS84 ellipsoid)
Returns
Quaternion_t
heightFromFloor
Get Signature
get heightFromFloor():
number|null
Returns
number | null
Set Signature
set heightFromFloor(
heightFromFloor):void
Parameters
heightFromFloor
number | null
Returns
void
heightFromGround
Get Signature
get heightFromGround():
number|null
Returns
number | null
Set Signature
set heightFromGround(
heightFromGround):void
Parameters
heightFromGround
number | null
Returns
void
lat
Get Signature
get lat():
number
Returns
number
Set Signature
set lat(
lat):void
Parameters
lat
number
Returns
void
latitude
Get Signature
get latitude():
number
Returns
number
Set Signature
set latitude(
_):void
Parameters
_
number
Returns
void
level
Get Signature
get level():
Level_t
Returns
Level_t
Set Signature
set level(
level):void
Parameters
level
Level_t
Returns
void
lng
Get Signature
get lng():
number
Returns
number
Set Signature
set lng(
lng):void
Parameters
lng
number
Returns
void
longitude
Get Signature
get longitude():
number
Returns
number
Set Signature
set longitude(
_):void
Parameters
_
number
Returns
void
Methods
bearingTo()
bearingTo(
location2):number
Azimuth to another point, in radians, clockwise from north. Taken in the local ENU frame, so it matches the true geodesic azimuth within 0.02" even at 100km.
Parameters
location2
Coordinates
Returns
number
clone()
clone():
Coordinates
Deep clone coordinates
Returns
Coordinates
destinationPoint()
destinationPoint(
distance,bearing,elevation?):Coordinates
Parameters
distance
number
bearing
number
elevation?
number | null
Returns
Coordinates
Throws
if elevation is defined and point altitude is not defined
distanceTo()
distanceTo(
location2):number
Returns the ground distance between two points in meters, on the WGS84 ellipsoid. Altitudes are ignored, as many callers compare positions across levels.
The chord between the two ECEF points is exact; converting it back to an arc length on the locally fitting sphere is what costs accuracy, and it costs very little: 3nm at 340m, 3um at 14km, 1.2m at 557km.
The one case where this is worse than the old haversine is a path along the equator, where the arc radius is R_MAJOR but the Gaussian radius is R_MINOR: 264m over 3340km, 9.3km over 10000km, against an exact haversine there. Everywhere else, and at every distance this SDK works at, it is orders of magnitude better.
Parameters
location2
Coordinates
Returns
number
equals()
equals(
other):boolean
Parameters
other
Coordinates
Returns
boolean
equalsWithoutLevel()
equalsWithoutLevel(
other,eps?,epsAlt?):boolean
Parameters
other
Coordinates
eps?
number = EPS_DEG_MM
epsAlt?
number = EPS_MM
Returns
boolean
getSegmentProjection()
getSegmentProjection(
p1,p2):Coordinates|null
Great-circle geometry, so it stays on the sphere: normalizing an ellipsoidal ECEF vector would yield a geocentric direction and shift the projection by tens of meters. The closure test that rejects a point off the segment measures angles between the same unit vectors, for the same reason: mixing in the geodesic distanceTo would compare a great circle with a geodesic and reject valid projections on long segments.
Parameters
p1
Coordinates
p2
Coordinates
Returns
Coordinates | null
move()
move(
distance,bearing,elevation?):Coordinates
Moves the point by a ground distance (in meters) along a bearing, on the WGS84 ellipsoid. The displacement is built in the local ENU frame as the chord of the arc travelled, then converted back through ECEF. ponytail: micrometer-accurate at working range (7um at 10km), then degrades as distance^3 / radius^2 (7mm at 100km, ~20m at 1200km). Use Karney's geodesics if continental distances ever matter.
Parameters
distance
number
bearing
number
elevation?
number | null
Returns
Coordinates
Throws
if elevation is defined and point altitude is not defined
toCompressedJson()
toCompressedJson():
CoordinatesCompressedJson
Returns
CoordinatesCompressedJson
toJson()
toJson():
CoordinatesJson
Returns
CoordinatesJson
toString()
toString():
string
Input / Output
Returns
string
wrap()
wrap():
void
Returns
void
bearingTo()
staticbearingTo(point1,point2):number
Parameters
point1
Coordinates
point2
Coordinates
Returns
number
distanceBetween()
staticdistanceBetween(point1,point2):number
Parameters
point1
Coordinates
point2
Coordinates
Returns
number
equals()
staticequals(pos1,pos2,eps?,epsAlt?):boolean
Parameters
pos1
Coordinates | null
pos2
Coordinates | null
eps?
number = EPS_DEG_MM
epsAlt?
number = EPS_MM
Returns
boolean
equalsWithoutLevel()
staticequalsWithoutLevel(pos1,pos2,eps?,epsAlt?):boolean
Parameters
pos1
Coordinates | null
pos2
Coordinates | null
eps?
number = EPS_DEG_MM
epsAlt?
number = EPS_MM
Returns
boolean
fromCompressedJson()
staticfromCompressedJson(json):Coordinates
Parameters
json
CoordinatesCompressedJson
Returns
Coordinates
fromECEF()
staticfromECEF(ecef):Coordinates
Parameters
ecef
Vector3_t
Returns
Coordinates
fromJson()
staticfromJson(json):Coordinates
Parameters
json
CoordinatesJson
Returns
Coordinates