"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _util = require("../util");
var _gcj = _interopRequireDefault(require("./gcj-02"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
var PI = Math.PI;
var X_PI = PI * 3000 / 180;
var toGCJ02 = (0, _util.forEachPoint)(function (input, output, offset) {
  var x = input[offset] - 0.0065;
  var y = input[offset + 1] - 0.006;
  var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI);
  var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI);
  output[offset] = z * Math.cos(theta);
  output[offset + 1] = z * Math.sin(theta);
  return output;
});
var fromGCJ02 = (0, _util.forEachPoint)(function (input, output, offset) {
  var x = input[offset];
  var y = input[offset + 1];
  var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI);
  var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI);
  output[offset] = z * Math.cos(theta) + 0.0065;
  output[offset + 1] = z * Math.sin(theta) + 0.006;
  return output;
});
var toWGS84 = function toWGS84(input, opt_output, opt_dimension) {
  var output = toGCJ02(input, opt_output, opt_dimension);
  return _gcj["default"].toWGS84(output, output, opt_dimension);
};
var fromWGS84 = function fromWGS84(input, opt_output, opt_dimension) {
  var output = _gcj["default"].fromWGS84(input, opt_output, opt_dimension);
  return fromGCJ02(output, output, opt_dimension);
};
var _default = exports["default"] = {
  toWGS84: toWGS84,
  fromWGS84: fromWGS84,
  toGCJ02: toGCJ02,
  fromGCJ02: fromGCJ02
};
//# sourceMappingURL=bd-09.js.map
