Skip to main content

UserPosition

wemap-sdk-js


Class: UserPosition

A Coordinates User Position is a Coordinates position with specific data related to user (bearing, time, accuracy)

Extends

Constructors

Constructor

new UserPosition(lat, lng, alt?, level?, time?, accuracy?, bearing?): UserPosition

Parameters

lat

number

lng

number

alt?

number | null

level?

Level_t = null

time?

number | null

accuracy?

number | null

bearing?

number | null

Returns

UserPosition

Overrides

Coordinates.constructor

Properties

autoWrap

autoWrap: boolean = true

Inherited from

Coordinates.autoWrap

Accessors

accuracy

Get Signature

get accuracy(): number | null

Returns

number | null

Set Signature

set accuracy(accuracy): void

Parameters
accuracy

number | null

Returns

void


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

Inherited from

Coordinates.alt


bearing

Get Signature

get bearing(): number | null

Returns

number | null

Set Signature

set bearing(bearing): void

Parameters
bearing

number | null

Returns

void


ecef

Get Signature

get ecef(): Vector3_t

https://gist.github.com/klucar/1536194

Returns

Vector3_t

Inherited from

Coordinates.ecef


ecefToEnuRotation

Get Signature

get ecefToEnuRotation(): Quaternion_t

Returns

Quaternion_t

Inherited from

Coordinates.ecefToEnuRotation


enuToEcefRotation

Get Signature

get enuToEcefRotation(): Quaternion_t

ECEF Transformations (WGS84 ellipsoid)

Returns

Quaternion_t

Inherited from

Coordinates.enuToEcefRotation


heightFromFloor

Get Signature

get heightFromFloor(): number | null

Returns

number | null

Set Signature

set heightFromFloor(heightFromFloor): void

Parameters
heightFromFloor

number | null

Returns

void

Inherited from

Coordinates.heightFromFloor


heightFromGround

Get Signature

get heightFromGround(): number | null

Returns

number | null

Set Signature

set heightFromGround(heightFromGround): void

Parameters
heightFromGround

number | null

Returns

void

Inherited from

Coordinates.heightFromGround


lat

Get Signature

get lat(): number

Returns

number

Set Signature

set lat(lat): void

Parameters
lat

number

Returns

void

Inherited from

Coordinates.lat


latitude

Get Signature

get latitude(): number

Returns

number

Set Signature

set latitude(_): void

Parameters
_

number

Returns

void

Inherited from

Coordinates.latitude


level

Get Signature

get level(): Level_t

Returns

Level_t

Set Signature

set level(level): void

Parameters
level

Level_t

Returns

void

Inherited from

Coordinates.level


lng

Get Signature

get lng(): number

Returns

number

Set Signature

set lng(lng): void

Parameters
lng

number

Returns

void

Inherited from

Coordinates.lng


longitude

Get Signature

get longitude(): number

Returns

number

Set Signature

set longitude(_): void

Parameters
_

number

Returns

void

Inherited from

Coordinates.longitude


time

Get Signature

get time(): number | null

Returns

number | null

Set Signature

set time(time): void

Parameters
time

number | null

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

Inherited from

Coordinates.bearingTo


clone()

clone(): UserPosition

Deep clone coordinates

Returns

UserPosition

Overrides

Coordinates.clone


destinationPoint()

destinationPoint(distance, bearing, elevation?): UserPosition

Parameters

distance

number

bearing

number

elevation?

number | null

Returns

UserPosition

Throws

if elevation is defined and point altitude is not defined

Overrides

Coordinates.destinationPoint


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

Inherited from

Coordinates.distanceTo


equals()

equals(other, eps?, epsAlt?): boolean

Parameters

other

UserPosition | Coordinates | null

eps?

number = EPS_DEG_MM

epsAlt?

number = EPS_MM

Returns

boolean

Overrides

Coordinates.equals


equalsWithoutLevel()

equalsWithoutLevel(other, eps?, epsAlt?): boolean

Parameters

other

Coordinates

eps?

number = EPS_DEG_MM

epsAlt?

number = EPS_MM

Returns

boolean

Inherited from

Coordinates.equalsWithoutLevel


getSegmentProjection()

getSegmentProjection(p1, p2): Coordinates | null

https://stackoverflow.com/questions/1299567/how-to-calculate-distance-from-a-point-to-a-line-segment-on-a-sphere

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

Inherited from

Coordinates.getSegmentProjection


move()

move(distance, bearing, elevation?): UserPosition

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

UserPosition

Throws

if elevation is defined and point altitude is not defined

Overrides

Coordinates.move


toCompressedJson()

toCompressedJson(): CoordinatesCompressedJson

Returns

CoordinatesCompressedJson

Inherited from

Coordinates.toCompressedJson


toJson()

toJson(): UserPositionJson

Returns

UserPositionJson

Overrides

Coordinates.toJson


toString()

toString(): string

Input / Output

Returns

string

Inherited from

Coordinates.toString


wrap()

wrap(): void

Returns

void

Inherited from

Coordinates.wrap


bearingTo()

static bearingTo(point1, point2): number

Parameters

point1

Coordinates

point2

Coordinates

Returns

number

Inherited from

Coordinates.bearingTo


distanceBetween()

static distanceBetween(point1, point2): number

Parameters

point1

Coordinates

point2

Coordinates

Returns

number

Inherited from

Coordinates.distanceBetween


equals()

static equals(pos1, pos2, eps?, epsAlt?): boolean

Parameters

pos1

UserPosition | Coordinates | null

pos2

UserPosition | Coordinates | null

eps?

number = EPS_DEG_MM

epsAlt?

number = EPS_MM

Returns

boolean

Overrides

Coordinates.equals


equalsWithoutLevel()

static equalsWithoutLevel(pos1, pos2, eps?, epsAlt?): boolean

Parameters

pos1

Coordinates | null

pos2

Coordinates | null

eps?

number = EPS_DEG_MM

epsAlt?

number = EPS_MM

Returns

boolean

Inherited from

Coordinates.equalsWithoutLevel


fromCompressedJson()

static fromCompressedJson(json): Coordinates

Parameters

json

CoordinatesCompressedJson

Returns

Coordinates

Inherited from

Coordinates.fromCompressedJson


fromCoordinates()

static fromCoordinates(coordinates): UserPosition

Parameters

coordinates

Coordinates

Returns

UserPosition


fromECEF()

static fromECEF(ecef): Coordinates

Parameters

ecef

Vector3_t

Returns

Coordinates

Inherited from

Coordinates.fromECEF


fromJson()

static fromJson(json): UserPosition

Parameters

json

UserPositionJson

Returns

UserPosition

Overrides

Coordinates.fromJson