getValue static method

num getValue(
  1. Position position,
  2. int index
)

A coordinate value of position by the coordinate axis index.

Returns zero when a coordinate axis is not available.

For 2D coordinates the supported indexes are:

Index Projected Geographic
0 x lon
1 y lat
2 m m

For 3D coordinates the supported indexes are:

Index Projected Geographic
0 x lon
1 y lat
2 z elev
3 m m

Implementation

static num getValue(Position position, int index) {
  if (position.is3D) {
    switch (index) {
      case 0:
        return position.x;
      case 1:
        return position.y;
      case 2:
        return position.z;
      case 3:
        return position.m; // returns m or 0
      default:
        return 0;
    }
  } else {
    switch (index) {
      case 0:
        return position.x;
      case 1:
        return position.y;
      case 2:
        return position.m; // returns m or 0
      default:
        return 0;
    }
  }
}