text: "use strict";
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.fromCartographic = fromCartographic;
  exports.fromCartographicToRadians = fromCartographicToRadians;
  exports.fromCartographicToDegrees = fromCartographicToDegrees;
  exports.toCartographic = toCartographic;
  exports.toCartographicFromRadians = toCartographicFromRadians;
  exports.toCartographicFromDegrees = toCartographicFromDegrees;
  exports.isWGS84 = isWGS84;
  
  var _math = require("math.gl");
  
  var _constants = require("./constants");
  
  var noop = function noop(x) {
    return x;
  };
  
  var scratchVector = new _math.Vector3();
  
  function fromCartographic(cartographic, vector) {
    var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
  
    if ((0, _math.isArray)(cartographic)) {
      vector[0] = map(cartographic[0]);
      vector[1] = map(cartographic[1]);
      vector[2] = cartographic[2];
    } else if ('longitude' in cartographic) {
      vector[0] = map(cartographic.longitude);
      vector[1] = map(cartographic.latitude);
      vector[2] = cartographic.height;
    } else {
      vector[0] = map(cartographic.x);
      vector[1] = map(cartographic.y);
      vector[2] = cartographic.z;
    }
  
    return vector;
  }
  
  function fromCartographicToRadians(cartographic) {
    var vector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scratchVector;
    return fromCartographic(cartographic, vector, _math.config.cartographicRadians ? noop : _math.toRadians);
  }
  
  function fromCartographicToDegrees(cartographic) {
    var vector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scratchVector;
    return fromCartographic(cartographic, vector, _math.config.cartographicRadians ? _math.toDegrees : noop);
  }
  
  function toCartographic(vector, cartographic) {
    var map = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
  
    if ((0, _math.isArray)(cartographic)) {
      cartographic[0] = map(vector[0]);
      cartographic[1] = map(vector[1]);
      cartographic[2] = vector[2];
    } else if ('longitude' in cartographic) {
      cartographic.longitude = map(vector[0]);
      cartographic.latitude = map(vector[1]);
      cartographic.height = vector[2];
    } else {
      cartographic.x = map(vector[0]);
      cartographic.y = map(vector[1]);
      cartographic.z = vector[2];
    }
  
    return cartographic;
  }
  
  function toCartographicFromRadians(vector, cartographic) {
    return toCartographic(vector, cartographic, _math.config.cartographicRadians ? noop : _math.toDegrees);
  }
  
  function toCartographicFromDegrees(vector, cartographic) {
    return toCartographic(vector, cartographic, _math.config.cartographicRadians ? _math.toRadians : noop);
  }
  
  function isWGS84(vector) {
    if (!vector) {
      return false;
    }
  
    scratchVector.from(vector);
    var oneOverRadiiSquared = _constants.WGS84_CONSTANTS.oneOverRadiiSquared,
        centerToleranceSquared = _constants.WGS84_CONSTANTS.centerToleranceSquared;
    var x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];
    var y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];
    var z2 = vector[2] * vector[2] * oneOverRadiiSquared[2];
    return Math.abs(x2 + y2 + z2 - 1) < centerToleranceSquared;
  }
  //# sourceMappingURL=type-utils.js.map