1 line
26 KiB
JavaScript
1 line
26 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ticketDistanceService=e():(t.ntt=t.ntt||{},t.ntt.smartit=t.ntt.smartit||{},t.ntt.smartit.ticketDistanceService=e())}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){t.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var a=e[r]={i:r,l:!1,exports:{}};return t[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(r,a,function(e){return t[e]}.bind(null,a));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.r(e);const a=Symbol.for("SchemaOptions");function o(t){return l(t)&&t.hasOwnProperty("fn")&&t.hasOwnProperty("path")}function i(t){return h(t)}function s(t){return Array.isArray(t)&&t.every(i)}const c=(t,e)=>t.reduce((t,n)=>(M(t,n,f(e,n)),t),{});function u(t){return void 0===t}function l(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}function h(t){return"string"==typeof t||t instanceof String}function p(t){return"function"==typeof t}function f(t,e){const n=(e=(e=e.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"")).split(".");for(let e=0,r=n.length;e<r;++e){const r=n[e];if(!(l(t)&&r in t))return;t=t[r]}return t}function d(t,e){return t.reduce((t,n,a)=>(function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),a.forEach(function(e){r(t,e,n[e])})}return t})({},t,{[n]:e[a]}),{})}function M(t,e,n,r){if("number"==typeof e&&(e=[e]),!e||0===e.length)return t;if("string"==typeof e)return M(t,e.split(".").map(g),n,r);const a=e[0],o=function(t,e){if(function(t,e){return"number"==typeof e&&Array.isArray(t)||function(t,e){return null!=t&&Object.prototype.hasOwnProperty.call(t,e)}(t,e)}(t,e))return t[e]}(t,a);return 1===e.length?(void 0!==o&&r||(t[a]=n),o):(void 0===o&&("number"==typeof e[1]?t[a]=[]:t[a]={}),M(t[a],e.slice(1),n,r))}function g(t){const e=parseInt(t);return e.toString()===t?e:t}function m(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),r.forEach(function(e){y(t,e,n[e])})}return t}function y(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}let b;function w(t,e){return e&&!function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}(e)&&(t[a]=e),t}!function(t){t.Root="Root",t.Property="Property",t.ActionFunction="ActionFunction",t.ActionAggregator="ActionAggregator",t.ActionString="ActionString",t.ActionSelector="ActionSelector"}(b||(b={}));class v{constructor(t){this.schemaOptions=void 0,this.root=void 0,this.schema=void 0,this.schema=t,this.schemaOptions=v.getSchemaOptions(this.schema),this.root={data:{targetPropertyPath:"",propertyName:"MorphismTreeRoot",action:null,kind:b.Root},parent:null,children:[]},t&&this.parseSchema(t)}static getSchemaOptions(t){return m({},{class:{automapping:!0},undefinedValues:{strip:!1}},t?t[a]:void 0)}parseSchema(t,e,n){var r;(h(r=t)||p(r)||o(r)||s(r))&&e?(this.add({propertyName:e,action:t},n),n=n?"".concat(n,".").concat(e):e):(e&&(this.add({propertyName:e,action:null},n),n=n?"".concat(n,".").concat(e):e),Array.isArray(t)?t.forEach((t,e)=>{this.parseSchema(t,e.toString(),n)}):l(t)&&Object.keys(t).forEach(e=>{this.parseSchema(t[e],e,n)}))}*traverseBFS(){const t=[];for(t.push(this.root);t.length>0;){let e=t.shift();if(!e)return;for(let n=0,r=e.children.length;n<r;n++)t.push(e.children[n]);e.data.kind!==b.Root&&(yield e)}}add(t,e){const n=this.getActionKind(t.action);if(!n)throw new Error("The action specified for ".concat(t.propertyName," is not supported."));const r={data:m({},t,{kind:n,targetPropertyPath:""}),parent:null,children:[]};if(r.data.preparedAction=this.getPreparedAction(r.data),e)for(const t of this.traverseBFS())t.data.targetPropertyPath===e&&(r.parent=t,r.data.targetPropertyPath="".concat(t.data.targetPropertyPath,".").concat(r.data.propertyName),t.children.push(r));else r.parent=this.root,r.data.targetPropertyPath=r.data.propertyName,this.root.children.push(r)}getActionKind(t){return i(t)?b.ActionString:p(t)?b.ActionFunction:o(t)?b.ActionSelector:s(t)?b.ActionAggregator:null===t?b.Property:void 0}getPreparedAction(t){const{propertyName:e,action:n,kind:r}=t;if(i(n))return t=>{let{object:e}=t;return f(e,n)};if(p(n))return t=>{let{object:e,items:r,objectToCompute:a}=t;return n.call(void 0,e,r,a)};if(s(n))return t=>{let{object:e}=t;return c(n,e)};if(o(n))return t=>{let r,{object:a,items:o,objectToCompute:i}=t;try{let s;Array.isArray(n.path)?s=c(n.path,a):h(n.path)&&(s=f(a,n.path)),r=n.fn.call(void 0,s,a,o,i)}catch(t){throw t.message="Unable to set target property [".concat(e,"].\n \n An error occured when applying [").concat(n.fn.name,"] on property [").concat(n.path,"]\n \n Internal error: ").concat(t.message),t}return r};if(r===b.Property)return null;throw new Error("The action specified for ".concat(e," is not supported."))}}function N(t){return(e,n,r)=>{const a=r.value;return"function"==typeof a&&(r.value=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const o=a.apply(this,n);return function(t){if(Promise&&Promise.resolve)return Promise.resolve(t)==t;throw"Promise not supported in your environment"}(o)?Promise.resolve(o).then(e=>t(e)):t(o)}),r}}function P(t,e,n,r){const a=e.schemaOptions,o=[];for(const a of e.traverseBFS()){const{preparedAction:e,targetPropertyPath:i}=a.data;e&&o.push({targetPropertyPath:i,preparedAction:e({object:t,objectToCompute:r,items:n})})}return o.reduce((t,e)=>{const n=((t,e)=>u(e)?u(t)?void 0:t:e)(f(t,e.targetPropertyPath),e.preparedAction);return void 0===n?(a&&a.undefinedValues&&a.undefinedValues.strip?a.undefinedValues.default&&M(t,e.targetPropertyPath,a.undefinedValues.default(t,e.targetPropertyPath)):M(t,e.targetPropertyPath,n),t):(M(t,e.targetPropertyPath,n),t)},r)}function S(t,e){const n=v.getSchemaOptions(t);let r;if(e&&n.class&&n.class.automapping){const n=function(t,e){let n=Object.keys(new t),r=d(n,n);return Object.assign(r,e)}(e,t);r=new v(n)}else r=new v(t);return function(t){if(!t)return t;if(Array.isArray(t))return t.map(n=>{if(e){const a=new e;return P(n,r,t,a)}return P(n,r,t,{})});{const n=t;if(e){const t=new e;return P(n,r,[n],t)}return P(n,r,[n],{})}}}function O(t,e,n){switch(arguments.length){case 1:return S(t);case 2:return S(t)(e);case 3:if(n)return null!==e?S(t,n)(e):S(t,n);throw new Error("When using morphism(schema, items, type), type should be defined but value received is ".concat(n))}}function R(t,e){return N(S(t,e))}function T(t){return N(S(t))}function j(t,e){return N(S(t,e))}n.d(e,"morph",function(){return R}),n.d(e,"toJSObject",function(){return T}),n.d(e,"toClassObject",function(){return j}),n.d(e,"morphism",function(){return O}),n.d(e,"createSchema",function(){return w}),n.d(e,"Schema",function(){}),n.d(e,"StrictSchema",function(){}),n.d(e,"SchemaOptions",function(){}),n.d(e,"Mapper",function(){}),n.d(e,"SCHEMA_OPTIONS_SYMBOL",function(){return a});const _=new class{constructor(t){this._registry=null,this._registry=t||{cache:new Map}}register(t,e){if(!t&&!e)throw new Error("type paramater is required when you register a mapping");if(this.exists(t))throw new Error("A mapper for ".concat(t.name," has already been registered"));let n;return n=O(e||{},null,t),this._registry.cache.set(t,n),n}map(t,e){if(!this.exists(t)){const n=this.register(t);if(void 0===e)return n}return this.getMapper(t)(e)}getMapper(t){return this._registry.cache.get(t)}setMapper(t,e){if(e){if(this.exists(t)){let n=O(e,null,t);return this._registry.cache.set(t,n),n}throw new Error("The type ".concat(t.name," is not registered. Register it using `Mophism.register(").concat(t.name,", schema)`"))}throw new Error("The schema must be an Object. Found ".concat(e))}deleteMapper(t){return this._registry.cache.delete(t)}exists(t){return this._registry.cache.has(t)}get mappers(){return this._registry.cache}},E=O;E.register=(t,e)=>_.register(t,e),E.map=(t,e)=>_.map(t,e),E.getMapper=t=>_.getMapper(t),E.setMapper=(t,e)=>_.setMapper(t,e),E.deleteMapper=t=>_.deleteMapper(t),E.mappers=_.mappers;const A=E;e.default=A}])},function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function o(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}n.r(e),n.d(e,"ticketDistanceService",function(){return c}),n(2);var c=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,i(e).apply(this,arguments))}var n,r,c;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(e,ntt.smartit.api.ICustomModule),n=e,(r=[{key:"name",value:function(){return"ticketDistanceService"}},{key:"injectTemplates",value:function(){return{}}},{key:"injectDynTemplates",value:function(){return{}}},{key:"templates",value:function(){return[{},{},{},{},{},{},{}]}},{key:"i18nLocales",value:function(){return{}}}])&&a(n.prototype,r),c&&a(n,c),e}();ntt.smartit.api.nttSmartitModules.push(new c)},function(t,e,n){"use strict";n.r(e);let r=" ";class a{static get separator(){return r}static set separator(t){r=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let n=null;switch(e.length){case 3:n=e[0]/1+e[1]/60+e[2]/3600;break;case 2:n=e[0]/1+e[1]/60;break;case 1:n=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(n=-n),Number(n)}static toDms(t,e="d",n){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===n)switch(e){case"d":case"deg":n=4;break;case"dm":case"deg+min":n=2;break;case"dms":case"deg+min+sec":n=0;break;default:e="d",n=4}t=Math.abs(t);let r=null,o=null,i=null,s=null;switch(e){default:case"d":case"deg":(o=t.toFixed(n))<100&&(o="0"+o),o<10&&(o="0"+o),r=o+"°";break;case"dm":case"deg+min":o=Math.floor(t),60==(i=(60*t%60).toFixed(n))&&(i=(0).toFixed(n),o++),i<10&&(i="0"+i),r=(o=("000"+o).slice(-3))+"°"+a.separator+i+"′";break;case"dms":case"deg+min+sec":o=Math.floor(t),i=Math.floor(3600*t/60)%60,60==(s=(3600*t%60).toFixed(n))&&(s=(0).toFixed(n),i++),60==i&&(i=0,o++),o=("000"+o).slice(-3),i=("00"+i).slice(-2),s<10&&(s="0"+s),r=o+"°"+a.separator+i+"′"+a.separator+s+"″"}return r}static toLat(t,e,n){const r=a.toDms(a.wrap90(t),e,n);return null===r?"–":r.slice(1)+a.separator+(t<0?"S":"N")}static toLon(t,e,n){const r=a.toDms(a.wrap180(t),e,n);return null===r?"–":r+a.separator+(t<0?"W":"E")}static toBrng(t,e,n){const r=a.toDms(a.wrap360(t),e,n);return null===r?"–":r.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),n={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(n.thousands,"⁜").replace(n.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),n={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",n.decimal).replace("⁜",n.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=a.wrap360(t);const n=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*n/360)%n*16/n]}static wrap360(t){return 0<=t&&t<360?t:(t%360+360)%360}static wrap180(t){return-180<t&&t<=180?t:(t+540)%360-180}static wrap90(t){return-90<=t&&t<=90?t:Math.abs((t%360+270)%360-180)-90}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};var o=a;const i=Math.PI;class s{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=o.wrap90(Number(t)),this._lon=o.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?o.wrap90(o.parse(t)):o.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?o.wrap90(o.parse(t)):o.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?o.wrap180(o.parse(t)):o.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?o.wrap180(o.parse(t)):o.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?o.wrap180(o.parse(t)):o.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e=void 0,n=void 0;if(2==t.length&&([e,n]=t,e=o.wrap90(o.parse(e)),n=o.wrap180(o.parse(n)),isNaN(e)||isNaN(n)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,n]=t[0].split(","),e=o.wrap90(o.parse(e)),n=o.wrap180(o.parse(n)),isNaN(e)||isNaN(n)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const r=t[0];if("Point"==r.type&&Array.isArray(r.coordinates)?[n,e]=r.coordinates:(null!=r.latitude&&(e=r.latitude),null!=r.lat&&(e=r.lat),null!=r.longitude&&(n=r.longitude),null!=r.lng&&(n=r.lng),null!=r.lon&&(n=r.lon),e=o.wrap90(o.parse(e)),n=o.wrap180(o.parse(n))),isNaN(e)||isNaN(n))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(n))throw new TypeError(`invalid point ‘${t.toString()}’`);return new s(e,n)}distanceTo(t,e=6371e3){if(t instanceof s||(t=s.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const n=e,r=this.lat.toRadians(),a=this.lon.toRadians(),o=t.lat.toRadians(),i=o-r,c=t.lon.toRadians()-a,u=Math.sin(i/2)*Math.sin(i/2)+Math.cos(r)*Math.cos(o)*Math.sin(c/2)*Math.sin(c/2);return n*(2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)))}initialBearingTo(t){if(t instanceof s||(t=s.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),n=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),a=Math.cos(e)*Math.sin(n)-Math.sin(e)*Math.cos(n)*Math.cos(r),i=Math.sin(r)*Math.cos(n),c=Math.atan2(i,a).toDegrees();return o.wrap360(c)}finalBearingTo(t){t instanceof s||(t=s.parse(t));const e=t.initialBearingTo(this)+180;return o.wrap360(e)}midpointTo(t){t instanceof s||(t=s.parse(t));const e=this.lat.toRadians(),n=this.lon.toRadians(),r=t.lat.toRadians(),a=(t.lon-this.lon).toRadians(),o=Math.cos(e),i=0,c=Math.sin(e),u={x:o+Math.cos(r)*Math.cos(a),y:i+Math.cos(r)*Math.sin(a),z:c+Math.sin(r)},l=Math.atan2(u.z,Math.sqrt(u.x*u.x+u.y*u.y)),h=n+Math.atan2(u.y,u.x),p=l.toDegrees(),f=h.toDegrees();return new s(p,f)}intermediatePointTo(t,e){if(t instanceof s||(t=s.parse(t)),this.equals(t))return new s(this.lat,this.lon);const n=this.lat.toRadians(),r=this.lon.toRadians(),a=t.lat.toRadians(),o=t.lon.toRadians(),i=a-n,c=o-r,u=Math.sin(i/2)*Math.sin(i/2)+Math.cos(n)*Math.cos(a)*Math.sin(c/2)*Math.sin(c/2),l=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u)),h=Math.sin((1-e)*l)/Math.sin(l),p=Math.sin(e*l)/Math.sin(l),f=h*Math.cos(n)*Math.cos(r)+p*Math.cos(a)*Math.cos(o),d=h*Math.cos(n)*Math.sin(r)+p*Math.cos(a)*Math.sin(o),M=h*Math.sin(n)+p*Math.sin(a),g=Math.atan2(M,Math.sqrt(f*f+d*d)),m=Math.atan2(d,f),y=g.toDegrees(),b=m.toDegrees();return new s(y,b)}destinationPoint(t,e,n=6371e3){const r=t/n,a=Number(e).toRadians(),o=this.lat.toRadians(),i=this.lon.toRadians(),c=Math.sin(o)*Math.cos(r)+Math.cos(o)*Math.sin(r)*Math.cos(a),u=Math.asin(c),l=Math.sin(a)*Math.sin(r)*Math.cos(o),h=Math.cos(r)-Math.sin(o)*c,p=i+Math.atan2(l,h),f=u.toDegrees(),d=p.toDegrees();return new s(f,d)}static intersection(t,e,n,r){if(t instanceof s||(t=s.parse(t)),n instanceof s||(n=s.parse(n)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(r))throw new TypeError(`invalid brng2 ‘${r}’`);const a=t.lat.toRadians(),o=t.lon.toRadians(),c=n.lat.toRadians(),u=n.lon.toRadians(),l=Number(e).toRadians(),h=Number(r).toRadians(),p=c-a,f=u-o,d=2*Math.asin(Math.sqrt(Math.sin(p/2)*Math.sin(p/2)+Math.cos(a)*Math.cos(c)*Math.sin(f/2)*Math.sin(f/2)));if(Math.abs(d)<Number.EPSILON)return new s(t.lat,t.lon);const M=(Math.sin(c)-Math.sin(a)*Math.cos(d))/(Math.sin(d)*Math.cos(a)),g=(Math.sin(a)-Math.sin(c)*Math.cos(d))/(Math.sin(d)*Math.cos(c)),m=Math.acos(Math.min(Math.max(M,-1),1)),y=Math.acos(Math.min(Math.max(g,-1),1)),b=l-(Math.sin(u-o)>0?m:2*i-m),w=(Math.sin(u-o)>0?2*i-y:y)-h;if(0==Math.sin(b)&&0==Math.sin(w))return null;if(Math.sin(b)*Math.sin(w)<0)return null;const v=-Math.cos(b)*Math.cos(w)+Math.sin(b)*Math.sin(w)*Math.cos(d),N=Math.atan2(Math.sin(d)*Math.sin(b)*Math.sin(w),Math.cos(w)+Math.cos(b)*v),P=Math.asin(Math.min(Math.max(Math.sin(a)*Math.cos(N)+Math.cos(a)*Math.sin(N)*Math.cos(l),-1),1)),S=o+Math.atan2(Math.sin(l)*Math.sin(N)*Math.cos(a),Math.cos(N)-Math.sin(a)*Math.sin(P)),O=P.toDegrees(),R=S.toDegrees();return new s(O,R)}crossTrackDistanceTo(t,e,n=6371e3){t instanceof s||(t=s.parse(t)),e instanceof s||(e=s.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(a)*Math.sin(o-i))*r}alongTrackDistanceTo(t,e,n=6371e3){t instanceof s||(t=s.parse(t)),e instanceof s||(e=s.parse(e));const r=n;if(this.equals(t))return 0;const a=t.distanceTo(this,r)/r,o=t.initialBearingTo(this).toRadians(),i=t.initialBearingTo(e).toRadians(),c=Math.asin(Math.sin(a)*Math.sin(o-i));return Math.acos(Math.cos(a)/Math.abs(Math.cos(c)))*Math.sign(Math.cos(i-o))*r}maxLatitude(t){const e=Number(t).toRadians(),n=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(n))).toDegrees()}static crossingParallels(t,e,n){if(t.equals(e))return null;const r=Number(n).toRadians(),a=t.lat.toRadians(),i=t.lon.toRadians(),s=e.lat.toRadians(),c=e.lon.toRadians()-i,u=Math.sin(a)*Math.cos(s)*Math.cos(r)*Math.sin(c),l=Math.sin(a)*Math.cos(s)*Math.cos(r)*Math.cos(c)-Math.cos(a)*Math.sin(s)*Math.cos(r),h=Math.cos(a)*Math.cos(s)*Math.sin(r)*Math.sin(c);if(h*h>u*u+l*l)return null;const p=Math.atan2(-l,u),f=Math.acos(h/Math.sqrt(u*u+l*l)),d=i+p+f,M=(i+p-f).toDegrees(),g=d.toDegrees();return{lon1:o.wrap180(M),lon2:o.wrap180(g)}}rhumbDistanceTo(t,e=6371e3){t instanceof s||(t=s.parse(t));const n=e,r=this.lat.toRadians(),a=t.lat.toRadians(),o=a-r;let c=Math.abs(t.lon-this.lon).toRadians();Math.abs(c)>i&&(c=c>0?-(2*i-c):2*i+c);const u=Math.log(Math.tan(a/2+i/4)/Math.tan(r/2+i/4)),l=Math.abs(u)>1e-11?o/u:Math.cos(r);return Math.sqrt(o*o+l*l*c*c)*n}rhumbBearingTo(t){if(t instanceof s||(t=s.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),n=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>i&&(r=r>0?-(2*i-r):2*i+r);const a=Math.log(Math.tan(n/2+i/4)/Math.tan(e/2+i/4)),c=Math.atan2(r,a).toDegrees();return o.wrap360(c)}rhumbDestinationPoint(t,e,n=6371e3){const r=this.lat.toRadians(),a=this.lon.toRadians(),o=Number(e).toRadians(),c=t/n,u=c*Math.cos(o);let l=r+u;Math.abs(l)>i/2&&(l=l>0?i-l:-i-l);const h=Math.log(Math.tan(l/2+i/4)/Math.tan(r/2+i/4)),p=Math.abs(h)>1e-11?u/h:Math.cos(r),f=a+c*Math.sin(o)/p,d=l.toDegrees(),M=f.toDegrees();return new s(d,M)}rhumbMidpointTo(t){t instanceof s||(t=s.parse(t));const e=this.lat.toRadians();let n=this.lon.toRadians();const r=t.lat.toRadians(),a=t.lon.toRadians();Math.abs(a-n)>i&&(n+=2*i);const o=(e+r)/2,c=Math.tan(i/4+e/2),u=Math.tan(i/4+r/2),l=Math.tan(i/4+o/2);let h=((a-n)*Math.log(l)+n*Math.log(u)-a*Math.log(c))/Math.log(u/c);isFinite(h)||(h=(n+a)/2);const p=o.toDegrees(),f=h.toDegrees();return new s(p,f)}static areaOf(t,e=6371e3){const n=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const a=t.length-1;let o=0;for(let e=0;e<a;e++){const n=t[e].lat.toRadians(),r=t[e+1].lat.toRadians(),a=(t[e+1].lon-t[e].lon).toRadians();o+=2*Math.atan2(Math.tan(a/2)*(Math.tan(n/2)+Math.tan(r/2)),1+Math.tan(n/2)*Math.tan(r/2))}(function(t){let e=0,n=t[0].initialBearingTo(t[1]);for(let r=0;r<t.length-1;r++){const a=t[r].initialBearingTo(t[r+1]),o=t[r].finalBearingTo(t[r+1]);e+=(a-n+540)%360-180,e+=(o-a+540)%360-180,n=o}const r=t[0].initialBearingTo(t[1]);return e+=(r-n+540)%360-180,Math.abs(e)<90})(t)&&(o=Math.abs(o)-2*i);const s=Math.abs(o*n*n);return r||t.pop(),s}equals(t){return t instanceof s||(t=s.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${o.toLat(this.lat,t,e)}, ${o.toLon(this.lon,t,e)}`}}function c(t){return t*(180/Math.PI)}function u(t){return t*(Math.PI/180)}var l=n(0);angular.module("myitsmApp").service("nttTicketDistanceService",["nttGenericService","$q","i18nService","ModuleConfigService",function(t,e,n,r){this.getIncidentsByDistance=function(a,o,i,h,p){return e(function(e,f){var d=r.getModuleConfig("ticketDistanceService"),M=function(t,e,n){var r=t+c(n/6371),a=t-c(n/6371),o=e+c(n/6371/Math.cos(u(t))),i=e-c(n/6371/Math.cos(u(t)));return{center:[t,e],nw:[r,i],ne:[r,o],sw:[a,i],se:[a,o]}}(a,o,i),g="'666100011' <= "+M.ne[1]+" && '666100011' >= "+M.nw[1]+" && '666100012' <= "+M.ne[0]+" && '666100012' >= "+M.se[0];d&&d.replaceDotByComma&&(g=g.replace(/\./g,",")),"all"!=p&&("open"==p?g+=" && '7' <= 3":"resolved"==p?g+=" && '7' > 3 && '7' <=5":"cancelled"==p&&(g+=" && '7' == 6")),t.getArEntriesByFormAndQual({form:"HPD:Help Desk",qual:g,fields:[179,666100011,666100012,1e9,1000000161,1000000218,6,7,1000000164,666100003,1000000151,1000000019,1000000018,1000000001]}).$promise.then(function(t){var r={0:"New",1:"Assigned",2:"In Progress",3:"Pending",4:"Resolved",5:"Closed",6:"Cancelled"},c={0:"Critical",1:"High",2:"Medium",3:"Low"},u={id:"179.value",lon:"666100011.value",lat:"666100012.value",title:"1000000000.value",type:function(t){return"incident"},displayId:"1000000161.value",assignee:"1000000218.value",lastModifyDate:function(t){return DayPilot.Date(t[6].value).d},status:function(t){return r[t[7].value]},priority:function(t){return c[t[1000000164].value]},adress:"666100003.value",description:function(t){return{label:n.getLocalizedString("ntt.address.showTicketsNearBy.ticket.desc.label"),value:t[1000000151].value}},custFirstName:"1000000019.value",custLastName:"1000000018.value",contactFirstName:"1000000019.value",contactLastName:"1000000018.value",company:"1000000001.value"},p=Object(l.morphism)(u,t.items.entries);h&&(p=_.reject(p,{id:h})),p=_.sortBy(_.forEach(p,function(t,e){var n,r,i,c,u,l;t.distance=(n=o,r=a,i=t.lon,c=t.lat,u=new s(r,n),l=new s(c,i),u.distanceTo(l))}),"distance"),p=_.reject(p,function(t){return t.distance/1e3>i}),e({incidents:p})},function(t){f(t.data)})})}}])}])}); |