@supermapgis/iclient-maplibregl
Version:
@supermapgis/iclient-maplibregl 是一套基于 Maplibre GL 的云 GIS 网络客户端开发平台, 支持访问 SuperMap iServer / iEdge / iPortal / iManager / Online 的地图、服务和资源,为用户提供了完整专业的 GIS 能力, 同时提供了优秀的可视化功能。
1,569 lines (1,546 loc) • 8.06 MB
JavaScript
/*!
*
* iclient-maplibregl
* Copyright© 2000 - 2026 SuperMap Software Co.Ltd
* license: Apache-2.0
* version: v12.1.0-r
*
*/
/******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 1358:
/***/ (function(module) {
(function (self) {
'use strict';
// if __disableNativeFetch is set to true, the it will always polyfill fetch
// with Ajax.
if (!self.__disableNativeFetch && self.fetch) {
return;
}
function normalizeName(name) {
if (typeof name !== 'string') {
name = String(name);
}
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name');
}
return name.toLowerCase();
}
function normalizeValue(value) {
if (typeof value !== 'string') {
value = String(value);
}
return value;
}
function Headers(headers) {
this.map = {};
if (headers instanceof Headers) {
headers.forEach(function (value, name) {
this.append(name, value);
}, this);
} else if (headers) {
Object.getOwnPropertyNames(headers).forEach(function (name) {
this.append(name, headers[name]);
}, this);
}
}
Headers.prototype.append = function (name, value) {
name = normalizeName(name);
value = normalizeValue(value);
var list = this.map[name];
if (!list) {
list = [];
this.map[name] = list;
}
list.push(value);
};
Headers.prototype['delete'] = function (name) {
delete this.map[normalizeName(name)];
};
Headers.prototype.get = function (name) {
var values = this.map[normalizeName(name)];
return values ? values[0] : null;
};
Headers.prototype.getAll = function (name) {
return this.map[normalizeName(name)] || [];
};
Headers.prototype.has = function (name) {
return this.map.hasOwnProperty(normalizeName(name));
};
Headers.prototype.set = function (name, value) {
this.map[normalizeName(name)] = [normalizeValue(value)];
};
Headers.prototype.forEach = function (callback, thisArg) {
Object.getOwnPropertyNames(this.map).forEach(function (name) {
this.map[name].forEach(function (value) {
callback.call(thisArg, value, name, this);
}, this);
}, this);
};
function consumed(body) {
if (body.bodyUsed) {
return Promise.reject(new TypeError('Already read'));
}
body.bodyUsed = true;
}
function fileReaderReady(reader) {
return new Promise(function (resolve, reject) {
reader.onload = function () {
resolve(reader.result);
};
reader.onerror = function () {
reject(reader.error);
};
});
}
function readBlobAsArrayBuffer(blob) {
var reader = new FileReader();
reader.readAsArrayBuffer(blob);
return fileReaderReady(reader);
}
function readBlobAsText(blob, options) {
var reader = new FileReader();
var contentType = options.headers.map['content-type'] ? options.headers.map['content-type'].toString() : '';
var regex = /charset\=[0-9a-zA-Z\-\_]*;?/;
var _charset = blob.type.match(regex) || contentType.match(regex);
var args = [blob];
if (_charset) {
args.push(_charset[0].replace(/^charset\=/, '').replace(/;$/, ''));
}
reader.readAsText.apply(reader, args);
return fileReaderReady(reader);
}
var support = {
blob: 'FileReader' in self && 'Blob' in self && function () {
try {
new Blob();
return true;
} catch (e) {
return false;
}
}(),
formData: 'FormData' in self,
arrayBuffer: 'ArrayBuffer' in self
};
function Body() {
this.bodyUsed = false;
this._initBody = function (body, options) {
this._bodyInit = body;
if (typeof body === 'string') {
this._bodyText = body;
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
this._bodyBlob = body;
this._options = options;
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body;
} else if (!body) {
this._bodyText = '';
} else if (support.arrayBuffer && ArrayBuffer.prototype.isPrototypeOf(body)) {
// Only support ArrayBuffers for POST method.
// Receiving ArrayBuffers happens via Blobs, instead.
} else {
throw new Error('unsupported BodyInit type');
}
};
if (support.blob) {
this.blob = function () {
var rejected = consumed(this);
if (rejected) {
return rejected;
}
if (this._bodyBlob) {
return Promise.resolve(this._bodyBlob);
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as blob');
} else {
return Promise.resolve(new Blob([this._bodyText]));
}
};
this.arrayBuffer = function () {
return this.blob().then(readBlobAsArrayBuffer);
};
this.text = function () {
var rejected = consumed(this);
if (rejected) {
return rejected;
}
if (this._bodyBlob) {
return readBlobAsText(this._bodyBlob, this._options);
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as text');
} else {
return Promise.resolve(this._bodyText);
}
};
} else {
this.text = function () {
var rejected = consumed(this);
return rejected ? rejected : Promise.resolve(this._bodyText);
};
}
if (support.formData) {
this.formData = function () {
return this.text().then(decode);
};
}
this.json = function () {
return this.text().then(JSON.parse);
};
return this;
}
// HTTP methods whose capitalization should be normalized
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
function normalizeMethod(method) {
var upcased = method.toUpperCase();
return methods.indexOf(upcased) > -1 ? upcased : method;
}
function Request(input, options) {
options = options || {};
var body = options.body;
if (Request.prototype.isPrototypeOf(input)) {
if (input.bodyUsed) {
throw new TypeError('Already read');
}
this.url = input.url;
this.credentials = input.credentials;
if (!options.headers) {
this.headers = new Headers(input.headers);
}
this.method = input.method;
this.mode = input.mode;
if (!body) {
body = input._bodyInit;
input.bodyUsed = true;
}
} else {
this.url = input;
}
this.credentials = options.credentials || this.credentials || 'omit';
if (options.headers || !this.headers) {
this.headers = new Headers(options.headers);
}
this.method = normalizeMethod(options.method || this.method || 'GET');
this.mode = options.mode || this.mode || null;
this.referrer = null;
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
throw new TypeError('Body not allowed for GET or HEAD requests');
}
this._initBody(body, options);
}
Request.prototype.clone = function () {
return new Request(this);
};
function decode(body) {
var form = new FormData();
body.trim().split('&').forEach(function (bytes) {
if (bytes) {
var split = bytes.split('=');
var name = split.shift().replace(/\+/g, ' ');
var value = split.join('=').replace(/\+/g, ' ');
form.append(decodeURIComponent(name), decodeURIComponent(value));
}
});
return form;
}
function headers(xhr) {
var head = new Headers();
var pairs = xhr.getAllResponseHeaders().trim().split('\n');
pairs.forEach(function (header) {
var split = header.trim().split(':');
var key = split.shift().trim();
var value = split.join(':').trim();
head.append(key, value);
});
return head;
}
Body.call(Request.prototype);
function Response(bodyInit, options) {
if (!options) {
options = {};
}
this._initBody(bodyInit, options);
this.type = 'default';
this.status = options.status;
this.ok = this.status >= 200 && this.status < 300;
this.statusText = options.statusText;
this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
this.url = options.url || '';
}
Body.call(Response.prototype);
Response.prototype.clone = function () {
return new Response(this._bodyInit, {
status: this.status,
statusText: this.statusText,
headers: new Headers(this.headers),
url: this.url
});
};
Response.error = function () {
var response = new Response(null, {
status: 0,
statusText: ''
});
response.type = 'error';
return response;
};
var redirectStatuses = [301, 302, 303, 307, 308];
Response.redirect = function (url, status) {
if (redirectStatuses.indexOf(status) === -1) {
throw new RangeError('Invalid status code');
}
return new Response(null, {
status: status,
headers: {
location: url
}
});
};
self.Headers = Headers;
self.Request = Request;
self.Response = Response;
self.fetch = function (input, init) {
return new Promise(function (resolve, reject) {
var request;
if (Request.prototype.isPrototypeOf(input) && !init) {
request = input;
} else {
request = new Request(input, init);
}
var xhr = new XMLHttpRequest();
function responseURL() {
if ('responseURL' in xhr) {
return xhr.responseURL;
}
// Avoid security warnings on getResponseHeader when not allowed by CORS
if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) {
return xhr.getResponseHeader('X-Request-URL');
}
return;
}
var __onLoadHandled = false;
function onload() {
if (xhr.readyState !== 4) {
return;
}
var status = xhr.status === 1223 ? 204 : xhr.status;
if (status < 100 || status > 599) {
if (__onLoadHandled) {
return;
} else {
__onLoadHandled = true;
}
reject(new TypeError('Network request failed'));
return;
}
var options = {
status: status,
statusText: xhr.statusText,
headers: headers(xhr),
url: responseURL()
};
var body = 'response' in xhr ? xhr.response : xhr.responseText;
if (__onLoadHandled) {
return;
} else {
__onLoadHandled = true;
}
resolve(new Response(body, options));
}
xhr.onreadystatechange = onload;
xhr.onload = onload;
xhr.onerror = function () {
if (__onLoadHandled) {
return;
} else {
__onLoadHandled = true;
}
reject(new TypeError('Network request failed'));
};
xhr.open(request.method, request.url, true);
// `withCredentials` should be setted after calling `.open` in IE10
// http://stackoverflow.com/a/19667959/1219343
try {
if (request.credentials === 'include') {
if ('withCredentials' in xhr) {
xhr.withCredentials = true;
} else {
console && console.warn && console.warn('withCredentials is not supported, you can ignore this warning');
}
}
} catch (e) {
console && console.warn && console.warn('set withCredentials error:' + e);
}
if ('responseType' in xhr && support.blob) {
xhr.responseType = 'blob';
}
request.headers.forEach(function (value, name) {
xhr.setRequestHeader(name, value);
});
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
});
};
self.fetch.polyfill = true;
// Support CommonJS
if ( true && module.exports) {
module.exports = self.fetch;
}
})(typeof self !== 'undefined' ? self : this);
/***/ }),
/***/ 3678:
/***/ (function(module, exports) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [exports, module], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else // removed by dead control flow
{ var mod; }
})(this, function (exports, module) {
'use strict';
var defaultOptions = {
timeout: 5000,
jsonpCallback: 'callback',
jsonpCallbackFunction: null
};
function generateCallbackFunction() {
return 'jsonp_' + Date.now() + '_' + Math.ceil(Math.random() * 100000);
}
function clearFunction(functionName) {
// IE8 throws an exception when you try to delete a property on window
// http://stackoverflow.com/a/1824228/751089
try {
delete window[functionName];
} catch (e) {
window[functionName] = undefined;
}
}
function removeScript(scriptId) {
var script = document.getElementById(scriptId);
if (script) {
document.getElementsByTagName('head')[0].removeChild(script);
}
}
function fetchJsonp(_url) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
// to avoid param reassign
var url = _url;
var timeout = options.timeout || defaultOptions.timeout;
var jsonpCallback = options.jsonpCallback || defaultOptions.jsonpCallback;
var timeoutId = undefined;
return new Promise(function (resolve, reject) {
var callbackFunction = options.jsonpCallbackFunction || generateCallbackFunction();
var scriptId = jsonpCallback + '_' + callbackFunction;
window[callbackFunction] = function (response) {
resolve({
ok: true,
// keep consistent with fetch API
json: function json() {
return Promise.resolve(response);
}
});
if (timeoutId) clearTimeout(timeoutId);
removeScript(scriptId);
clearFunction(callbackFunction);
};
// Check if the user set their own params, and if not add a ? to start a list of params
url += url.indexOf('?') === -1 ? '?' : '&';
var jsonpScript = document.createElement('script');
jsonpScript.setAttribute('src', '' + url + jsonpCallback + '=' + callbackFunction);
if (options.charset) {
jsonpScript.setAttribute('charset', options.charset);
}
jsonpScript.id = scriptId;
document.getElementsByTagName('head')[0].appendChild(jsonpScript);
timeoutId = setTimeout(function () {
reject(new Error('JSONP request to ' + _url + ' timed out'));
clearFunction(callbackFunction);
removeScript(scriptId);
window[callbackFunction] = function () {
clearFunction(callbackFunction);
};
}, timeout);
// Caught if got 404/500
jsonpScript.onerror = function () {
reject(new Error('JSONP request to ' + _url + ' failed'));
clearFunction(callbackFunction);
removeScript(scriptId);
if (timeoutId) clearTimeout(timeoutId);
};
});
}
// export as global function
/*
let local;
if (typeof global !== 'undefined') {
local = global;
} else if (typeof self !== 'undefined') {
local = self;
} else {
try {
local = Function('return this')();
} catch (e) {
throw new Error('polyfill failed because global object is unavailable in this environment');
}
}
local.fetchJsonp = fetchJsonp;
*/
module.exports = fetchJsonp;
});
/***/ }),
/***/ 8461:
/***/ (function(module, exports, __webpack_require__) {
/* module decorator */ module = __webpack_require__.nmd(module);
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
(function (cb) {
var geodesic = {};
geodesic.Constants = {};
geodesic.Math = {};
geodesic.Accumulator = {};
(function (c) {
"use strict";
c.WGS84 = {
a: 6378137,
f: 1 / 298.257223563
};
c.version = {
major: 2,
minor: 2,
patch: 0
};
c.version_string = "2.2.0";
})(geodesic.Constants);
(function (m) {
"use strict";
m.digits = 53;
m.epsilon = Math.pow(0.5, m.digits - 1);
m.degree = Math.PI / 180;
m.sq = function (x) {
return x * x;
};
m.hypot = function (x, y) {
return Math.sqrt(x * x + y * y);
};
m.cbrt = Math.cbrt || function (x) {
var y = Math.pow(Math.abs(x), 1 / 3);
return x > 0 ? y : x < 0 ? -y : x;
};
m.log1p = Math.log1p || function (x) {
var y = 1 + x,
z = y - 1;
return z === 0 ? x : x * Math.log(y) / z;
};
m.atanh = Math.atanh || function (x) {
var y = Math.abs(x);
y = m.log1p(2 * y / (1 - y)) / 2;
return x > 0 ? y : x < 0 ? -y : x;
};
m.copysign = function (x, y) {
return Math.abs(x) * (y < 0 || y === 0 && 1 / y < 0 ? -1 : 1);
};
m.sum = function (u, v) {
var s = u + v,
up = s - v,
vpp = s - up,
t;
up -= u;
vpp -= v;
t = s ? 0 - (up + vpp) : s;
return {
s: s,
t: t
};
};
m.polyval = function (N, p, s, x) {
var y = N < 0 ? 0 : p[s++];
while (--N >= 0) y = y * x + p[s++];
return y;
};
m.AngRound = function (x) {
var z = 1 / 16,
y = Math.abs(x);
y = y < z ? z - (z - y) : y;
return m.copysign(y, x);
};
m.remainder = function (x, y) {
x %= y;
return x < -y / 2 ? x + y : x < y / 2 ? x : x - y;
};
m.AngNormalize = function (x) {
var y = m.remainder(x, 360);
return Math.abs(y) === 180 ? m.copysign(180, x) : y;
};
m.LatFix = function (x) {
return Math.abs(x) > 90 ? NaN : x;
};
m.AngDiff = function (x, y) {
var r = m.sum(m.remainder(-x, 360), m.remainder(y, 360)),
d,
e;
r = m.sum(m.remainder(r.s, 360), r.t);
d = r.s;
e = r.t;
if (d === 0 || Math.abs(d) === 180) d = m.copysign(d, e === 0 ? y - x : -e);
return {
d: d,
e: e
};
};
m.sincosd = function (x) {
var d, r, q, s, c, sinx, cosx;
d = x % 360;
q = Math.round(d / 90);
d -= 90 * q;
r = d * this.degree;
s = Math.sin(r);
c = Math.cos(r);
if (Math.abs(d) === 45) {
c = Math.sqrt(0.5);
s = m.copysign(c, r);
} else if (Math.abs(d) === 30) {
c = Math.sqrt(0.75);
s = m.copysign(0.5, r);
}
switch (q & 3) {
case 0:
sinx = s;
cosx = c;
break;
case 1:
sinx = c;
cosx = -s;
break;
case 2:
sinx = -s;
cosx = -c;
break;
default:
sinx = -c;
cosx = s;
break;
}
cosx += 0;
if (sinx === 0) sinx = m.copysign(sinx, x);
return {
s: sinx,
c: cosx
};
};
m.sincosde = function (x, t) {
var d, r, q, s, c, sinx, cosx;
d = x % 360;
q = Math.round(d / 90);
d = m.AngRound(d - 90 * q + t);
r = d * this.degree;
s = Math.sin(r);
c = Math.cos(r);
if (Math.abs(d) === 45) {
c = Math.sqrt(0.5);
s = m.copysign(c, r);
} else if (Math.abs(d) === 30) {
c = Math.sqrt(0.75);
s = m.copysign(0.5, r);
}
switch (q & 3) {
case 0:
sinx = s;
cosx = c;
break;
case 1:
sinx = c;
cosx = -s;
break;
case 2:
sinx = -s;
cosx = -c;
break;
default:
sinx = -c;
cosx = s;
break;
}
cosx += 0;
if (sinx === 0) sinx = m.copysign(sinx, x + t);
return {
s: sinx,
c: cosx
};
};
m.atan2d = function (y, x) {
var q = 0,
ang;
if (Math.abs(y) > Math.abs(x)) {
var _ref = [x, y];
y = _ref[0];
x = _ref[1];
q = 2;
}
if (m.copysign(1, x) < 0) {
x = -x;
++q;
}
ang = Math.atan2(y, x) / this.degree;
switch (q) {
case 1:
ang = m.copysign(180, y) - ang;
break;
case 2:
ang = 90 - ang;
break;
case 3:
ang = -90 + ang;
break;
default:
break;
}
return ang;
};
})(geodesic.Math);
(function (a, m) {
"use strict";
a.Accumulator = function (y) {
this.Set(y);
};
a.Accumulator.prototype.Set = function (y) {
if (!y) y = 0;
if (y.constructor === a.Accumulator) {
this._s = y._s;
this._t = y._t;
} else {
this._s = y;
this._t = 0;
}
};
a.Accumulator.prototype.Add = function (y) {
var u = m.sum(y, this._t),
v = m.sum(u.s, this._s);
u = u.t;
this._s = v.s;
this._t = v.t;
if (this._s === 0) this._s = u;else this._t += u;
};
a.Accumulator.prototype.Sum = function (y) {
var b;
if (!y) return this._s;else {
b = new a.Accumulator(this);
b.Add(y);
return b._s;
}
};
a.Accumulator.prototype.Negate = function () {
this._s *= -1;
this._t *= -1;
};
a.Accumulator.prototype.Remainder = function (y) {
this._s = m.remainder(this._s, y);
this.Add(0);
};
})(geodesic.Accumulator, geodesic.Math);
geodesic.Geodesic = {};
geodesic.GeodesicLine = {};
geodesic.PolygonArea = {};
(function (g, l, p, m, c) {
"use strict";
var GEOGRAPHICLIB_GEODESIC_ORDER = 6,
nA1_ = GEOGRAPHICLIB_GEODESIC_ORDER,
nA2_ = GEOGRAPHICLIB_GEODESIC_ORDER,
nA3_ = GEOGRAPHICLIB_GEODESIC_ORDER,
nA3x_ = nA3_,
nC3x_,
nC4x_,
maxit1_ = 20,
maxit2_ = maxit1_ + m.digits + 10,
tol0_ = m.epsilon,
tol1_ = 200 * tol0_,
tol2_ = Math.sqrt(tol0_),
tolb_ = tol0_,
xthresh_ = 1000 * tol2_,
CAP_NONE = 0,
CAP_ALL = 0x1F,
OUT_ALL = 0x7F80,
astroid,
A1m1f_coeff,
C1f_coeff,
C1pf_coeff,
A2m1f_coeff,
C2f_coeff,
A3_coeff,
C3_coeff,
C4_coeff;
g.tiny_ = Math.sqrt(Number.MIN_VALUE / Number.EPSILON);
g.nC1_ = GEOGRAPHICLIB_GEODESIC_ORDER;
g.nC1p_ = GEOGRAPHICLIB_GEODESIC_ORDER;
g.nC2_ = GEOGRAPHICLIB_GEODESIC_ORDER;
g.nC3_ = GEOGRAPHICLIB_GEODESIC_ORDER;
g.nC4_ = GEOGRAPHICLIB_GEODESIC_ORDER;
nC3x_ = g.nC3_ * (g.nC3_ - 1) / 2;
nC4x_ = g.nC4_ * (g.nC4_ + 1) / 2;
g.CAP_C1 = 1 << 0;
g.CAP_C1p = 1 << 1;
g.CAP_C2 = 1 << 2;
g.CAP_C3 = 1 << 3;
g.CAP_C4 = 1 << 4;
g.NONE = 0;
g.ARC = 1 << 6;
g.LATITUDE = 1 << 7 | CAP_NONE;
g.LONGITUDE = 1 << 8 | g.CAP_C3;
g.AZIMUTH = 1 << 9 | CAP_NONE;
g.DISTANCE = 1 << 10 | g.CAP_C1;
g.STANDARD = g.LATITUDE | g.LONGITUDE | g.AZIMUTH | g.DISTANCE;
g.DISTANCE_IN = 1 << 11 | g.CAP_C1 | g.CAP_C1p;
g.REDUCEDLENGTH = 1 << 12 | g.CAP_C1 | g.CAP_C2;
g.GEODESICSCALE = 1 << 13 | g.CAP_C1 | g.CAP_C2;
g.AREA = 1 << 14 | g.CAP_C4;
g.ALL = OUT_ALL | CAP_ALL;
g.LONG_UNROLL = 1 << 15;
g.OUT_MASK = OUT_ALL | g.LONG_UNROLL;
g.SinCosSeries = function (sinp, sinx, cosx, c) {
var k = c.length,
n = k - (sinp ? 1 : 0),
ar = 2 * (cosx - sinx) * (cosx + sinx),
y0 = n & 1 ? c[--k] : 0,
y1 = 0;
n = Math.floor(n / 2);
while (n--) {
y1 = ar * y0 - y1 + c[--k];
y0 = ar * y1 - y0 + c[--k];
}
return sinp ? 2 * sinx * cosx * y0 : cosx * (y0 - y1);
};
astroid = function astroid(x, y) {
var k,
p = m.sq(x),
q = m.sq(y),
r = (p + q - 1) / 6,
S,
r2,
r3,
disc,
u,
T3,
T,
ang,
v,
uv,
w;
if (!(q === 0 && r <= 0)) {
S = p * q / 4;
r2 = m.sq(r);
r3 = r * r2;
disc = S * (S + 2 * r3);
u = r;
if (disc >= 0) {
T3 = S + r3;
T3 += T3 < 0 ? -Math.sqrt(disc) : Math.sqrt(disc);
T = m.cbrt(T3);
u += T + (T !== 0 ? r2 / T : 0);
} else {
ang = Math.atan2(Math.sqrt(-disc), -(S + r3));
u += 2 * r * Math.cos(ang / 3);
}
v = Math.sqrt(m.sq(u) + q);
uv = u < 0 ? q / (v - u) : u + v;
w = (uv - q) / (2 * v);
k = uv / (Math.sqrt(uv + m.sq(w)) + w);
} else {
k = 0;
}
return k;
};
A1m1f_coeff = [+1, 4, 64, 0, 256];
g.A1m1f = function (eps) {
var p = Math.floor(nA1_ / 2),
t = m.polyval(p, A1m1f_coeff, 0, m.sq(eps)) / A1m1f_coeff[p + 1];
return (t + eps) / (1 - eps);
};
C1f_coeff = [-1, 6, -16, 32, -9, 64, -128, 2048, +9, -16, 768, +3, -5, 512, -7, 1280, -7, 2048];
g.C1f = function (eps, c) {
var eps2 = m.sq(eps),
d = eps,
o = 0,
l,
p;
for (l = 1; l <= g.nC1_; ++l) {
p = Math.floor((g.nC1_ - l) / 2);
c[l] = d * m.polyval(p, C1f_coeff, o, eps2) / C1f_coeff[o + p + 1];
o += p + 2;
d *= eps;
}
};
C1pf_coeff = [+205, -432, 768, 1536, +4005, -4736, 3840, 12288, -225, 116, 384, -7173, 2695, 7680, +3467, 7680, +38081, 61440];
g.C1pf = function (eps, c) {
var eps2 = m.sq(eps),
d = eps,
o = 0,
l,
p;
for (l = 1; l <= g.nC1p_; ++l) {
p = Math.floor((g.nC1p_ - l) / 2);
c[l] = d * m.polyval(p, C1pf_coeff, o, eps2) / C1pf_coeff[o + p + 1];
o += p + 2;
d *= eps;
}
};
A2m1f_coeff = [-11, -28, -192, 0, 256];
g.A2m1f = function (eps) {
var p = Math.floor(nA2_ / 2),
t = m.polyval(p, A2m1f_coeff, 0, m.sq(eps)) / A2m1f_coeff[p + 1];
return (t - eps) / (1 + eps);
};
C2f_coeff = [+1, 2, 16, 32, +35, 64, 384, 2048, +15, 80, 768, +7, 35, 512, +63, 1280, +77, 2048];
g.C2f = function (eps, c) {
var eps2 = m.sq(eps),
d = eps,
o = 0,
l,
p;
for (l = 1; l <= g.nC2_; ++l) {
p = Math.floor((g.nC2_ - l) / 2);
c[l] = d * m.polyval(p, C2f_coeff, o, eps2) / C2f_coeff[o + p + 1];
o += p + 2;
d *= eps;
}
};
g.Geodesic = function (a, f) {
this.a = a;
this.f = f;
this._f1 = 1 - this.f;
this._e2 = this.f * (2 - this.f);
this._ep2 = this._e2 / m.sq(this._f1);
this._n = this.f / (2 - this.f);
this._b = this.a * this._f1;
this._c2 = (m.sq(this.a) + m.sq(this._b) * (this._e2 === 0 ? 1 : (this._e2 > 0 ? m.atanh(Math.sqrt(this._e2)) : Math.atan(Math.sqrt(-this._e2))) / Math.sqrt(Math.abs(this._e2)))) / 2;
this._etol2 = 0.1 * tol2_ / Math.sqrt(Math.max(0.001, Math.abs(this.f)) * Math.min(1, 1 - this.f / 2) / 2);
if (!(isFinite(this.a) && this.a > 0)) throw new Error("Equatorial radius is not positive");
if (!(isFinite(this._b) && this._b > 0)) throw new Error("Polar semi-axis is not positive");
this._A3x = new Array(nA3x_);
this._C3x = new Array(nC3x_);
this._C4x = new Array(nC4x_);
this.A3coeff();
this.C3coeff();
this.C4coeff();
};
A3_coeff = [-3, 128, -2, -3, 64, -1, -3, -1, 16, +3, -1, -2, 8, +1, -1, 2, +1, 1];
g.Geodesic.prototype.A3coeff = function () {
var o = 0,
k = 0,
j,
p;
for (j = nA3_ - 1; j >= 0; --j) {
p = Math.min(nA3_ - j - 1, j);
this._A3x[k++] = m.polyval(p, A3_coeff, o, this._n) / A3_coeff[o + p + 1];
o += p + 2;
}
};
C3_coeff = [+3, 128, +2, 5, 128, -1, 3, 3, 64, -1, 0, 1, 8, -1, 1, 4, +5, 256, +1, 3, 128, -3, -2, 3, 64, +1, -3, 2, 32, +7, 512, -10, 9, 384, +5, -9, 5, 192, +7, 512, -14, 7, 512, +21, 2560];
g.Geodesic.prototype.C3coeff = function () {
var o = 0,
k = 0,
l,
j,
p;
for (l = 1; l < g.nC3_; ++l) {
for (j = g.nC3_ - 1; j >= l; --j) {
p = Math.min(g.nC3_ - j - 1, j);
this._C3x[k++] = m.polyval(p, C3_coeff, o, this._n) / C3_coeff[o + p + 1];
o += p + 2;
}
}
};
C4_coeff = [+97, 15015, +1088, 156, 45045, -224, -4784, 1573, 45045, -10656, 14144, -4576, -858, 45045, +64, 624, -4576, 6864, -3003, 15015, +100, 208, 572, 3432, -12012, 30030, 45045, +1, 9009, -2944, 468, 135135, +5792, 1040, -1287, 135135, +5952, -11648, 9152, -2574, 135135, -64, -624, 4576, -6864, 3003, 135135, +8, 10725, +1856, -936, 225225, -8448, 4992, -1144, 225225, -1440, 4160, -4576, 1716, 225225, -136, 63063, +1024, -208, 105105, +3584, -3328, 1144, 315315, -128, 135135, -2560, 832, 405405, +128, 99099];
g.Geodesic.prototype.C4coeff = function () {
var o = 0,
k = 0,
l,
j,
p;
for (l = 0; l < g.nC4_; ++l) {
for (j = g.nC4_ - 1; j >= l; --j) {
p = g.nC4_ - j - 1;
this._C4x[k++] = m.polyval(p, C4_coeff, o, this._n) / C4_coeff[o + p + 1];
o += p + 2;
}
}
};
g.Geodesic.prototype.A3f = function (eps) {
return m.polyval(nA3x_ - 1, this._A3x, 0, eps);
};
g.Geodesic.prototype.C3f = function (eps, c) {
var mult = 1,
o = 0,
l,
p;
for (l = 1; l < g.nC3_; ++l) {
p = g.nC3_ - l - 1;
mult *= eps;
c[l] = mult * m.polyval(p, this._C3x, o, eps);
o += p + 1;
}
};
g.Geodesic.prototype.C4f = function (eps, c) {
var mult = 1,
o = 0,
l,
p;
for (l = 0; l < g.nC4_; ++l) {
p = g.nC4_ - l - 1;
c[l] = mult * m.polyval(p, this._C4x, o, eps);
o += p + 1;
mult *= eps;
}
};
g.Geodesic.prototype.Lengths = function (eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, outmask, C1a, C2a) {
outmask &= g.OUT_MASK;
var vals = {},
m0x = 0,
J12 = 0,
A1 = 0,
A2 = 0,
B1,
B2,
l,
csig12,
t;
if (outmask & (g.DISTANCE | g.REDUCEDLENGTH | g.GEODESICSCALE)) {
A1 = g.A1m1f(eps);
g.C1f(eps, C1a);
if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
A2 = g.A2m1f(eps);
g.C2f(eps, C2a);
m0x = A1 - A2;
A2 = 1 + A2;
}
A1 = 1 + A1;
}
if (outmask & g.DISTANCE) {
B1 = g.SinCosSeries(true, ssig2, csig2, C1a) - g.SinCosSeries(true, ssig1, csig1, C1a);
vals.s12b = A1 * (sig12 + B1);
if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
B2 = g.SinCosSeries(true, ssig2, csig2, C2a) - g.SinCosSeries(true, ssig1, csig1, C2a);
J12 = m0x * sig12 + (A1 * B1 - A2 * B2);
}
} else if (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE)) {
for (l = 1; l <= g.nC2_; ++l) C2a[l] = A1 * C1a[l] - A2 * C2a[l];
J12 = m0x * sig12 + (g.SinCosSeries(true, ssig2, csig2, C2a) - g.SinCosSeries(true, ssig1, csig1, C2a));
}
if (outmask & g.REDUCEDLENGTH) {
vals.m0 = m0x;
vals.m12b = dn2 * (csig1 * ssig2) - dn1 * (ssig1 * csig2) - csig1 * csig2 * J12;
} else vals.m12b = NaN;
if (outmask & g.GEODESICSCALE) {
csig12 = csig1 * csig2 + ssig1 * ssig2;
t = this._ep2 * (cbet1 - cbet2) * (cbet1 + cbet2) / (dn1 + dn2);
vals.M12 = csig12 + (t * ssig2 - csig2 * J12) * ssig1 / dn1;
vals.M21 = csig12 - (t * ssig1 - csig1 * J12) * ssig2 / dn2;
}
return vals;
};
g.Geodesic.prototype.InverseStart = function (sbet1, cbet1, dn1, sbet2, cbet2, dn2, lam12, slam12, clam12, C1a, C2a) {
var vals = {},
sbet12 = sbet2 * cbet1 - cbet2 * sbet1,
cbet12 = cbet2 * cbet1 + sbet2 * sbet1,
sbet12a,
shortline,
omg12,
sbetm2,
somg12,
comg12,
t,
ssig12,
csig12,
x,
y,
lamscale,
betscale,
k2,
eps,
cbet12a,
bet12a,
m12b,
m0,
nvals,
k,
omg12a,
lam12x;
vals.sig12 = -1;
sbet12a = sbet2 * cbet1;
sbet12a += cbet2 * sbet1;
shortline = cbet12 >= 0 && sbet12 < 0.5 && cbet2 * lam12 < 0.5;
if (shortline) {
sbetm2 = m.sq(sbet1 + sbet2);
sbetm2 /= sbetm2 + m.sq(cbet1 + cbet2);
vals.dnm = Math.sqrt(1 + this._ep2 * sbetm2);
omg12 = lam12 / (this._f1 * vals.dnm);
somg12 = Math.sin(omg12);
comg12 = Math.cos(omg12);
} else {
somg12 = slam12;
comg12 = clam12;
}
vals.salp1 = cbet2 * somg12;
vals.calp1 = comg12 >= 0 ? sbet12 + cbet2 * sbet1 * m.sq(somg12) / (1 + comg12) : sbet12a - cbet2 * sbet1 * m.sq(somg12) / (1 - comg12);
ssig12 = m.hypot(vals.salp1, vals.calp1);
csig12 = sbet1 * sbet2 + cbet1 * cbet2 * comg12;
if (shortline && ssig12 < this._etol2) {
vals.salp2 = cbet1 * somg12;
vals.calp2 = sbet12 - cbet1 * sbet2 * (comg12 >= 0 ? m.sq(somg12) / (1 + comg12) : 1 - comg12);
t = m.hypot(vals.salp2, vals.calp2);
vals.salp2 /= t;
vals.calp2 /= t;
vals.sig12 = Math.atan2(ssig12, csig12);
} else if (Math.abs(this._n) > 0.1 || csig12 >= 0 || ssig12 >= 6 * Math.abs(this._n) * Math.PI * m.sq(cbet1)) {} else {
lam12x = Math.atan2(-slam12, -clam12);
if (this.f >= 0) {
k2 = m.sq(sbet1) * this._ep2;
eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
lamscale = this.f * cbet1 * this.A3f(eps) * Math.PI;
betscale = lamscale * cbet1;
x = lam12x / lamscale;
y = sbet12a / betscale;
} else {
cbet12a = cbet2 * cbet1 - sbet2 * sbet1;
bet12a = Math.atan2(sbet12a, cbet12a);
nvals = this.Lengths(this._n, Math.PI + bet12a, sbet1, -cbet1, dn1, sbet2, cbet2, dn2, cbet1, cbet2, g.REDUCEDLENGTH, C1a, C2a);
m12b = nvals.m12b;
m0 = nvals.m0;
x = -1 + m12b / (cbet1 * cbet2 * m0 * Math.PI);
betscale = x < -0.01 ? sbet12a / x : -this.f * m.sq(cbet1) * Math.PI;
lamscale = betscale / cbet1;
y = lam12 / lamscale;
}
if (y > -tol1_ && x > -1 - xthresh_) {
if (this.f >= 0) {
vals.salp1 = Math.min(1, -x);
vals.calp1 = -Math.sqrt(1 - m.sq(vals.salp1));
} else {
vals.calp1 = Math.max(x > -tol1_ ? 0 : -1, x);
vals.salp1 = Math.sqrt(1 - m.sq(vals.calp1));
}
} else {
k = astroid(x, y);
omg12a = lamscale * (this.f >= 0 ? -x * k / (1 + k) : -y * (1 + k) / k);
somg12 = Math.sin(omg12a);
comg12 = -Math.cos(omg12a);
vals.salp1 = cbet2 * somg12;
vals.calp1 = sbet12a - cbet2 * sbet1 * m.sq(somg12) / (1 - comg12);
}
}
if (!(vals.salp1 <= 0)) {
t = m.hypot(vals.salp1, vals.calp1);
vals.salp1 /= t;
vals.calp1 /= t;
} else {
vals.salp1 = 1;
vals.calp1 = 0;
}
return vals;
};
g.Geodesic.prototype.Lambda12 = function (sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1, slam120, clam120, diffp, C1a, C2a, C3a) {
var vals = {},
t,
salp0,
calp0,
somg1,
comg1,
somg2,
comg2,
somg12,
comg12,
B312,
eta,
k2,
nvals;
if (sbet1 === 0 && calp1 === 0) calp1 = -g.tiny_;
salp0 = salp1 * cbet1;
calp0 = m.hypot(calp1, salp1 * sbet1);
vals.ssig1 = sbet1;
somg1 = salp0 * sbet1;
vals.csig1 = comg1 = calp1 * cbet1;
t = m.hypot(vals.ssig1, vals.csig1);
vals.ssig1 /= t;
vals.csig1 /= t;
vals.salp2 = cbet2 !== cbet1 ? salp0 / cbet2 : salp1;
vals.calp2 = cbet2 !== cbet1 || Math.abs(sbet2) !== -sbet1 ? Math.sqrt(m.sq(calp1 * cbet1) + (cbet1 < -sbet1 ? (cbet2 - cbet1) * (cbet1 + cbet2) : (sbet1 - sbet2) * (sbet1 + sbet2))) / cbet2 : Math.abs(calp1);
vals.ssig2 = sbet2;
somg2 = salp0 * sbet2;
vals.csig2 = comg2 = vals.calp2 * cbet2;
t = m.hypot(vals.ssig2, vals.csig2);
vals.ssig2 /= t;
vals.csig2 /= t;
vals.sig12 = Math.atan2(Math.max(0, vals.csig1 * vals.ssig2 - vals.ssig1 * vals.csig2), vals.csig1 * vals.csig2 + vals.ssig1 * vals.ssig2);
somg12 = Math.max(0, comg1 * somg2 - somg1 * comg2);
comg12 = comg1 * comg2 + somg1 * somg2;
eta = Math.atan2(somg12 * clam120 - comg12 * slam120, comg12 * clam120 + somg12 * slam120);
k2 = m.sq(calp0) * this._ep2;
vals.eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
this.C3f(vals.eps, C3a);
B312 = g.SinCosSeries(true, vals.ssig2, vals.csig2, C3a) - g.SinCosSeries(true, vals.ssig1, vals.csig1, C3a);
vals.domg12 = -this.f * this.A3f(vals.eps) * salp0 * (vals.sig12 + B312);
vals.lam12 = eta + vals.domg12;
if (diffp) {
if (vals.calp2 === 0) vals.dlam12 = -2 * this._f1 * dn1 / sbet1;else {
nvals = this.Lengths(vals.eps, vals.sig12, vals.ssig1, vals.csig1, dn1, vals.ssig2, vals.csig2, dn2, cbet1, cbet2, g.REDUCEDLENGTH, C1a, C2a);
vals.dlam12 = nvals.m12b;
vals.dlam12 *= this._f1 / (vals.calp2 * cbet2);
}
}
return vals;
};
g.Geodesic.prototype.Inverse = function (lat1, lon1, lat2, lon2, outmask) {
var r, vals;
if (!outmask) outmask = g.STANDARD;
if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
outmask &= g.OUT_MASK;
r = this.InverseInt(lat1, lon1, lat2, lon2, outmask);
vals = r.vals;
if (outmask & g.AZIMUTH) {
vals.azi1 = m.atan2d(r.salp1, r.calp1);
vals.azi2 = m.atan2d(r.salp2, r.calp2);
}
return vals;
};
g.Geodesic.prototype.InverseInt = function (lat1, lon1, lat2, lon2, outmask) {
var vals = {},
lon12,
lon12s,
lonsign,
t,
swapp,
latsign,
sbet1,
cbet1,
sbet2,
cbet2,
s12x,
m12x,
dn1,
dn2,
lam12,
slam12,
clam12,
sig12,
calp1,
salp1,
calp2,
salp2,
C1a,
C2a,
C3a,
meridian,
nvals,
ssig1,
csig1,
ssig2,
csig2,
eps,
omg12,
dnm,
numit,
salp1a,
calp1a,
salp1b,
calp1b,
tripn,
tripb,
v,
dv,
dalp1,
sdalp1,
cdalp1,
nsalp1,
lengthmask,
salp0,
calp0,
alp12,
k2,
A4,
C4a,
B41,
B42,
somg12,
comg12,
domg12,
dbet1,
dbet2,
salp12,
calp12,
sdomg12,
cdomg12;
vals.lat1 = lat1 = m.LatFix(lat1);
vals.lat2 = lat2 = m.LatFix(lat2);
lat1 = m.AngRound(lat1);
lat2 = m.AngRound(lat2);
lon12 = m.AngDiff(lon1, lon2);
lon12s = lon12.e;
lon12 = lon12.d;
if (outmask & g.LONG_UNROLL) {
vals.lon1 = lon1;
vals.lon2 = lon1 + lon12 + lon12s;
} else {
vals.lon1 = m.AngNormalize(lon1);
vals.lon2 = m.AngNormalize(lon2);
}
lonsign = m.copysign(1, lon12);
lon12 *= lonsign;
lon12s *= lonsign;
lam12 = lon12 * m.degree;
t = m.sincosde(lon12, lon12s);
slam12 = t.s;
clam12 = t.c;
lon12s = 180 - lon12 - lon12s;
swapp = Math.abs(lat1) < Math.abs(lat2) || isNaN(lat2) ? -1 : 1;
if (swapp < 0) {
lonsign *= -1;
var _ref2 = [lat1, lat2];
lat2 = _ref2[0];
lat1 = _ref2[1];
}
latsign = m.copysign(1, -lat1);
lat1 *= latsign;
lat2 *= latsign;
t = m.sincosd(lat1);
sbet1 = this._f1 * t.s;
cbet1 = t.c;
t = m.hypot(sbet1, cbet1);
sbet1 /= t;
cbet1 /= t;
cbet1 = Math.max(g.tiny_, cbet1);
t = m.sincosd(lat2);
sbet2 = this._f1 * t.s;
cbet2 = t.c;
t = m.hypot(sbet2, cbet2);
sbet2 /= t;
cbet2 /= t;
cbet2 = Math.max(g.tiny_, cbet2);
if (cbet1 < -sbet1) {
if (cbet2 === cbet1) sbet2 = m.copysign(sbet1, sbet2);
} else {
if (Math.abs(sbet2) === -sbet1) cbet2 = cbet1;
}
dn1 = Math.sqrt(1 + this._ep2 * m.sq(sbet1));
dn2 = Math.sqrt(1 + this._ep2 * m.sq(sbet2));
C1a = new Array(g.nC1_ + 1);
C2a = new Array(g.nC2_ + 1);
C3a = new Array(g.nC3_);
meridian = lat1 === -90 || slam12 === 0;
if (meridian) {
calp1 = clam12;
salp1 = slam12;
calp2 = 1;
salp2 = 0;
ssig1 = sbet1;
csig1 = calp1 * cbet1;
ssig2 = sbet2;
csig2 = calp2 * cbet2;
sig12 = Math.atan2(Math.max(0, csig1 * ssig2 - ssig1 * csig2), csig1 * csig2 + ssig1 * ssig2);
nvals = this.Lengths(this._n, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, outmask | g.DISTANCE | g.REDUCEDLENGTH, C1a, C2a);
s12x = nvals.s12b;
m12x = nvals.m12b;
if (outmask & g.GEODESICSCALE) {
vals.M12 = nvals.M12;
vals.M21 = nvals.M21;
}
if (sig12 < tol2_ || m12x >= 0) {
if (sig12 < 3 * g.tiny_ || sig12 < tol0_ && (s12x < 0 || m12x < 0)) sig12 = m12x = s12x = 0;
m12x *= this._b;
s12x *= this._b;
vals.a12 = sig12 / m.degree;
} else meridian = false;
}
somg12 = 2;
if (!meridian && sbet1 === 0 && (this.f <= 0 || lon12s >= this.f * 180)) {
calp1 = calp2 = 0;
salp1 = salp2 = 1;
s12x = this.a * lam12;
sig12 = omg12 = lam12 / this._f1;
m12x = this._b * Math.sin(sig12);
if (outmask & g.GEODESICSCALE) vals.M12 = vals.M21 = Math.cos(sig12);
vals.a12 = lon12 / this._f1;
} else if (!meridian) {
nvals = this.InverseStart(sbet1, cbet1, dn1, sbet2, cbet2, dn2, lam12, slam12, clam12, C1a, C2a);
sig12 = nvals.sig12;
salp1 = nvals.salp1;
calp1 = nvals.calp1;
if (sig12 >= 0) {
salp2 = nvals.salp2;
calp2 = nvals.calp2;
dnm = nvals.dnm;
s12x = sig12 * this._b * dnm;
m12x = m.sq(dnm) * this._b * Math.sin(sig12 / dnm);
if (outmask & g.GEODESICSCALE) vals.M12 = vals.M21 = Math.cos(sig12 / dnm);
vals.a12 = sig12 / m.degree;
omg12 = lam12 / (this._f1 * dnm);
} else {
numit = 0;
salp1a = g.tiny_;
calp1a = 1;
salp1b = g.tiny_;
calp1b = -1;
for (tripn = false, tripb = false;; ++numit) {
nvals = this.Lambda12(sbet1, cbet1, dn1, sbet2, cbet2, dn2, salp1, calp1, slam12, clam12, numit < maxit1_, C1a, C2a, C3a);
v = nvals.lam12;
salp2 = nvals.salp2;
calp2 = nvals.calp2;
sig12 = nvals.sig12;
ssig1 = nvals.ssig1;
csig1 = nvals.csig1;
ssig2 = nvals.ssig2;
csig2 = nvals.csig2;
eps = nvals.eps;
domg12 = nvals.domg12;
dv = nvals.dlam12;
if (tripb || !(Math.abs(v) >= (tripn ? 8 : 1) * tol0_) || numit == maxit2_) break;
if (v > 0 && (numit < maxit1_ || calp1 / salp1 > calp1b / salp1b)) {
salp1b = salp1;
calp1b = calp1;
} else if (v < 0 && (numit < maxit1_ || calp1 / salp1 < calp1a / salp1a)) {
salp1a = salp1;
calp1a = calp1;
}
if (numit < maxit1_ && dv > 0) {
dalp1 = -v / dv;
if (Math.abs(dalp1) < Math.PI) {
sdalp1 = Math.sin(dalp1);
cdalp1 = Math.cos(dalp1);
nsalp1 = salp1 * cdalp1 + calp1 * sdalp1;
if (nsalp1 > 0) {
calp1 = calp1 * cdalp1 - salp1 * sdalp1;
salp1 = nsalp1;
t = m.hypot(salp1, calp1);
salp1 /= t;
calp1 /= t;
tripn = Math.abs(v) <= 16 * tol0_;
continue;
}
}
}
salp1 = (salp1a + salp1b) / 2;
calp1 = (calp1a + calp1b) / 2;
t = m.hypot(salp1, calp1);
salp1 /= t;
calp1 /= t;
tripn = false;
tripb = Math.abs(salp1a - salp1) + (calp1a - calp1) < tolb_ || Math.abs(salp1 - salp1b) + (calp1 - calp1b) < tolb_;
}
lengthmask = outmask | (outmask & (g.REDUCEDLENGTH | g.GEODESICSCALE) ? g.DISTANCE : g.NONE);
nvals = this.Lengths(eps, sig12, ssig1, csig1, dn1, ssig2, csig2, dn2, cbet1, cbet2, lengthmask, C1a, C2a);
s12x = nvals.s12b;
m12x = nvals.m12b;
if (outmask & g.GEODESICSCALE) {
vals.M12 = nvals.M12;
vals.M21 = nvals.M21;
}
m12x *= this._b;
s12x *= this._b;
vals.a12 = sig12 / m.degree;
if (outmask & g.AREA) {
sdomg12 = Math.sin(domg12);
cdomg12 = Math.cos(domg12);
somg12 = slam12 * cdomg12 - clam12 * sdomg12;
comg12 = clam12 * cdomg12 + slam12 * sdomg12;
}
}
}
if (outmask & g.DISTANCE) vals.s12 = 0 + s12x;
if (outmask & g.REDUCEDLENGTH) vals.m12 = 0 + m12x;
if (outmask & g.AREA) {
salp0 = salp1 * cbet1;
calp0 = m.hypot(calp1, salp1 * sbet1);
if (calp0 !== 0 && salp0 !== 0) {
ssig1 = sbet1;
csig1 = calp1 * cbet1;
ssig2 = sbet2;
csig2 = calp2 * cbet2;
k2 = m.sq(calp0) * this._ep2;
eps = k2 / (2 * (1 + Math.sqrt(1 + k2)) + k2);
A4 = m.sq(this.a) * calp0 * salp0 * this._e2;
t = m.hypot(ssig1, csig1);
ssig1 /= t;
csig1 /= t;
t = m.hypot(ssig2, csig2);
ssig2 /= t;
csig2 /= t;
C4a = new Array(g.nC4_);
this.C4f(eps, C4a);
B41 = g.SinCosSeries(false, ssig1, csig1, C4a);
B42 = g.SinCosSeries(false, ssig2, csig2, C4a);
vals.S12 = A4 * (B42 - B41);
} else vals.S12 = 0;
if (!meridian && somg12 == 2) {
somg12 = Math.sin(omg12);
comg12 = Math.cos(omg12);
}
if (!meridian && comg12 > -0.7071 && sbet2 - sbet1 < 1.75) {
domg12 = 1 + comg12;
dbet1 = 1 + cbet1;
dbet2 = 1 + cbet2;
alp12 = 2 * Math.atan2(somg12 * (sbet1 * dbet2 + sbet2 * dbet1), domg12 * (sbet1 * sbet2 + dbet1 * dbet2));
} else {
salp12 = salp2 * calp1 - calp2 * salp1;
calp12 = calp2 * calp1 + salp2 * salp1;
if (salp12 === 0 && calp12 < 0) {
salp12 = g.tiny_ * calp1;
calp12 = -1;
}
alp12 = Math.atan2(salp12, calp12);
}
vals.S12 += this._c2 * alp12;
vals.S12 *= swapp * lonsign * latsign;
vals.S12 += 0;
}
if (swapp < 0) {
var _ref3 = [salp1, salp2];
salp2 = _ref3[0];
salp1 = _ref3[1];
var _ref4 = [calp1, calp2];
calp2 = _ref4[0];
calp1 = _ref4[1];
if (outmask & g.GEODESICSCALE) {
var _ref5 = [vals.M12, vals.M21];
vals.M21 = _ref5[0];
vals.M12 = _ref5[1];
}
}
salp1 *= swapp * lonsign;
calp1 *= swapp * latsign;
salp2 *= swapp * lonsign;
calp2 *= swapp * latsign;
return {
vals: vals,
salp1: salp1,
calp1: calp1,
salp2: salp2,
calp2: calp2
};
};
g.Geodesic.prototype.GenDirect = function (lat1, lon1, azi1, arcmode, s12_a12, outmask) {
var line;
if (!outmask) outmask = g.STANDARD;else if (outmask === g.LONG_UNROLL) outmask |= g.STANDARD;
if (!arcmode) outmask |= g.DISTANCE_IN;
line = new l.GeodesicLine(this, lat1, lon1, azi1, outmask);
return line.GenPosition(arcmode, s12_a12, outmask);
};
g.Geodesic.prototype.Direct = function (lat1, lon1, azi1, s12, outmask) {
return this.GenDirect(lat1, lon1, azi1, false, s12, outmask);
};
g.Geodesic.prototype.ArcDirect = function (lat1, lon1, azi1, a12, outmask) {
return this.GenDirect(lat1, lon1, azi1, true, a12, outmask);
};
g.Geodesic.prototype.Line = function (lat1, lon1, azi1, caps) {
return new l.GeodesicLine(this, lat1, lon1, azi1, caps);
};
g.Geodesic.prototype.DirectLine = function (lat1, lon1, azi1, s12, caps) {
return this.GenDirectLine(lat1, lon1, azi1, false, s12, caps);
};
g.Geodesic.prototype.ArcDirectLine = function (lat1, lon1, azi1, a12, caps) {
return this.GenDirectLine(lat1, lon1, azi1, true, a12, caps);
};
g.Geodesic.prototype.GenDirectLine = function (lat1, lon1, azi1, arcmode, s12_a12, caps) {
var t;
if (!caps) caps = g.STANDARD | g.DISTANCE_IN;
if (!arcmode) caps |= g.DISTANCE_IN;
t = new l.GeodesicLine(this, lat1, lon1, azi1, caps);
t.GenSetDistance(arcmode, s12_a12);
return t;
};
g.Geodesic.prototype.I