Class: IWCoordinate

IWCoordinate

A class representing a coordinate.

new IWCoordinate(x, y, projection)

Creates a new coordinate. If x and y are not specified (0, 0) is returned.
Parameters:
Name Type Description
x number horizontal coordinate
y number vertical coordinate
projection String projection type of this coordinate (optional, default is Mercator)

Extends

Members


<static> MERCATOR :String

Mercator Projection Type
Type:
  • String

<static> WGS84 :String

WGS84 Projection Type
Type:
  • String

Methods


bearingFrom(other)

Returns the bearing between the current point and another point. Uses the formula for bearing on a rhumb line (https://en.wikipedia.org/wiki/Rhumb_line): Δψ = ln( tan(π/4 + φ2/2) / tan(π/4 + φ1/2) ) ----> ("projected" latitude difference) θ = atan2(Δλ, Δψ) - where φ is latitude, λ is longitude, Δλ is taking shortest route (<180°), R is the earth’s radius, ln is natural log
Parameters:
Name Type Description
other IWCoordinate another coordinate
Returns:
Type
number

clone()

Returns a new instance of this object.
Overrides:
Returns:
Type
IWCoordinate

distanceFrom(other)

Returns the distance between this coordinate and another one in meters.
Parameters:
Name Type Description
other IWCoordinate another coordinate
Returns:
Type
number

equals(other)

Checks whether this coordinate equals another one (or is very close to it, i.e. in a range of 5 meters).
Parameters:
Name Type Description
other IWCoordinate another coordinate
Returns:
Type
boolean

getProjectionType()

Returns the projection type.
Returns:
Type
String

getX()

Returns the horizontal position of this coordinate.
Returns:
Type
number

getY()

Returns the vertical position of this coordinate in meters.
Returns:
Type
number

setProjectionType(projectionType)

Sets the projection type.
Parameters:
Name Type Description
projectionType String
Returns:
Type
void

setX(x)

Sets the horizontal position of this coordinate.
Parameters:
Name Type Description
x number
Returns:
Type
void

setY(y)

Sets the vertical position of this coordinate in meters.
Parameters:
Name Type Description
y number
Returns:
Type
void

squaredEuclideanDistanceFrom(other)

Returns the squared euclidean distance between this coordinate and another one. This is the fastest way to compare coordinates, e.g. to find the closest point on a route to a coordinate.
Parameters:
Name Type Description
other IWCoordinate another coordinate
Returns:
Type
number

toFormattedString()

Returns a compact string representation of this coordinate. For WGS84 coordinates this is latitude, longitude (e.g. "50.701508, 7.140887"), in all other cases x, y (e.g. "794920, 6568663").
Returns:
the coordinate string
Type
String

toMercator()

Projects the coordinate to Mercator. Returns a copy of the coordinate if it already is in Mercator.
Returns:
Type
IWCoordinate

toString()

Returns a string representation of this coordinate.
Returns:
Type
String

toWGS84()

Projects the coordinate to WGS 84. Returns a copy of the coordinate if it already is in WGS 84.
Returns:
Type
IWCoordinate