Class Coordinates

Represents coordinates associated with a coordinate reference system (CRS).

Hierarchy

  • Coordinates

Constructors

  • Build a Coordinates object, given a CRS and a number of coordinates value. Coordinates can be geocentric, geographic, or an instance of Vector3.

    Parameters

    • crs: string

      Geographic or Geocentric coordinates system.

    • Rest ...coordinates: Input

      The coordinates.

    Returns Coordinates

    Example

    new Coordinates('EPSG:4978', 20885167, 849862, 23385912); //Geocentric coordinates
    // or
    new Coordinates('EPSG:4978', new Vector3(20885167, 849862, 23385912)) // Same with a vector.
    // or
    new Coordinates('EPSG:4326', 2.33, 48.24, 24999549); //Geographic coordinates

Properties

_normal: Vector3
_values: Float64Array
crs: string

Accessors

  • get geodesicNormal(): Vector3
  • Returns the normal vector associated with this coordinate.

    Returns Vector3

    The normal vector.

  • get latitude(): number
  • Returns the latitude in geographic coordinates. Coordinates must be in geographic system (can be converted by using module:Core/geographic/Coordinates~Coordinates#as as() ).

    Returns number

    The latitude of the position.

    Example

    const position = { longitude: 2.33, latitude: 48.24, altitude: 24999549 };
    const coordinates = new Coordinates(
    'EPSG:4326', position.longitude, position.latitude, position.altitude); // Geographic
    coordinates.latitude; // Latitude in geographic system
    // returns : 48.24

    // or

    const position = { x: 20885167, y: 849862, z: 23385912 };
    // Geocentric system
    const coords = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    const coordinates = coords.as('EPSG:4326'); // Geographic system
    coordinates.latitude; // Latitude in geographic system
    // returns : 48.24830764643365
  • get longitude(): number
  • Returns the longitude in geographic coordinates. Coordinates must be in geographic system (can be converted by using module:Core/geographic/Coordinates~Coordinates#as as() ).

    Returns number

    The longitude of the position.

    Example

    const position = { longitude: 2.33, latitude: 48.24, altitude: 24999549 };
    const coordinates = new Coordinates(
    'EPSG:4326', position.longitude, position.latitude, position.altitude); // Geographic
    coordinates.longitude; // Longitude in geographic system
    // returns 2.33

    // or

    const position = { x: 20885167, y: 849862, z: 23385912 };
    // Geocentric system
    const coords = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    const coordinates = coords.as('EPSG:4326'); // Geographic system
    coordinates.longitude; // Longitude in geographic system
    // returns 2.330201911389028
  • get values(): Float64Array
  • Returns Float64Array

  • get x(): number
  • Returns the x component of this coordinate in geocentric coordinates. Coordinates must be in geocentric system (can be converted by using module:Core/geographic/Coordinates~Coordinates#as as()).

    Returns number

    The x component of the position.

    Example

    const position = { x: 20885167, y: 849862, z: 23385912 };
    const coordinates = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    coordinates.x; // Geocentric system
    // returns : 20885167

    // or

    const position = { longitude: 2.33, latitude: 48.24, altitude: 24999549 };
    // Geographic system
    const coords =
    new Coordinates('EPSG:4326', position.longitude, position.latitude, position.altitude);
    const coordinates = coords.as('EPSG:4978'); // Geocentric system
    coordinates.x; // Geocentric system
    // returns : 20888561.0301258
  • get y(): number
  • Returns the y component of this coordinate in geocentric coordinates. Coordinates must be in geocentric system (can be converted by using module:Core/geographic/Coordinates~Coordinates#as as()).

    Returns number

    The y component of the position.

    Example

    const position = { x: 20885167, y: 849862, z: 23385912 };
    const coordinates = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    coordinates.y; // Geocentric system
    // returns : 849862
  • get z(): number
  • Returns the z component of this coordinate in geocentric coordinates. Coordinates must be in geocentric system (can be converted by using module:Core/geographic/Coordinates~Coordinates#as as()).

    Returns number

    The z component of the position.

    Example

    const position = { x: 20885167, y: 849862, z: 23385912 };
    const coordinates = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    coordinates.z; // Geocentric system
    // returns : 23385912

Methods

  • Returns the altitude in geographic coordinates. Coordinates must be in geographic system(can be converted by using module:Core/geographic/Coordinates~Coordinates#as as() ).

    Returns number

    The altitude of the position.

    Example

    const position = { longitude: 2.33, latitude: 48.24, altitude: 24999549 };
    // Geographic system
    const coordinates =
    new Coordinates('EPSG:4326', position.longitude, position.latitude, position.altitude);
    coordinates.altitude(); // Altitude in geographic system
    // returns : 24999549

    // or

    const position = { x: 20885167, y: 849862, z: 23385912 };
    // Geocentric system
    const coords = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    const coordinates = coords.as('EPSG:4326'); // Geographic system
    coordinates.altitude(); // Altitude in geographic system
    // returns : 24999548.046711832
  • Converts coordinates in another CRS.

    If target is not specified, creates a new instance. The original instance is never modified (except if you passed it as target).

    Parameters

    • crs: string

      the CRS EPSG string

    • Optional target: Coordinates

      the object that is returned

    Returns Coordinates

    the converted coordinate

    Example

    const position = { longitude: 2.33, latitude: 48.24, altitude: 24999549 };
    // Geographic system
    const coords =
    new Coordinates('EPSG:4326', position.longitude, position.latitude, position.altitude);
    const coordinates = coords.as('EPSG:4978'); // Geocentric system
  • Returns the boolean result of the check if this coordinate is geographic (true) or geocentric (false).

    Returns boolean

    If the coordinate is geographic.

    Example

    const position = { x: 20885167, y: 849862, z: 23385912 };
    const coordinates = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    coordinates.isGeographic(); // Geocentric system
    // returns : false
  • Parameters

    • crs: string
    • Rest ...coordinates: Input

    Returns Coordinates

  • Set the altitude.

    Parameters

    • altitude: number

      the new altitude.

    Returns void

    Example

    coordinates.setAltitude(10000)
    
  • Returns the equivalent Vector2 of this coordinate. Coordinates must be in geocentric system (can be converted by using as()). Note that the Z component (elevation) is lost.

    Parameters

    • Optional target: Vector2

      the geocentric coordinate

    Returns Vector2

    target position

    Example

    const position = { x: 20885167, y: 849862, z: 23385912 };
    // Geocentric system
    const coordinates = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    coordinates.toVector2(); // Geocentric system
    // returns : Vector2
    // x: 20885167
    // y: 849862

    // or

    const position = { longitude: 2.33, latitude: 48.24, altitude: 24999549 };
    // Geographic system
    const coords =
    new Coordinates('EPSG:4326', position.longitude, position.latitude, position.altitude);
    const coordinates = coords.as('EPSG:4978'); // Geocentric system
    coordinates.toVector2(); // Geocentric system
    // returns : Vector2
    // x: 20885167
    // y: 849862
  • Returns the equivalent Vector3 of this coordinate. Coordinates must be in geocentric system (can be converted by using as()).

    Parameters

    • Optional target: Vector3

      the geocentric coordinate

    Returns Vector3

    target position

    Example

    const position = { x: 20885167, y: 849862, z: 23385912 };
    // Geocentric system
    const coordinates = new Coordinates('EPSG:4978', position.x, position.y, position.z);
    coordinates.toVector3(); // Geocentric system
    // returns : Vector3
    // x: 20885167
    // y: 849862
    // z: 23385912

    // or

    const position = { longitude: 2.33, latitude: 48.24, altitude: 24999549 };
    // Geographic system
    const coords =
    new Coordinates('EPSG:4326', position.longitude, position.latitude, position.altitude);
    const coordinates = coords.as('EPSG:4978'); // Geocentric system
    coordinates.toVector3(); // Geocentric system
    // returns : Vector3
    // x: 20885167
    // y: 849862
    // z: 23385912

Generated using TypeDoc