Class: Coordinate

Coordinate

Represents a coordinate point
e.g.
A geographical point (longitude, latitude)

new Coordinate() [source]

var coord = new Coordinate(0, 0);
var coord = new Coordinate([ 0, 0 ]);
var coord = new Coordinate({ x : 0, y : 0 });
Extends:

Members

  • x

  • Inherited From:
    Properties:
    Name Type Description
    x Number x value
    Inherited From:
    Source:

  • y

  • Inherited From:
    Properties:
    Name Type Description
    y Number y value
    Inherited From:
    Source:

  • z

  • Inherited From:
    Properties:
    Name Type Description
    z Number z value, it's a pure property and doesn't take part in caculation for now.
    Inherited From:
    Source:

    Static Methods

  • (static) toNumberArrays(coordinates) [source]

  • Convert one or more Coordinate objects to GeoJSON style coordinates
    // result is [[100,0], [101,1]]
    var numCoords = Coordinate.toNumberArrays([new Coordinate(100,0), new Coordinate(101,1)]);
    Parameter Type Description
    coordinates Coordinate | Array.<Coordinate> coordinates to convert
    Returns:
    Array.<Number>|Array.<Array.<Number>>:
  • (static) toCoordinates(coordinates) [source]

  • Convert one or more GeoJSON style coordiantes to Coordinate objects
    var coordinates = Coordinate.toCoordinates([[100,0], [101,1]]);
    Parameter Type Description
    coordinates Array.<Number> | Array.<Array.<Number>> coordinates to convert
    Returns:
    Coordinate|Array.<Coordinate>:

    Methods

  • (inherited) set() [source]

  • Set point or coordinate's x, y value
    Inherited From:
    Returns:
    Coordinate|Point: this
  • (inherited) abs() [source]

  • Return abs value of the point
    Inherited From:
    Returns:
    Coordinate|Point: abs point
  • (inherited) round() [source]

  • Like math.round, rounding the point's xy.
    Inherited From:
    Returns:
    Coordinate|Point: rounded point
  • (inherited) distanceTo(point) [source]

  • Returns the distance between the current and the given point.
    Parameter Type Description
    point Coordinate | Point another point
    Inherited From:
    Returns:
    Number: distance
  • (inherited) mag() [source]

  • Return the magnitude of this point: this is the Euclidean distance from the 0, 0 coordinate to this point's x and y coordinates.
    Inherited From:
    Returns:
    Number: magnitude
  • (inherited) copy() [source]

  • Returns a copy of the coordinate
    Inherited From:
    Returns:
    Coordinate|Point: copy
  • (inherited) add(x, yopt) [source]

  • Returns the result of addition of another coordinate.
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) sub(x, yopt) [source]

  • Returns the result of subtraction of another coordinate.
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) substract(x, yopt) [source]

  • Alias for sub
    Parameter Type Description
    x Coordinate | Point | Array | Number coordinate to add
    y opt Number optional, coordinate to add
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) multi(ratio) [source]

  • Returns the result of multiplication of the current coordinate by the given number.
    Parameter Type Description
    ratio Number ratio to multi
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) div(n) [source]

  • Returns the result of division of the current point by the given number.
    Parameter Type Description
    n Number number to div
    Inherited From:
    Returns:
    Coordinate|Point: result
  • (inherited) equals(c) [source]

  • Compare with another coordinate to see whether they are equal.
    Parameter Type Description
    c Coordinate | Point coordinate to compare
    Inherited From:
    Returns:
    Boolean:
  • (inherited) isZero() [source]

  • Whether the coordinate/point is zero
    Inherited From:

  • (inherited) toArray() [source]

  • Convert to a number array [x, y]
    Inherited From:
    Returns:
    Array.<Number>: number array
  • (inherited) toFixed(n) [source]

  • Formats coordinate number using fixed-point notation.
    Parameter Type Description
    n Number The number of digits to appear after the decimal point
    Inherited From:
    Returns:
    Coordinate: fixed coordinate
  • (inherited) toJSON() [source]

  • Convert to a json object {x : .., y : ..}
    Inherited From:
    Returns:
    Object: json