Represents mesh coordinate, namely, discrete latitude and/or longitude.

This supports total ordering, and non-negative latitude and/or longitude only.

The coordinate has three digits, first, second and third, the first values 0 to 9, the second does 0 to 7 and the third does 0 to 99 inclusive.

We note that the third digit takes either 0 or 5 only on the mesh with MeshUnit.

const coord = new MeshCoord(1, 2, 3);

console.log(coord.first); // Prints 1
console.log(coord.second); // Prints 2
console.log(coord.third); // Prints 3

// Prints MeshCoord(first=1, second=2, third=3)
console.log(coord.toString());

Constructors

Accessors

  • get first(): First
  • The first digit of this, 0 to 99.

    Returns First

    const coord = new MeshCoord(1, 2, 3);
    console.log(coord.first); // Prints 1
  • get second(): Second
  • The second digit of this, 0 to 7.

    Returns Second

    const coord = new MeshCoord(1, 2, 3);
    console.log(coord.second); // Prints 2
  • get third(): Third
  • The third digit of this, 0 to 9.

    Returns Third

    const coord = new MeshCoord(1, 2, 3);
    console.log(coord.third); // Prints 3

Methods

  • Returns true is other is equal to this.

    Parameters

    • other: unknown

    Returns other is MeshCoord

    const coord = new MeshCoord(0, 0, 1);
    console.log(coord.eq(new MeshCoord(0, 0, 0))); // Prints true
    console.log(coord.eq(new MeshCoord(0, 0, 1))); // Prints false
  • Tests this is greater than or equal to other.

    Parameters

    Returns boolean

    const coord = new MeshCoord(0, 0, 1);
    console.log(coord.ge(new MeshCoord(0, 0, 0))); // Prints true
    console.log(coord.ge(new MeshCoord(0, 0, 1))); // Prints true
    console.log(coord.ge(new MeshCoord(0, 0, 2))); // Prints false
  • Tests this is greater than other.

    Parameters

    Returns boolean

    const coord = new MeshCoord(0, 0, 1);
    console.log(coord.gt(new MeshCoord(0, 0, 0))); // Prints true
    console.log(coord.gt(new MeshCoord(0, 0, 1))); // Prints false
    console.log(coord.gt(new MeshCoord(0, 0, 2))); // Prints false
  • Returns true if this is compatible to the meshUnit.

    Parameters

    • meshUnit: MeshUnit

      the mesh unit, 1 or 5

    Returns boolean

    true if this is compatible to the meshUnit

    const coord = new MeshCoord(1, 2, 3);
    console.log(coord.isMeshUnit(1)); // Prints true
    console.log(coord.isMeshUnit(5)); // Prints false
  • Tests this is less than or equal to other.

    Parameters

    Returns boolean

    const coord = new MeshCoord(0, 0, 1);
    console.log(coord.le(new MeshCoord(0, 0, 0))); // Prints false
    console.log(coord.le(new MeshCoord(0, 0, 1))); // Prints true
    console.log(coord.le(new MeshCoord(0, 0, 2))); // Prints true
  • Tests this is less than other.

    Parameters

    Returns boolean

    const coord = new MeshCoord(0, 0, 1);
    console.log(coord.lt(new MeshCoord(0, 0, 0))); // Prints false
    console.log(coord.lt(new MeshCoord(0, 0, 1))); // Prints false
    console.log(coord.lt(new MeshCoord(0, 0, 2))); // Prints true
  • Returns true is other is not equal to this.

    Parameters

    • other: unknown

    Returns boolean

    const coord = new MeshCoord(0, 0, 0);
    console.log(coord.ne(new MeshCoord(0, 0, 0))); // Prints false
    console.log(coord.ne(new MeshCoord(0, 0, 1))); // Prints true
  • Returns the greatest MeshCoord instance less than this.

    Parameters

    • meshUnit: MeshUnit

      The mesh unit, 1 or 5.

    Returns MeshCoord

    The next down MeshCoord.

    // Prints MeshCoord(first=0, second=0, third=0)
    console.log(new MeshCoord(0, 0, 1).nextDown(1));
    // Prints MeshCoord(first=0, second=0, third=9)
    console.log(new MeshCoord(0, 1, 0).nextDown(1));
    // Prints MeshCoord(first=0, second=7, third=9)
    console.log(new MeshCoord(1, 0, 0).nextDown(1));

    // Prints MeshCoord(first=0, second=0, third=0)
    console.log(new MeshCoord(0, 0, 5).nextDown(5));
    // Prints MeshCoord(first=0, second=0, third=5)
    console.log(new MeshCoord(0, 1, 0).nextDown(5));
    // Prints MeshCoord(first=0, second=7, third=5)
    console.log(new MeshCoord(1, 0, 0).nextDown(5));
  • Returns the smallest MeshCoord instance greater than this.

    Parameters

    • meshUnit: MeshUnit

      The mesh unit, 1 or 5.

    Returns MeshCoord

    The next up MeshCoord.

    // Prints MeshCoord(first=0, second=0, third=1)
    console.log(new MeshCoord(0, 0, 0).nextUp(1));
    // Prints MeshCoord(first=0, second=1, third=0)
    console.log(new MeshCoord(0, 0, 9).nextUp(1));
    // Prints MeshCoord(first=1, second=0, third=0)
    console.log(new MeshCoord(0, 7, 9).nextUp(1));

    // Prints MeshCoord(first=0, second=0, third=5)
    console.log(new MeshCoord(0, 0, 0).nextUp(5));
    // Prints MeshCoord(first=0, second=1, third=0)
    console.log(new MeshCoord(0, 0, 5).nextUp(5));
    // Prints MeshCoord(first=1, second=0, third=0)
    console.log(new MeshCoord(0, 7, 5).nextUp(5));
  • Returns the latitude that this converts into.

    Returns number

    The latitude [deg].

    const latitude = 36.103774791666666;

    let coord = MeshCoord.fromLatitude(latitude, 1);
    // Prints 36.1
    console.log(coord.toLatitude());

    let coord = MeshCoord.ofLatitude(latitude, 5);
    // Prints 36.083333333333336
    console.log(coord.toLatitude());
  • Returns the longitude that this converts into.

    Returns number

    The longitude [deg].

    const longitude = 140.08785504166664;

    let coord = MeshCoord.fromLongitude(longitude, 1);
    // Prints 140.0875
    console.log(coord.toLongitude());

    let coord = MeshCoord.fromLongitude(longitude, 5);
    // Prints 140.0625
    console.log(coord.toLongitude());
  • Returns string

    const coord = new MeshCoord(1, 2, 3);
    // Prints "MeshCoord(first=1, second=2, third=3)"
    console.log(coord.toString());
  • Makes the greatest MeshCoord instance less than the latitude with meshUnit.

    Parameters

    • degree: number

      the latitude [deg].

    • meshUnit: MeshUnit

      the mesh unit, 1 or 5.

    Returns MeshCoord

    let coord = MeshCoord.fromLatitude(36.103774791666666, 1);
    // Prints MeshCoord(first=54, second=1, third=2)
    console.log(coord.toString());

    let coord = MeshCoord.fromLatitude(36.103774791666666, 5);
    // Prints MeshCoord(first=54, second=1, third=0)
    console.log(coord.toString());
  • Makes the greatest MeshCoord instance less than the longitude with meshUnit.

    Parameters

    • degree: number

      The longitude [deg].

    • meshUnit: MeshUnit

      The mesh unit, 1 or 5.

    Returns MeshCoord

    let coord = MeshCoord.fromLongitude(140.08785504166664, 1);
    // Prints MeshCoord(first=40, second=0, third=7)
    console.log(coord.toString());

    let coord = MeshCoord.fromLongitude(140.08785504166664, 5);
    // Prints MeshCoord(first=40, second=0, third=5)
    console.log(coord).toString();