@targomo/core
Advanced tools
Comparing version 0.2.8 to 0.2.9
@@ -5,3 +5,3 @@ { | ||
"author": "Targomo", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "repository": "github:targomo/targomo-js", |
/** | ||
* @targomo/core "0.2.8" http://targomo.com | ||
* @targomo/core "0.2.9" http://targomo.com | ||
* The JavaScript (& TypeScript) API for Targomo's time-based access mapping services. | ||
* (c) 2019 Targomo | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.tgm={})}(this,function(u){"use strict";!function(t){if(!t.fetch){var e="URLSearchParams"in t,i="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),n="FormData"in t,r="ArrayBuffer"in t;if(r)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=function(t){return t&&DataView.prototype.isPrototypeOf(t)},c=ArrayBuffer.isView||function(t){return t&&-1<s.indexOf(Object.prototype.toString.call(t))};d.prototype.append=function(t,e){t=h(t),e=f(e);var i=this.map[t];this.map[t]=i?i+","+e:e},d.prototype.delete=function(t){delete this.map[h(t)]},d.prototype.get=function(t){return t=h(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(h(t))},d.prototype.set=function(t,e){this.map[h(t)]=f(e)},d.prototype.forEach=function(t,e){for(var i in this.map)this.map.hasOwnProperty(i)&&t.call(e,this.map[i],i,this)},d.prototype.keys=function(){var i=[];return this.forEach(function(t,e){i.push(e)}),p(i)},d.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),p(e)},d.prototype.entries=function(){var i=[];return this.forEach(function(t,e){i.push([e,t])}),p(i)},i&&(d.prototype[Symbol.iterator]=d.prototype.entries);var l=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];S.prototype.clone=function(){return new S(this,{body:this._bodyInit})},b.call(S.prototype),b.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var u=[301,302,303,307,308];w.redirect=function(t,e){if(-1===u.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},t.Headers=d,t.Request=S,t.Response=w,t.fetch=function(i,r){return new Promise(function(n,t){var e=new S(i,r),s=new XMLHttpRequest;s.onload=function(){var t,r,e={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",r=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var e=t.split(":"),i=e.shift().trim();if(i){var n=e.join(":").trim();r.append(i,n)}}),r)};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new w(i,e))},s.onerror=function(){t(new TypeError("Network request failed"))},s.ontimeout=function(){t(new TypeError("Network request failed"))},s.open(e.method,e.url,!0),"include"===e.credentials?s.withCredentials=!0:"omit"===e.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),e.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===e._bodyInit?null:e._bodyInit)})},t.fetch.polyfill=!0}function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function p(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach(function(t,e){this.append(e,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function g(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function m(i){return new Promise(function(t,e){i.onload=function(){t(i.result)},i.onerror=function(){e(i.error)}})}function v(t){var e=new FileReader,i=m(e);return e.readAsArrayBuffer(t),i}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t)if("string"==typeof t)this._bodyText=t;else if(o&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(n&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(r&&o&&a(t))this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!r||!ArrayBuffer.prototype.isPrototypeOf(t)&&!c(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=g(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?g(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t,e,i,n=g(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,i=m(e),e.readAsText(t),i;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),i=new Array(e.length),n=0;n<e.length;n++)i[n]=String.fromCharCode(e[n]);return i.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},n&&(this.formData=function(){return this.text().then(T)}),this.json=function(){return this.text().then(JSON.parse)},this}function S(t,e){var i,n,r=(e=e||{}).body;if(t instanceof S){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=(i=e.method||this.method||"GET",n=i.toUpperCase(),-1<l.indexOf(n)?n:i),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function T(t){var r=new FormData;return t.trim().split("&").forEach(function(t){if(t){var e=t.split("="),i=e.shift().replace(/\+/g," "),n=e.join("=").replace(/\+/g," ");r.append(decodeURIComponent(i),decodeURIComponent(n))}}),r}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=200<=this.status&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:window);var n=function(t){this.serverUrl="https://api.targomo.com/",this.statisticsUrl="https://api.targomo.com/statistics/",this.tilesUrl="https://api.targomo.com/vector-statistics/",this.poiUrl="https://api.targomo.com/pointofinterest/",this.mapTilesUrl="https://maps.targomo.com/",this.photonGeocoderUrl="https://api.targomo.com/geocode/",this.overpassUrl="https://api.targomo.com/overpass/",this.fleetsUrl="https://api.targomo.com/fleetplanner/",this.basemapsUrl="https://maps.targomo.com/styles/",this.version=1,Object.assign(this,t)},r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function i(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var s=function(){return(s=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function g(s,o,a,c){return new(a||(a=Promise))(function(t,e){function i(t){try{r(c.next(t))}catch(t){e(t)}}function n(t){try{r(c.throw(t))}catch(t){e(t)}}function r(e){e.done?t(e.value):new a(function(t){t(e.value)}).then(i,n)}r((c=c.apply(s,o||[])).next())})}function m(i,n){var r,s,o,t,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,s&&(o=2&e[0]?s.return:e[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,e[1])).done)return o;switch(s=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,s=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(o=0<(o=a.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){a.label=e[1];break}if(6===e[0]&&a.label<o[1]){a.label=o[1],o=e;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(e);break}o[2]&&a.ops.pop(),a.trys.pop();continue}e=n.call(i,a)}catch(t){e=[6,t],s=0}finally{r=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var c=function(t,e,i,n){this.value=t,this.key=e,this.previous=i,this.next=n},e=function(){function t(t){void 0===t&&(t=0),this.capacity=t,this.map={},this.size=0}return t.prototype.get=function(o,a){return g(this,void 0,void 0,function(){var e,i,n,r,s;return m(this,function(t){switch(t.label){case 0:if(void 0===(e=this.map[o]))return[3,5];this.oldest==e&&e.next&&(this.oldest=e.next),e.next&&(e.next.previous=e.previous),e.previous&&(e.previous.next=e.next),e.previous=this.newest,e.next=null,this.newest=e,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.value];case 2:return[2,t.sent()];case 3:return t.sent(),this.map[o]=void 0,[2,this.get(o,a)];case 4:return[3,8];case 5:return a?(i=a(),n=this.map[o]=new c(i,o,this.newest,null),[4,i]):[3,7];case 6:return r=t.sent(),this.newest&&(this.newest.next=n),this.newest=n,this.capacity&&(this.size>=this.capacity?(s=this.oldest)&&(this.oldest=s.next,delete this.map[s.key]):this.size++),this.oldest||(this.oldest=this.newest),[2,r];case 7:return[2,void 0];case 8:return[2]}})})},t}(),t=function(){function t(){this.map={}}return t.prototype.get=function(n,r){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e="string"==typeof n?n:JSON.stringify(n),null==this.map[e]?[3,1]:[2,this.map[e]];case 1:return[4,r()];case 2:return i=t.sent(),[2,this.map[e]=i]}})})},t}(),a=new t,o=function(){function t(){}return t.prototype.fetch=function(h,f,p,d){return void 0===f&&(f="GET"),void 0===d&&(d={}),g(this,void 0,void 0,function(){var e,i,n,r,s,o,a,c,l,u;return m(this,function(t){switch(t.label){case 0:return"JSONP"!==(e=f)?d.Accept=d.Accept?d.Accept:"application/json":e="GET","POST-RAW"===f&&(e="POST"),"PUT"!==e&&"POST"!==e||(d["Content-Type"]="application/json"),i={method:e,headers:new Headers(d)},"POST-RAW"===f?i.body=p:"GET"!==f&&"JSONP"!==f&&(i.body=JSON.stringify(p)),[4,fetch(h,i)];case 1:return 400<=(n=t.sent()).status?"application/json"!==n.headers.get("content-type")?[3,3]:(a=(o=JSON).stringify,[4,n.text()]):[3,6];case 2:return s=a.apply(o,[t.sent(),null,2]),[3,5];case 3:return[4,n.text()];case 4:s=t.sent(),t.label=5;case 5:throw r=s,console.error("[ERROR] in service request\n status = "+n.status+" "+n.statusText+"\n url = "+h+"\n body = "+r),new Error(r);case 6:return"JSONP"!==f?[3,8]:[4,n.text()];case 7:return c=t.sent(),l=c.indexOf("("),u=c.lastIndexOf(")"),-1<l&&-1<u?[2,JSON.parse(c.substring(l+1,u))]:[2,JSON.parse(c)];case 8:return[2,n.json()];case 9:return[2]}})})},t.prototype.fetchData=function(i,n,r,s){return void 0===n&&(n="GET"),g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return[4,this.fetch(i,n,r,s)];case 1:return(e=t.sent()).data?[2,e.data]:(console.warn("No data object was transmitted by "+i+" \nReturning raw response"),[2,e])}})})},t.prototype.fetchCached=function(t,e,i,n,r){var s=this;if(void 0===i&&(i="GET"),!1===t)return this.fetch(e,i,n,r);!0!==t&&t||(t=a);var o=JSON.stringify({url:e,method:i,payload:n});return t.get(o,function(){return s.fetch(e,i,n,r)})},t.prototype.fetchCachedData=function(t,e,i,n,r){var s=this;if(void 0===i&&(i="GET"),!1===t)return this.fetchData(e,i,n,r);!0!==t&&t||(t=a);var o=JSON.stringify({url:e,method:i,payload:n});return t.get(o,function(){return s.fetchData(e,i,n,r)})},t}();function h(t,e){return new o}var l,f,p=function(){function t(t){this.client=t}return t.prototype.fetch=function(r,s,o){return g(this,void 0,void 0,function(){var e,i,n;return m(this,function(t){switch(t.label){case 0:return e={west:o.southWest.lng,south:o.southWest.lat,east:o.northEast.lng,north:o.northEast.lat},i={bounds:e,benchmarks:s.map(function(t){return{source:t.source,minEnd:t.minEnd,minStart:t.minStart,factor:t.factor}})},n=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("benchmarks/scores_cumulative/").version().part("/"+encodeURIComponent(""+r)).key().toString(),[4,h(this.client).fetch(n,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.metadata=function(i){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("benchmarks/meta/").version().part("/"+encodeURIComponent(""+i)).key().toString(),[4,h(this.client).fetch(e)];case 1:return[2,t.sent()]}})})},t}();l=u.UrlUtil||(u.UrlUtil={}),f=function(){function t(t){this.client=t,this.url="",this.firstParamPlaced=!1}return t.prototype.host=function(t){return 0===this.url.length&&"/"!==t[t.length-1]&&(t+="/"),this.part(t)},t.prototype.part=function(t){return this.url+=t,this},t.prototype.version=function(){return null!==this.client.config.version&&void 0!==this.client.config.version?this.part("v"+this.client.config.version):"/"===this.url[this.url.length-1]&&(this.url=this.url.substr(0,this.url.length-1)),this},t.prototype.params=function(t){var i=this;return Object.keys(t).forEach(function(e){t[e]instanceof Array?t[e].forEach(function(t){i.param(e,t)}):i.param(e,t[e])}),this},t.prototype.param=function(t,e){this.firstParamPlaced?this.url+="&"+t+"="+e:(this.firstParamPlaced=!0,this.url+="?"+t+"="+e)},t.prototype.key=function(){return this.params({key:this.client.serviceKey})},t.prototype.toString=function(){return this.url},t}(),l.TargomoUrl=f;var d=function(){function t(){}return t.prototype.geocode=function(r,s,t,o,a){return g(this,void 0,void 0,function(){var e,i,n;return m(this,function(t){switch(t.label){case 0:return e={singleLine:r,f:"json",countryCode:o,maxLocations:5},s&&(e.location=s.lng+","+s.lat),a&&(e.magicKey=a),i=(new u.UrlUtil.TargomoUrl).part("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates").params(e).toString(),[4,h().fetch(i)];case 1:return n=t.sent(),[2,n.candidates.map(function(t){return{lat:t.location.y,lng:t.location.x,description:t.address}})]}})})},t.prototype.suggest=function(n,r,t,s,o){return void 0===o&&(o=5),g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e={text:n,f:"json",countryCode:s,maxSuggestions:o},r&&(e.location=r.lng+","+r.lat),i=(new u.UrlUtil.TargomoUrl).part("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest").params(e).toString(),[4,h().fetch(i)];case 1:return[2,t.sent().suggestions]}})})},t.prototype.reverseGeocode=function(r,t){return g(this,void 0,void 0,function(){var e,i,n;return m(this,function(t){switch(t.label){case 0:return(e={f:"json"}).location=r.lng+","+r.lat,i=(new u.UrlUtil.TargomoUrl).part("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode").params(e).toString(),[4,h().fetch(i)];case 1:return(n=t.sent())&&n.address?[2,{address:n.address.Match_addr,city:n.address.City,countryCode:n.address.CountryCode,location:n.address.Loc_name,region:n.address.Region,subregion:n.address.Subregion,zip:n.address.Postal}]:[2,{}]}})})},t}(),v=function(){function t(t){this.client=t}return t.prototype.geocode=function(r,s,o){return g(this,void 0,void 0,function(){var e,i,n=this;return m(this,function(t){switch(t.label){case 0:return e=(new u.UrlUtil.TargomoUrl).host(this.client.config.photonGeocoderUrl).part("api").params({q:encodeURIComponent(r),limit:5}).toString(),s&&(e+="&lat="+s.lat+"&lon="+s.lng),o&&(e+="&lang="+encodeURIComponent(o)),[4,h().fetch(e)];case 1:return(i=t.sent()).features.forEach(function(t,e,i){"boundary"==t.properties.osm_key&&i.splice(e,1)}),[2,i.features.map(function(t){return t.value=t.properties.osm_id,t.description=n.buildPlaceDescription(t.properties),t})]}})})},t.prototype.buildPlaceDescription=function(i){var n=function(t,e){return void 0===e&&(e=" "),t.filter(function(t){return!!t}).join(e).trim()},t=function(t,e){return n(t.map(function(t){return i[t]}),e)},e=t(["street","housenumber"]," "),r=n([t(["postcode","city"]," "),i.country],", "),s={title:"",meta1:"",meta2:"",full:""};return void 0!==i.name?(s.title=i.name,s.meta1=e,s.meta2=r):(s.title=e,s.meta1=r),i.name!==e&&(s.full=s.title),s.meta1&&i.name!==e&&(s.full+=", "+s.meta1),s.meta1&&i.name===e&&(s.full+=s.meta1),s.full=n([s.full,s.meta2],", "),s},t}(),y=function(){},b=function(){this.edgeWeight="time"},S=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.transitFrameDuration=void 0,t.transitFrameDate=20170801,t.transitFrameTime=39600,t.transitMaxTransfers=5,t.walkSpeed={},t.bikeSpeed={},t}return i(t,e),t}(b),T=function(s){function t(t){var e=s.call(this)||this;if(Object.assign(e,t),null!=t.transitFrameDateTime){var i=void 0,n=(i=t.transitFrameDateTime instanceof Date?t.transitFrameDateTime:new Date(t.transitFrameDateTime))?1e4*i.getFullYear()+100*(i.getMonth()+1)+i.getDate():void 0,r=i?3600*i.getHours()+60*i.getMinutes():void 0;e.transitFrameDate=n||e.transitFrameDate,e.transitFrameTime=r||e.transitFrameTime}return e}return i(t,s),t.prototype.buildTargetsCfg=function(t){return t.map(function(t){return{lat:t.lat,lng:t.lng,id:t.id}})},t.prototype.buildSourcesCfg=function(t){var i=this;return t.map(function(t){var e={lat:t.lat,lng:t.lng,id:t.id,tm:t.tm};if(!e.tm)switch(i.travelType){case"car":e.tm={car:i.rushHour?{rushHour:i.rushHour}:{}};break;case"walk":e.tm={walk:i.walkSpeed};break;case"bike":e.tm={bike:i.bikeSpeed};break;case"transit":e.tm={transit:{frame:{date:i.transitFrameDate,time:i.transitFrameTime,duration:i.transitFrameDuration},maxTransfers:i.transitMaxTransfers}}}return e})},t}(S),w=function(r){function t(t,e,i){var n=r.call(this,e)||this;return n.sources=n.buildSourcesCfg(t),i&&(n.targets=n.buildTargetsCfg(i)),n.multigraph=e.multigraph,n}return i(t,r),t}(T),U=function(){function t(t){this.client=t}return t.prototype.fetch=function(n,r,s){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/multigraph").key().toString(),i=new w(n,r,s),[4,h(this.client).fetch(e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.fetchOverview=function(n,r,s){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/multigraph/overview").key().toString(),i=new w(n,r,s),[4,h(this.client).fetch(e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.getTiledMultigraphUrl=function(r,s,o,a){return g(this,void 0,void 0,function(){var e,i,n;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/objectcache/add").key().toString(),i=new w(r,s,a),[4,h(this.client).fetch(e,"POST",i)];case 1:return n=t.sent(),[2,new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/multigraph/{z}/{x}/{y}."+o).key().params({cfgUuid:n.uuid}).toString()]}})})},t}(),E=function(t,e,i,n){this.description=n.description||"",this.serviceUrl=t,this.serviceKey=e,this.email=n.email||"developers@targomo.com",this.sendMail=!1,this.callbackUrl=n.callbackUrl||"https://localhost/",this.pointsPerSolution=n.pointsPerSolution,this.maxSolutions=n.maxSolutions||1,this.travelType=n.travelType,this.edgeWeight=n.edgeWeight,this.maxEdgeWeight=n.maxEdgeWeight,this.statisticGroupId=n.statisticGroup,n.statistic instanceof Number||"number"==typeof n.statistic?this.statisticId=+n.statistic:this.statisticId=n.statistic.id;var r={};i.forEach(function(t){r[t.id]={id:t.id,x:t.lng,y:t.lat}}),this.sources.push(r)},A=function(t){this.raw=t,this.id=t.id,this.maxPossibleValue=t.maxPossibleValue,this.solutions=t.simulationResults.map(function(t){var e={};return t.sourcePoints.forEach(function(t){e[t.id]=t.optimal}),{id:t.id,startTime:t.startTime,endTime:t.endTime,maxValue:t.maxValue,numberOfDesiredPoints:t.numberOfDesiredPoints,sources:e}})},C=function(){function t(t){this.client=t}return t.prototype.create=function(r,s){return g(this,void 0,void 0,function(){var e,i,n;return m(this,function(t){switch(t.label){case 0:return r.length?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("simulation/start/").key().params({serviceUrl:encodeURIComponent(this.client.serviceUrl)}).toString(),i=new E(this.client.serviceUrl,this.client.serviceKey,r,s),[4,h(this.client).fetch(e,"POST",i)]):[2,null];case 1:return[2,(n=t.sent())&&+n.id]}})})},t.prototype.ready=function(i){return g(this,void 0,void 0,function(){var e;return m(this,function(t){return i instanceof Array||(i=[i]),e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("simulation/ready/").key().params({serviceUrl:encodeURIComponent(this.client.serviceUrl),simulationId:i}).toString(),[2,h(this.client).fetch(e)]})})},t.prototype.fetch=function(n){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("simulation/"+n+"/").key().params({serviceUrl:encodeURIComponent(this.client.serviceUrl)}).toString(),i=A.bind,[4,h(this.client).fetch(e)];case 1:return[2,new(i.apply(A,[void 0,t.sent()]))]}})})},t}(),O=function(r){function t(t,e,i){var n=r.call(this,i)||this;return n.osmTypes=[],n.sources=n.buildSourcesCfg([e]),n.osmTypes=i.osmTypes,n.format=i.format,n.serviceKey=t.serviceKey,n.serviceUrl=t.serviceUrl,n}return i(t,r),t}(T),R=function(){function i(t,e,i,n){this.id=t,this.lng=e,this.lat=i,this.properties=n,this.properties&&(this.properties["marker-size"]=1)}return i.prototype.toString=function(){return this.properties?this.properties.name:""},i.prototype.copy=function(){var t=new i(this.id,this.lat,this.lng,s({},this.properties));for(var e in this)"properties"!=e&&(t[e]=this[e]);return t},i}();function I(t){var e=t.lat,i=t.lon;return void 0===e&&t.center&&(e=t.center.lat,i=t.center.lon),new R(t.id,i,e,t.tags)}var _,x=function(){function t(t){this.client=t}return t.prototype.queryRaw=function(e){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return[4,h(this.client).fetch(this.client.config.overpassUrl+"/api/interpreter","POST-RAW",e)];case 1:return[2,t.sent().elements.filter(function(t){return!!t.tags}).map(function(t){return I(t)})]}})})},t.prototype.query=function(t,i){function n(t){if("*"===t.tag||null==t.tag)return'"'+t.type+'"';if(t.type&&t.tag)return'"'+t.type+'"="'+t.tag+'"';throw new Error("invalid query"+JSON.stringify(t))}var r=[];t.forEach(function(e){i.forEach(function(t){r.push("\n way["+n(e)+"]\n ("+t.southWest.lat+","+t.southWest.lng+","+t.northEast.lat+","+t.northEast.lng+");\n node["+n(e)+"]\n ("+t.southWest.lat+","+t.southWest.lng+","+t.northEast.lat+","+t.northEast.lng+");\n ")})});var e="\n [out:json];\n (\n "+r.join("")+"\n );\n out center;\n ";return this.queryRaw(e)},t.prototype.queryGetCustom=function(e){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return[4,h(this.client).fetch(e)];case 1:return[2,t.sent().elements.map(function(t){return I(t)})]}})})},t.prototype.reachable=function(i,n){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return e=this.client.config.poiUrl+"/reachability",[4,h(this.client).fetch(e,"POST",new O(this.client,i,n))];case 1:return[2,t.sent()]}})})},t}(),P=function(){},M=function(){};(_=u.StatisticsGroups||(u.StatisticsGroups={}))[_.GERMANY_ZENSUS_100M_STATISTICS=9]="GERMANY_ZENSUS_100M_STATISTICS",_[_.GERMANY_ZENSUS_200M_STATISTICS=2]="GERMANY_ZENSUS_200M_STATISTICS",_[_.GERMANY_ZENSUS_500M_STATISTICS=11]="GERMANY_ZENSUS_500M_STATISTICS",_[_.GERMANY_ZENSUS_1000M_STATISTICS=3]="GERMANY_ZENSUS_1000M_STATISTICS",_[_.GERMANY_ZENSUS_2000M_STATISTICS=10]="GERMANY_ZENSUS_2000M_STATISTICS",_[_.NORWAY_STATISTICS=4]="NORWAY_STATISTICS",_[_.CENSUS_BRANDENBURG_POPULATION=12]="CENSUS_BRANDENBURG_POPULATION",_[_.CANADA_BLOCK_STATISTICS=8]="CANADA_BLOCK_STATISTICS",_[_.CANADA_AREA_STATISTICS=5]="CANADA_AREA_STATISTICS",_[_.BERLIN_STATISTICS=6]="BERLIN_STATISTICS";var N,D,k,G=function(){},W=function(t){for(var e in this.values=t,this.total=0,this.values)this.total+=this.values[e]};(N=u.SRID||(u.SRID={}))[N.SRID_3857=3857]="SRID_3857",N[N.SRID_4326=4326]="SRID_4326",(D=u.MultigraphRequestAggregation||(u.MultigraphRequestAggregation={})).NONE="none",D.SUM="sum",D.MAX="max",D.MIN="min",D.MEAN="mean",D.MEDIAN="median",D.NEAREST="nearest",D.UNION="routing_union",(k=u.MultigraphRequestLayer||(u.MultigraphRequestLayer={})).EDGE="edge",k.NODE="node",k.TILE="tile",k.HEXAGON="hexagon",k.TILE_NODE="tile_node",k.HEXAGON_NODE="hexagon_node";var B=new(function(){function t(){this.R=6378137}return t.prototype.project=function(t){var e=Math.PI/180,i=Math.max(Math.min(Math.sin(t.lat*e),1-1e-15),-(1-1e-15));return{x:this.R*t.lng*e,y:this.R*Math.log((1+i)/(1-i))/2}},t.prototype.unproject=function(t){var e=180/Math.PI;return{lat:(2*Math.atan(Math.exp(t.y/this.R))-Math.PI/2)*e,lng:t.x*e/this.R}},t}()),j=6371.01,F=Math.PI/180;function L(t,e){var i=F*t.lat,n=F*t.lng,r=F*e.lat,s=F*e.lng;return Math.acos(Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos(n-s))*j}function H(t,e){e*=1e3;var i=t.lat,n=t.lng,r=i*F,s=e/1e3/110.574235,o=e/1e3/(110.572833*Math.cos(r));return{northEast:{lat:i+s,lng:n+o},southWest:{lat:i-s,lng:n-o}}}function z(t){switch(t.travelType){case"walk":return 10;case"bike":return 25;case"transit":return 150;default:return 120}}function q(t,i,e){return i instanceof Array?K(t,i,e).filter(function(e){return!i.some(function(t){return t==e})}):K(t,i,e).filter(function(t){return i!=t})}function K(t,i,n){return i instanceof Array?t.filter(function(e){return i.some(function(t){return L(e,t)<=n})}):t.filter(function(t){return L(t,i)<=n})}function V(t,e){var i=B.unproject(t);return null!=e?{lat:i.lat,lng:i.lng,elevation:e}:i}var J,Y=Object.freeze({contains:function(t,e){return e.lat>=t.southWest.lat&&e.lat<=t.northEast.lat&&e.lng>=t.southWest.lng&&e.lng<=t.northEast.lng},calculateDistance:L,boundingBox:H,locationsWithinTravelOptions:function(t,e,i){var n,r=i.maxEdgeWeight;switch(i.travelType){case"walk":n=10;break;case"bike":n=25;break;case"transit":n=150;break;default:n=120}return q(t,e,"distance"===i.edgeWeight?Math.round(r/1e3):n*r/3600)},boundingBoxWithinTravelOptions:function(t,e){var i=e.maxEdgeWeight,n=z(e);return H(t,"distance"===e.edgeWeight?Math.round(i/1e3):n*i/3600)},boundingBoxFromLocationArray:function(t){return t.reduce(function(t,e){return t.northEast.lat=e.lat>t.northEast.lat?e.lat:t.northEast.lat,t.northEast.lng=e.lng>t.northEast.lng?e.lng:t.northEast.lng,t.southWest.lat=e.lat<t.southWest.lat?e.lat:t.southWest.lat,t.southWest.lng=e.lng<t.southWest.lng?e.lng:t.southWest.lng,t},{northEast:{lat:t[0].lat,lng:t[0].lng},southWest:{lat:t[0].lat,lng:t[0].lng}})},boundingBoxListWithinTravelOptions:function(t,e){var i=e.maxEdgeWeight,n=z(e),r="distance"===e.edgeWeight?Math.round(i/1e3):n*i/3600,s={northEast:{lat:-1/0,lng:-1/0},southWest:{lat:1/0,lng:1/0}};return t.forEach(function(t){var e=H(t,r);s.northEast.lat=Math.max(s.northEast.lat,e.northEast.lat),s.northEast.lng=Math.max(s.northEast.lng,e.northEast.lng),s.southWest.lat=Math.min(s.southWest.lat,e.southWest.lat),s.southWest.lng=Math.min(s.southWest.lng,e.southWest.lng)}),s},locationsWithinDistance:q,locationsWithinDistanceInclusive:K,webMercatorToLatLng:V,latLngToWebMercator:function(t){return B.project(t)}}),Z=function(t,e){var i=this;this.points=[],this.type=e.type,this.travelTime=e.travelTime,this.distance=e.length/1e3,this.warning=e.warning,this.elevationGain=e.elevationGain,this.transitSegment=!1,this.startName=e.startname,this.endName=e.endname,e.points.forEach(function(t){i.points.push(V({x:t[1],y:t[0]},t[2]))}),e.isTransit&&(this.transitSegment=!0,this.routeType=e.routeType,this.routeShortName=e.routeShortName,this.startName=e.startname,this.endName=e.endname,this.departureTime=e.departureTime,this.arrivalTime=e.arrivalTime,this.tripHeadSign=e.tripHeadSign)},X=function(){function t(i,t,e,n){var r=this;this.travelTime=t,this.routeSegments=[],this.targetHeight=void 0,this.sourceHeight=void 0,this.sourceId=void 0,this.targetId=void 0,this.length=void 0;var s=0,o=[];e.reverse().forEach(function(t){var e=new Z(i,t);r.routeSegments.push(e),"TRANSFER"===e.type&&s++,o=o.concat(e.points.reverse())}),this.points=o,this.transfers=s,void 0!==n&&(this.sourceId=n.source_id,this.targetId=n.target_id,this.length=n.length);var a=this.calculateElevationDifferences(this.points);this.targetHeight=a.targetHeight,this.sourceHeight=a.sourceHeight,this.uphillMeter=a.uphillMeter,this.downhillMeter=a.downhillMeter,this.totalElevationDifference=Math.abs(this.sourceHeight-this.targetHeight),this.departureTime=this.calculateDepartureTime(),this.arrivalTime=this.calculateArrivalTime(),this.distance=this.calculateDistance(),this.elevationGain=this.calculateElevationGain()}return t.prototype.calculateDistance=function(){for(var t=0,e=0;e<this.routeSegments.length;e++)t+=this.routeSegments[e].distance;return t},t.prototype.calculateElevationGain=function(){for(var t=void 0,e=0;e<this.routeSegments.length;e++)isFinite(this.routeSegments[e].elevationGain)&&(t=(t||0)+this.routeSegments[e].elevationGain);return t},t.prototype.calculateElevationDifferences=function(t){for(var e=void 0,i=void 0,n=void 0,r=0,s=0,o=this.points.length-1;0<=o;o--)0==o&&(i=this.points[o].elevation),o==this.points.length-1&&(n=this.points[o].elevation),void 0!==e&&(e>this.points[o].elevation?r+=e-this.points[o].elevation:e<this.points[o].elevation&&(s+=this.points[o].elevation-e)),e=this.points[o].elevation;return{targetHeight:i,sourceHeight:n,uphillMeter:r,downhillMeter:s}},t.prototype.calculateDepartureTime=function(){for(var t=0,e=0;e<this.routeSegments.length;e++){var i=this.routeSegments[e];if(null!=i.departureTime)return i.departureTime-t;t+=i.travelTime||0}},t.prototype.calculateArrivalTime=function(){for(var t=0,e=this.routeSegments.length-1;0<=e;e--){var i=this.routeSegments[e];if(null!=i.arrivalTime)return i.arrivalTime-t;t+=i.travelTime||0}},t}(),$=function(t,s){function e(t){for(var e={},i=0,n=s;i<n.length;i++){var r=n[i];e[r.name]=new W(t[r.id])}return e}var i={};if(t.individualStatistics)for(var n in t.individualStatistics)t.individualStatistics[n]&&t.individualStatistics[n].statistics&&(i[n]=e(t.individualStatistics[n].statistics));this.statistics=e(t.statistics),this.individualStatistics=i,this.raw=t};(J=u.MultigraphStatus||(u.MultigraphStatus={})).CREATED="CREATED",J.ROUTING="ROUTING",J.MERGING="MERGING",J.AGGREGATING="AGGREGATING",J.COMPLETED="COMPLETED",J.FAILED="FAILED";var Q=function(){},tt=function(t,e){this.values={};var i={};e.forEach(function(t){i[t.id]=t.name}),this.raw=t;var n=this.values;for(var r in t){var s=t[r],o=(s.aggregation||"").toLowerCase();n[o]=n[o]||{};var a=i[s.statisticId];n[o][a]={value:s.value}}},et=function(){this.minPolygonHoleSize=1e7,this.buffer=50,this.simplify=50,this.srid=u.SRID.SRID_4326,this.quadrantSegments=2,this.intersectionMode="union",this.decimalPrecision=6},it=function(r){function t(t,e,i){var n=r.call(this,i)||this;return n.polygon=new et,n.sources=n.buildSourcesCfg(e),n.polygon.values=i.travelEdgeWeights,n.polygon.serializer=i.serializer,n.polygon.simplify=i.simplify,n.polygon.srid=i.srid,n.polygon.buffer=i.buffer,n.polygon.minPolygonHoleSize=i.minPolygonHoleSize,n.polygon.quadrantSegments=i.quadrantSegments,n.polygon.intersectionMode=i.intersectionMode,n.polygon.decimalPrecision=i.decimalPrecision,n}return i(t,r),t}(T),nt=function(){function t(t){this.client=t}return t.prototype.fetch=function(n,r){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new it(this.client,n,r),[4,this._executeFetch(n,r,e)];case 1:return i=t.sent(),"json"===r.serializer?[2,i]:"geojson"===r.serializer?[2,i]:[2]}})})},t.prototype._executeFetch=function(t,n,r){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/polygon").key().toString(),[4,h(this.client).fetchCachedData(n.useClientCache,e,"POST",r)];case 1:return(i=t.sent()).metadata=n,[2,i]}})})},t}(),rt=function(s){function t(t,e,i,n){var r=s.call(this,n)||this;return r.sources=r.buildSourcesCfg(e),r.targets=r.buildTargetsCfg(i),r}return i(t,s),t}(T),st=function(){function t(t){this.client=t}return t.prototype.individual=function(n,r,s){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/time").key().toString(),i=new rt(this.client,n,r,s),[4,h(this.client).fetchCachedData(s.useClientCache,e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.combined=function(n,r,s){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/reachability").key().toString(),i=new rt(this.client,n,r,s),[4,h(this.client).fetchCachedData(s.useClientCache,e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.count=function(e,i,n){return g(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return[4,this.locations(e,i,n)];case 1:return[2,t.sent().length]}})})},t.prototype.locations=function(e,n,r){return g(this,void 0,void 0,function(){var i;return m(this,function(t){switch(t.label){case 0:return i={},n.forEach(function(t){return i[String(t.id)]=-1}),[4,this.combined(e,n,r)];case 1:return t.sent().forEach(function(t){var e=String(t.id);i[e]?-1<t.travelTime&&(-1<i[e]?i[e]=Math.min(i[e],t.travelTime):i[e]=t.travelTime):console.warn("NOT FOUND",String(t.id))}),[2,n.filter(function(t){var e=String(t.id);return t.travelTime=i[e],-1<i[e]})]}})})},t}(),ot=function(s){function t(t,e,i,n){var r=s.call(this,n)||this;return r.sources=r.buildSourcesCfg(e),r.targets=r.buildTargetsCfg(i),r.pathSerializer=n.pathSerializer,"boolean"==typeof n.recommendations&&(n.recommendations=n.recommendations?1:0),Number.isInteger(n.recommendations)&&r.sources&&r.sources.forEach(function(t){if(null!=t.tm)for(var e in t.tm)t.tm[e].recommendations=n.recommendations}),r}return i(t,s),t}(T),at=function(){function t(t){this.client=t}return t.prototype.fetch=function(s,o,a){return g(this,void 0,void 0,function(){var e,i,n,r=this;return m(this,function(t){switch(t.label){case 0:return e=new ot(this.client,s,o,a),i=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/route").key().params({cfg:encodeURIComponent(JSON.stringify(e))}).toString(),[4,h(this.client).fetchCachedData(a.useClientCache,i,"GET",void 0,{Accept:"application/json,application/javascript,*/*"})];case 1:return(n=t.sent()).routes?[2,n.routes.map(function(t){return new X(r.client,t.travelTime,t.segments,t)})]:[2,null]}})})},t}(),ct=function(){function t(t){this.client=t}return t.prototype.metadata=function(i){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("similarity/meta/").version().part("/"+encodeURIComponent(""+i)).key().toString(),[4,h(this.client).fetch(e)];case 1:return[2,t.sent()]}})})},t.prototype.fetch=function(s,o,a,c,l){return g(this,void 0,void 0,function(){var e,i,n,r;return m(this,function(t){switch(t.label){case 0:return e={west:c.southWest.lng,south:c.southWest.lat,east:c.northEast.lng,north:c.northEast.lat},i={bounds:e,refCellId:o,scores:a.map(function(t){return{source:t.source,minutes:t.minutes,factor:t.factor||1}})},n=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("similarity/scores_cumulative/").version().part("/"+encodeURIComponent(""+s)).key(),r=l?n.params({normalizeOnViewport:!!l}).toString():n.toString(),[4,h(this.client).fetch(r,"POST",i)];case 1:return[2,t.sent()]}})})},t}();var lt=function(t,e,i){this.inactiveSources=[],this.getClosestSources=!1,this.serviceUrl=t.serviceUrl,this.serviceKey=t.serviceKey,this.useCache=null==i.useCache||i.useCache,this.sources=e.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}),this.iFeelLucky=i.iFeelLucky,this.travelType=i.travelType,this.edgeWeight=i.edgeWeight,this.maxEdgeWeight=i.maxEdgeWeight,i.inactiveSources&&(this.inactiveSources=i.inactiveSources.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}));var n=[];i.statistics&&(this.omitIndividualStatistics=i.omitIndividualStatistics,n=i.statistics.map(function(t){return t instanceof Number||"number"==typeof t?+t:t.id})),this.statisticGroupId=+i.statisticsGroup,this.statisticIds=n,i.closestSources&&(this.getClosestSources=!0)},ut=function(t,e,i){var n=i.statistics.map(function(t){return t instanceof Number||"number"==typeof t?+t:t.id});this.statisticGroupId=+i.statisticsGroup,this.statisticIds=n,this.intersectionGeometry={data:e,crs:i.crs||4326}},ht=function(){function t(t){this.client=t,this.statisticsMetadataCache=new e(200),this.statisticsEnsemblesCache=new e(200)}return t.prototype.combined=function(i,n){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return[4,this.dependent(i,n)];case 1:return[2,(e=t.sent())&&e.statistics]}})})},t.prototype.individual=function(i,n){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return[4,this.dependent(i,n)];case 1:return[2,(e=t.sent())&&e.individualStatistics]}})})},t.prototype.travelTimes=function(i,n){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return i.length?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("traveltimes").params({serviceUrl:this.client.serviceUrl}).toString(),[4,h(this.client).fetch(e,"POST",new lt(this.client,i,n))]):[2,null];case 1:return[2,t.sent()]}})})},t.prototype.dependent=function(n,r){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return n.length?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("charts/dependent").params({serviceUrl:this.client.serviceUrl}).toString(),[4,h(this.client).fetch(e,"POST",new lt(this.client,n,r))]):[2,null];case 1:return i=t.sent(),[2,new $(i,r.statistics)]}})})},t.prototype.geometry=function(n,r){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return n?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("values/geometry").params({serviceUrl:this.client.serviceUrl}).toString(),[4,h(this.client).fetch(e,"POST",new ut(this.client,n,r))]):[2,null];case 1:return i=t.sent(),[2,new tt(i,r.statistics)]}})})},t.prototype.metadata=function(s){return g(this,void 0,void 0,function(){var e,n,i,r=this;return m(this,function(t){switch(t.label){case 0:return e=this.client.config.tilesUrl,n="number"==typeof s?s:s.id,i=e+"-"+n,[4,this.statisticsMetadataCache.get(i,function(){return g(r,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("statistics/meta/").version().part("/"+n).key().toString(),[4,h(this.client).fetch(e)];case 1:return!(i=t.sent()).name&&i.names&&i.names.en&&(i.name=i.names.en),i.stats&&i.stats.length&&i.stats.forEach(function(t){!t.name&&t.names&&t.names.en&&(t.name=t.names.en)}),[2,i]}})})})];case 1:return[2,t.sent()]}})})},t.prototype.metadataKey=function(s,o){return g(this,void 0,void 0,function(){var e,i,n,r;return m(this,function(t){switch(t.label){case 0:return[4,this.metadata(s)];case 1:for(e=t.sent(),i=0,n=e.stats;i<n.length;i++)if(r=n[i],o.id==r.statistic_id||r.names&&r.names.en==o.name)return[2,r];return[2,null]}})})},t.prototype.tileRoute=function(t,e){var i="number"==typeof t?t:t.id,n=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("statistics/tiles/").version().part("/"+i+"/{z}/{x}/{y}.mvt").key();return e&&0<e.length?n.params({columns:encodeURIComponent(e.map(function(t){return+t.id}).join(","))}).toString():n.toString()},t.prototype.ensembles=function(){return g(this,void 0,void 0,function(){var e,i=this;return m(this,function(t){switch(t.label){case 0:return e=this.client.config.tilesUrl,[4,this.statisticsEnsemblesCache.get(e,function(){return g(i,void 0,void 0,function(){var e,i,n,r;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("ensemble/list/").version().key().toString(),[4,h(this.client).fetch(e,"GET")];case 1:for(n in i=t.sent())i[n]&&((r=i[n]).id=+r.id,r.groups&&r.groups.length&&r.groups.forEach(function(t){t.hierarchy=+t.hierarchy,t.id=+t.id}));return[2,i]}})})})];case 1:return[2,t.sent()]}})})},t}(),ft=function(r){function t(t,e,i){var n=r.call(this,t,e,i)||this;return delete n.inactiveSources,delete n.statisticGroupId,delete n.statisticIds,delete n.getClosestSources,delete n.useCache,i&&(n.multiGraphSerializationType=i.multigraph.serialization.format,n.multiGraphSerializationDecimalPrecision=i.multigraph.serialization.decimalPrecision,i.multigraph.aggregation&&(n.multiGraphAggregationType=i.multigraph.aggregation.type||null,n.multiGraphAggregationIgnoreOutlier=i.multigraph.aggregation.ignoreOutliers||null,n.multiGraphAggregationMinSourcesRatio=i.multigraph.aggregation.minSourcesRatio||null,n.multiGraphAggregationMinSourcesCount=i.multigraph.aggregation.minSourcesCount||null,n.multiGraphAggregationMaxResultValueRatio=i.multigraph.aggregation.maxResultValueRatio||null,n.multiGraphAggregationMaxResultValue=i.multigraph.aggregation.maxResultValue||null)),n}return i(t,r),t}(lt),pt=function(){function t(t){this.client=t}return t.prototype.create=function(n,r){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("multigraph").key().toString(),i=new ft(this.client,n,r),[4,h(this.client).fetchCachedData(r.useClientCache,e,"POST",i,{Accept:"text/plain"})];case 1:return[2,t.sent()]}})})},t.prototype.info=function(n){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("multigraph/"+n).key().toString(),[4,h(this.client).fetch(e,"GET")];case 1:return(i=t.sent()).boundingBoxNorthEast&&i.boundingBoxSouthWest&&(i.boundingBox={northEast:{lat:i.boundingBoxNorthEast.y,lng:i.boundingBoxNorthEast.x},southWest:{lat:i.boundingBoxSouthWest.y,lng:i.boundingBoxSouthWest.x}},delete i.boundingBoxNorthEast,delete i.boundingBoxSouthWest),[2,i]}})})},t.prototype.redo=function(i){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("multigraph/"+i+"/update").key().toString(),[4,h(this.client).fetch(e,"PATCH")];case 1:return[2,t.sent()]}})})},t}(),dt=function(){function t(t){this.client=t}return t.prototype.fetch=function(n,r,s,o){return g(this,void 0,void 0,function(){var e,i;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.fleetsUrl).version().part("/api/key-auth/optimizations").key().toString(),i=this._createPayload(this.client,n,r,s,o),[4,h(this.client).fetch(e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype._createPayload=function(t,e,i,n,r){return{optimizationTime:r.optimizationTime,optimizationAlgorithm:r.optimizationAlgorithm,optimizationMetadata:{costMatrixSource:r.costMatrixSource,geojsonCreation:r.geojsonCreation,unimprovedWaitingTime:r.unimprovedWaitingTime,filterOrdersWithMissedDeadline:r.filterOrdersWithMissedDeadline,filterOrdersOutsideOfValidWorkingHours:r.filterOrdersOutsideOfValidWorkingHours,prohibitFilteringOfOrdersWithDeadlinesEarlierEqualsThan:r.prohibitFilteringOfOrdersWithDeadlinesEarlierEqualsThan,secondsToPenaltyRatioForDeadlineMissed:r.secondsToPenaltyRatioForDeadlineMissed,secondsToPenaltyRatioForOutOfWorkingHours:r.secondsToPenaltyRatioForOutOfWorkingHours,timeConstraintPenaltyToTravelCostRatio:r.timeConstraintPenaltyToTravelCostRatio,longestTourPenaltyFactor:r.longestTourPenaltyFactor,nonParallelOrdersByTags:r.nonParallelOrdersByTags,travelOptions:{travelType:r.travelType,serviceKey:t.serviceKey,serviceUrl:t.serviceUrl,travelTimeFactors:r.travelTimeFactors,fallbackServiceUrl:"",edgeWeight:r.edgeWeight,maxEdgeWeight:r.maxEdgeWeight,elevation:r.elevation,rushHour:r.rushHour}},stores:e,transports:n,orders:i}},t}(),gt=function(){function t(t){this.client=t,this.basemapsLookup={Bright:"osm-bright-gl-style",Light:"positron-gl-style","Light No-Labels":"positron-nolabels-gl-style",Dark:"dark-matter-gl-style","Dark No-Labels":"dark-matter-nolabels-gl-style",Gray:"gray-gl-style","Gray No-Labels":"gray-nolabels-gl-style","Light blue":"blueberry-gl-style","Dark blue":"fiord-color-gl-style","Dark blue No-Labels":"fiord-color-nolabels-gl-style",Basic:"klokantech-basic-gl-style",Toner:"toner-gl-style"}}return Object.defineProperty(t.prototype,"basemapNames",{get:function(){return Object.keys(this.basemapsLookup)},enumerable:!0,configurable:!0}),t.prototype.getGLStyleURL=function(t){if(!t||!this.basemapsLookup[t])throw new Error("valid style name required to access Targomo basemap");return new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.basemapsUrl).part(this.basemapsLookup[t]+".json").params({key:this.client.serviceKey}).toString()},t}(),mt=function(t,e){this.esri=t,this.photon=e},vt=function(){function t(t,e,i){if(this.serviceKey=e,!t)throw new TypeError("Region parameter is missing");this.config=new n(i),t.includes("http")||t.includes("localhost")||t.includes("/")?this.serviceUrl=t:this.serviceUrl="https://api.targomo.com/"+t+"/",this.pois=new x(this),this.statistics=new ht(this),this.reachability=new st(this),this.optimizations=new C(this),this.geocoding=new mt(new d,new v(this)),this.polygons=new nt(this),this.routes=new at(this),this.similarity=new ct(this),this.benchmarks=new p(this),this.statefulMultigraph=new pt(this),this.multigraph=new U(this),this.basemaps=new gt(this),this.fleets=new dt(this)}return Object.defineProperty(t.prototype,"endpoint",{get:function(){var t=this.serviceUrl.split("/").filter(function(t){return!!t});return t[t.length-1]},enumerable:!0,configurable:!0}),t.prototype.metadata=function(){return g(this,void 0,void 0,function(){var e;return m(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this).part(this.serviceUrl).version().part("/metadata/network").key().toString(),[4,h().fetch(e)];case 1:return[2,t.sent()]}})})},t}(),yt=Y;u.geometry=yt,u.PointsOfInterestClient=x,u.ClientConfig=n,u.BenchmarksClient=p,u.GeocodeEsriClient=d,u.GeocodePhotonClient=v,u.MultigraphClient=U,u.OptimizationsClient=C,u.PolygonsClient=nt,u.ReachabilityClient=st,u.RoutesClient=at,u.SimilarityClient=ct,u.StatisticsClient=ht,u.GeocodingClients=mt,u.TargomoClient=vt,u.FleetsClient=dt,u.LatLng=P,u.BoundingBox=M,u.TravelSpeedValues=G,u.StatisticValues=W,u.UseCacheRequestOptions=y,u.BaseRequestOptions=b,u.TravelRequestOptions=S,u.Route=X,u.RouteSegment=Z,u.StatisticsResult=$,u.FpResult=Q,u.OptimizationResult=A,u.StatisticsGeometryResult=tt,u.RequestsUtil=o,u.requests=h,u.SimpleLRU=e,u.SimpleCache=t,Object.defineProperty(u,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.tgm={})}(this,function(u){"use strict";!function(t){if(!t.fetch){var e="URLSearchParams"in t,i="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),n="FormData"in t,r="ArrayBuffer"in t;if(r)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=function(t){return t&&DataView.prototype.isPrototypeOf(t)},c=ArrayBuffer.isView||function(t){return t&&-1<s.indexOf(Object.prototype.toString.call(t))};d.prototype.append=function(t,e){t=h(t),e=f(e);var i=this.map[t];this.map[t]=i?i+","+e:e},d.prototype.delete=function(t){delete this.map[h(t)]},d.prototype.get=function(t){return t=h(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(h(t))},d.prototype.set=function(t,e){this.map[h(t)]=f(e)},d.prototype.forEach=function(t,e){for(var i in this.map)this.map.hasOwnProperty(i)&&t.call(e,this.map[i],i,this)},d.prototype.keys=function(){var i=[];return this.forEach(function(t,e){i.push(e)}),p(i)},d.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),p(e)},d.prototype.entries=function(){var i=[];return this.forEach(function(t,e){i.push([e,t])}),p(i)},i&&(d.prototype[Symbol.iterator]=d.prototype.entries);var l=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];S.prototype.clone=function(){return new S(this,{body:this._bodyInit})},b.call(S.prototype),b.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},w.error=function(){var t=new w(null,{status:0,statusText:""});return t.type="error",t};var u=[301,302,303,307,308];w.redirect=function(t,e){if(-1===u.indexOf(e))throw new RangeError("Invalid status code");return new w(null,{status:e,headers:{location:t}})},t.Headers=d,t.Request=S,t.Response=w,t.fetch=function(i,r){return new Promise(function(n,t){var e=new S(i,r),s=new XMLHttpRequest;s.onload=function(){var t,r,e={status:s.status,statusText:s.statusText,headers:(t=s.getAllResponseHeaders()||"",r=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var e=t.split(":"),i=e.shift().trim();if(i){var n=e.join(":").trim();r.append(i,n)}}),r)};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new w(i,e))},s.onerror=function(){t(new TypeError("Network request failed"))},s.ontimeout=function(){t(new TypeError("Network request failed"))},s.open(e.method,e.url,!0),"include"===e.credentials?s.withCredentials=!0:"omit"===e.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),e.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===e._bodyInit?null:e._bodyInit)})},t.fetch.polyfill=!0}function h(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function f(t){return"string"!=typeof t&&(t=String(t)),t}function p(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach(function(t,e){this.append(e,t)},this):Array.isArray(e)?e.forEach(function(t){this.append(t[0],t[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function g(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function m(i){return new Promise(function(t,e){i.onload=function(){t(i.result)},i.onerror=function(){e(i.error)}})}function v(t){var e=new FileReader,i=m(e);return e.readAsArrayBuffer(t),i}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t)if("string"==typeof t)this._bodyText=t;else if(o&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(n&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(r&&o&&a(t))this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!r||!ArrayBuffer.prototype.isPrototypeOf(t)&&!c(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=g(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?g(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t,e,i,n=g(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,i=m(e),e.readAsText(t),i;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),i=new Array(e.length),n=0;n<e.length;n++)i[n]=String.fromCharCode(e[n]);return i.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},n&&(this.formData=function(){return this.text().then(T)}),this.json=function(){return this.text().then(JSON.parse)},this}function S(t,e){var i,n,r=(e=e||{}).body;if(t instanceof S){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=(i=e.method||this.method||"GET",n=i.toUpperCase(),-1<l.indexOf(n)?n:i),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function T(t){var r=new FormData;return t.trim().split("&").forEach(function(t){if(t){var e=t.split("="),i=e.shift().replace(/\+/g," "),n=e.join("=").replace(/\+/g," ");r.append(decodeURIComponent(i),decodeURIComponent(n))}}),r}function w(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=200<=this.status&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:window);var n=function(t){this.serverUrl="https://api.targomo.com/",this.statisticsUrl="https://api.targomo.com/statistics/",this.tilesUrl="https://api.targomo.com/vector-statistics/",this.poiUrl="https://api.targomo.com/pointofinterest/",this.mapTilesUrl="https://maps.targomo.com/",this.photonGeocoderUrl="https://api.targomo.com/geocode/",this.overpassUrl="https://api.targomo.com/overpass/",this.fleetsUrl="https://api.targomo.com/fleetplanner/",this.basemapsUrl="https://maps.targomo.com/styles/",this.version=1,this.debug=!1,Object.assign(this,t)},r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};function i(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var s=function(){return(s=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function h(s,o,a,c){return new(a||(a=Promise))(function(t,e){function i(t){try{r(c.next(t))}catch(t){e(t)}}function n(t){try{r(c.throw(t))}catch(t){e(t)}}function r(e){e.done?t(e.value):new a(function(t){t(e.value)}).then(i,n)}r((c=c.apply(s,o||[])).next())})}function y(i,n){var r,s,o,t,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,s&&(o=2&e[0]?s.return:e[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,e[1])).done)return o;switch(s=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,s=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(o=0<(o=a.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){a.label=e[1];break}if(6===e[0]&&a.label<o[1]){a.label=o[1],o=e;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(e);break}o[2]&&a.ops.pop(),a.trys.pop();continue}e=n.call(i,a)}catch(t){e=[6,t],s=0}finally{r=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var c=function(t,e,i,n){this.value=t,this.key=e,this.previous=i,this.next=n},e=function(){function t(t){void 0===t&&(t=0),this.capacity=t,this.map={},this.size=0}return t.prototype.get=function(o,a){return h(this,void 0,void 0,function(){var e,i,n,r,s;return y(this,function(t){switch(t.label){case 0:if(void 0===(e=this.map[o]))return[3,5];this.oldest==e&&e.next&&(this.oldest=e.next),e.next&&(e.next.previous=e.previous),e.previous&&(e.previous.next=e.next),e.previous=this.newest,e.next=null,this.newest=e,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.value];case 2:return[2,t.sent()];case 3:return t.sent(),this.map[o]=void 0,[2,this.get(o,a)];case 4:return[3,8];case 5:return a?(i=a(),n=this.map[o]=new c(i,o,this.newest,null),[4,i]):[3,7];case 6:return r=t.sent(),this.newest&&(this.newest.next=n),this.newest=n,this.capacity&&(this.size>=this.capacity?(s=this.oldest)&&(this.oldest=s.next,delete this.map[s.key]):this.size++),this.oldest||(this.oldest=this.newest),[2,r];case 7:return[2,void 0];case 8:return[2]}})})},t}(),t=function(){function t(){this.map={}}return t.prototype.get=function(n,r){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e="string"==typeof n?n:JSON.stringify(n),null==this.map[e]?[3,1]:[2,this.map[e]];case 1:return[4,r()];case 2:return i=t.sent(),[2,this.map[e]=i]}})})},t}(),a=new t;function b(t){t instanceof String||"string"==typeof t?console.log(t):console.log(JSON.stringify(t,null,2))}var o=function(){function t(t){this.options=t}return t.prototype.fetch=function(d,g,m,v){return void 0===g&&(g="GET"),void 0===v&&(v={}),h(this,void 0,void 0,function(){var e,i,n,r,s,o,a,c,l,u,h,f,p;return y(this,function(t){switch(t.label){case 0:return"JSONP"!==(e=g)?v.Accept=v.Accept?v.Accept:"application/json":e="GET","POST-RAW"===g&&(e="POST"),"PUT"!==e&&"POST"!==e||(v["Content-Type"]="application/json"),i=new Headers(v),n={method:e,headers:i},"POST-RAW"===g?n.body=m:"GET"!==g&&"JSONP"!==g&&(n.body=JSON.stringify(m)),[4,fetch(d,n)];case 1:return r=t.sent(),(this.options&&this.options.debug||400<=r.status)&&(console.log("[TargomoClient Begin]"),console.log("[Request]",n.method,d),console.log(" [Headers]"),i.forEach(function(t,e){console.log(" "+e+" = "+t)}),n.body&&(console.log(" [Body]"),console.log(n.body)),console.log("[Response]"),console.log(" status = ",r.status),console.log(" statusText = ",r.statusText),console.log(" [Headers]"),r.headers.forEach(function(t,e){console.log(" "+e+" = "+t)})),400<=r.status?(console.log(" [Body]"),"application/json"!==r.headers.get("content-type")?[3,3]:(c=(a=JSON).stringify,[4,r.text()])):[3,6];case 2:return o=c.apply(a,[t.sent(),null,2]),[3,5];case 3:return[4,r.text()];case 4:o=t.sent(),t.label=5;case 5:throw b(s=o),console.log("[TargomoClient End]"),new Error(s);case 6:return l=null,"JSONP"!==g?[3,8]:[4,r.text()];case 7:return u=t.sent(),h=u.indexOf("("),f=u.lastIndexOf(")"),l=-1<h&&-1<f?JSON.parse(u.substring(h+1,f)):JSON.parse(u),[3,9];case 8:l=r.json(),t.label=9;case 9:return this.options&&this.options.debug?(console.log(" [Body]"),p=b,[4,l]):[3,11];case 10:p.apply(void 0,[t.sent()]),console.log("[TargomoClient End]"),t.label=11;case 11:return[2,l]}})})},t.prototype.fetchData=function(i,n,r,s){return void 0===n&&(n="GET"),h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return[4,this.fetch(i,n,r,s)];case 1:return(e=t.sent()).data?[2,e.data]:(console.warn("No data object was transmitted by "+i+" \nReturning raw response"),[2,e])}})})},t.prototype.fetchCached=function(t,e,i,n,r){var s=this;if(void 0===i&&(i="GET"),!1===t)return this.fetch(e,i,n,r);!0!==t&&t||(t=a);var o=JSON.stringify({url:e,method:i,payload:n});return t.get(o,function(){return s.fetch(e,i,n,r)})},t.prototype.fetchCachedData=function(t,e,i,n,r){var s=this;if(void 0===i&&(i="GET"),!1===t)return this.fetchData(e,i,n,r);!0!==t&&t||(t=a);var o=JSON.stringify({url:e,method:i,payload:n});return t.get(o,function(){return s.fetchData(e,i,n,r)})},t}();function f(t,e){return new o({debug:t&&t.config&&t.config.debug})}var l,p,d=function(){function t(t){this.client=t}return t.prototype.fetch=function(r,s,o){return h(this,void 0,void 0,function(){var e,i,n;return y(this,function(t){switch(t.label){case 0:return e={west:o.southWest.lng,south:o.southWest.lat,east:o.northEast.lng,north:o.northEast.lat},i={bounds:e,benchmarks:s.map(function(t){return{source:t.source,minEnd:t.minEnd,minStart:t.minStart,factor:t.factor}})},n=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("benchmarks/scores_cumulative/").version().part("/"+encodeURIComponent(""+r)).key().toString(),[4,f(this.client).fetch(n,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.metadata=function(i){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("benchmarks/meta/").version().part("/"+encodeURIComponent(""+i)).key().toString(),[4,f(this.client).fetch(e)];case 1:return[2,t.sent()]}})})},t}();l=u.UrlUtil||(u.UrlUtil={}),p=function(){function t(t){this.client=t,this.url="",this.firstParamPlaced=!1}return t.prototype.host=function(t){return 0===this.url.length&&"/"!==t[t.length-1]&&(t+="/"),this.part(t)},t.prototype.part=function(t){return this.url+=t,this},t.prototype.version=function(){return null!==this.client.config.version&&void 0!==this.client.config.version?this.part("v"+this.client.config.version):"/"===this.url[this.url.length-1]&&(this.url=this.url.substr(0,this.url.length-1)),this},t.prototype.params=function(t){var i=this;return Object.keys(t).forEach(function(e){t[e]instanceof Array?t[e].forEach(function(t){i.param(e,t)}):i.param(e,t[e])}),this},t.prototype.param=function(t,e){this.firstParamPlaced?this.url+="&"+t+"="+e:(this.firstParamPlaced=!0,this.url+="?"+t+"="+e)},t.prototype.key=function(){return this.params({key:this.client.serviceKey})},t.prototype.toString=function(){return this.url},t}(),l.TargomoUrl=p;var g=function(){function t(){}return t.prototype.geocode=function(r,s,t,o,a){return h(this,void 0,void 0,function(){var e,i,n;return y(this,function(t){switch(t.label){case 0:return e={singleLine:r,f:"json",countryCode:o,maxLocations:5},s&&(e.location=s.lng+","+s.lat),a&&(e.magicKey=a),i=(new u.UrlUtil.TargomoUrl).part("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates").params(e).toString(),[4,f().fetch(i)];case 1:return n=t.sent(),[2,n.candidates.map(function(t){return{lat:t.location.y,lng:t.location.x,description:t.address}})]}})})},t.prototype.suggest=function(n,r,t,s,o){return void 0===o&&(o=5),h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e={text:n,f:"json",countryCode:s,maxSuggestions:o},r&&(e.location=r.lng+","+r.lat),i=(new u.UrlUtil.TargomoUrl).part("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest").params(e).toString(),[4,f().fetch(i)];case 1:return[2,t.sent().suggestions]}})})},t.prototype.reverseGeocode=function(r,t){return h(this,void 0,void 0,function(){var e,i,n;return y(this,function(t){switch(t.label){case 0:return(e={f:"json"}).location=r.lng+","+r.lat,i=(new u.UrlUtil.TargomoUrl).part("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode").params(e).toString(),[4,f().fetch(i)];case 1:return(n=t.sent())&&n.address?[2,{address:n.address.Match_addr,city:n.address.City,countryCode:n.address.CountryCode,location:n.address.Loc_name,region:n.address.Region,subregion:n.address.Subregion,zip:n.address.Postal}]:[2,{}]}})})},t}(),m=function(){function t(t){this.client=t}return t.prototype.geocode=function(r,s,o){return h(this,void 0,void 0,function(){var e,i,n=this;return y(this,function(t){switch(t.label){case 0:return e=(new u.UrlUtil.TargomoUrl).host(this.client.config.photonGeocoderUrl).part("api").params({q:encodeURIComponent(r),limit:5}).toString(),s&&(e+="&lat="+s.lat+"&lon="+s.lng),o&&(e+="&lang="+encodeURIComponent(o)),[4,f().fetch(e)];case 1:return(i=t.sent()).features.forEach(function(t,e,i){"boundary"==t.properties.osm_key&&i.splice(e,1)}),[2,i.features.map(function(t){return t.value=t.properties.osm_id,t.description=n.buildPlaceDescription(t.properties),t})]}})})},t.prototype.buildPlaceDescription=function(i){var n=function(t,e){return void 0===e&&(e=" "),t.filter(function(t){return!!t}).join(e).trim()},t=function(t,e){return n(t.map(function(t){return i[t]}),e)},e=t(["street","housenumber"]," "),r=n([t(["postcode","city"]," "),i.country],", "),s={title:"",meta1:"",meta2:"",full:""};return void 0!==i.name?(s.title=i.name,s.meta1=e,s.meta2=r):(s.title=e,s.meta1=r),i.name!==e&&(s.full=s.title),s.meta1&&i.name!==e&&(s.full+=", "+s.meta1),s.meta1&&i.name===e&&(s.full+=s.meta1),s.full=n([s.full,s.meta2],", "),s},t}(),v=function(){},S=function(){this.edgeWeight="time"},T=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.transitFrameDuration=void 0,t.transitFrameDate=20170801,t.transitFrameTime=39600,t.transitMaxTransfers=5,t.walkSpeed={},t.bikeSpeed={},t}return i(t,e),t}(S),w=function(s){function t(t){var e=s.call(this)||this;if(Object.assign(e,t),null!=t.transitFrameDateTime){var i=void 0,n=(i=t.transitFrameDateTime instanceof Date?t.transitFrameDateTime:new Date(t.transitFrameDateTime))?1e4*i.getFullYear()+100*(i.getMonth()+1)+i.getDate():void 0,r=i?3600*i.getHours()+60*i.getMinutes():void 0;e.transitFrameDate=n||e.transitFrameDate,e.transitFrameTime=r||e.transitFrameTime}return e}return i(t,s),t.prototype.buildTargetsCfg=function(t){return t.map(function(t){return{lat:t.lat,lng:t.lng,id:t.id}})},t.prototype.buildSourcesCfg=function(t){var i=this;return t.map(function(t){var e={lat:t.lat,lng:t.lng,id:t.id,tm:t.tm};if(!e.tm)switch(i.travelType){case"car":e.tm={car:i.rushHour?{rushHour:i.rushHour}:{}};break;case"walk":e.tm={walk:i.walkSpeed};break;case"bike":e.tm={bike:i.bikeSpeed};break;case"transit":e.tm={transit:{frame:{date:i.transitFrameDate,time:i.transitFrameTime,duration:i.transitFrameDuration},maxTransfers:i.transitMaxTransfers}}}return e})},t}(T),U=function(r){function t(t,e,i){var n=r.call(this,e)||this;return n.sources=n.buildSourcesCfg(t),i&&(n.targets=n.buildTargetsCfg(i)),n.multigraph=e.multigraph,n}return i(t,r),t}(w),E=function(){function t(t){this.client=t}return t.prototype.fetch=function(n,r,s){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/multigraph").key().toString(),i=new U(n,r,s),[4,f(this.client).fetch(e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.fetchOverview=function(n,r,s){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/multigraph/overview").key().toString(),i=new U(n,r,s),[4,f(this.client).fetch(e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.getTiledMultigraphUrl=function(r,s,o,a){return h(this,void 0,void 0,function(){var e,i,n;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/objectcache/add").key().toString(),i=new U(r,s,a),[4,f(this.client).fetch(e,"POST",i)];case 1:return n=t.sent(),[2,new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/multigraph/{z}/{x}/{y}."+o).key().params({cfgUuid:n.uuid}).toString()]}})})},t}(),A=function(t,e,i,n){this.description=n.description||"",this.serviceUrl=t,this.serviceKey=e,this.email=n.email||"developers@targomo.com",this.sendMail=!1,this.callbackUrl=n.callbackUrl||"https://localhost/",this.pointsPerSolution=n.pointsPerSolution,this.maxSolutions=n.maxSolutions||1,this.travelType=n.travelType,this.edgeWeight=n.edgeWeight,this.maxEdgeWeight=n.maxEdgeWeight,this.statisticGroupId=n.statisticGroup,n.statistic instanceof Number||"number"==typeof n.statistic?this.statisticId=+n.statistic:this.statisticId=n.statistic.id;var r={};i.forEach(function(t){r[t.id]={id:t.id,x:t.lng,y:t.lat}}),this.sources.push(r)},C=function(t){this.raw=t,this.id=t.id,this.maxPossibleValue=t.maxPossibleValue,this.solutions=t.simulationResults.map(function(t){var e={};return t.sourcePoints.forEach(function(t){e[t.id]=t.optimal}),{id:t.id,startTime:t.startTime,endTime:t.endTime,maxValue:t.maxValue,numberOfDesiredPoints:t.numberOfDesiredPoints,sources:e}})},O=function(){function t(t){this.client=t}return t.prototype.create=function(r,s){return h(this,void 0,void 0,function(){var e,i,n;return y(this,function(t){switch(t.label){case 0:return r.length?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("simulation/start/").key().params({serviceUrl:encodeURIComponent(this.client.serviceUrl)}).toString(),i=new A(this.client.serviceUrl,this.client.serviceKey,r,s),[4,f(this.client).fetch(e,"POST",i)]):[2,null];case 1:return[2,(n=t.sent())&&+n.id]}})})},t.prototype.ready=function(i){return h(this,void 0,void 0,function(){var e;return y(this,function(t){return i instanceof Array||(i=[i]),e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("simulation/ready/").key().params({serviceUrl:encodeURIComponent(this.client.serviceUrl),simulationId:i}).toString(),[2,f(this.client).fetch(e)]})})},t.prototype.fetch=function(n){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("simulation/"+n+"/").key().params({serviceUrl:encodeURIComponent(this.client.serviceUrl)}).toString(),i=C.bind,[4,f(this.client).fetch(e)];case 1:return[2,new(i.apply(C,[void 0,t.sent()]))]}})})},t}(),R=function(r){function t(t,e,i){var n=r.call(this,i)||this;return n.osmTypes=[],n.sources=n.buildSourcesCfg([e]),n.osmTypes=i.osmTypes,n.format=i.format,n.serviceKey=t.serviceKey,n.serviceUrl=t.serviceUrl,n}return i(t,r),t}(w),I=function(){function i(t,e,i,n){this.id=t,this.lng=e,this.lat=i,this.properties=n,this.properties&&(this.properties["marker-size"]=1)}return i.prototype.toString=function(){return this.properties?this.properties.name:""},i.prototype.copy=function(){var t=new i(this.id,this.lat,this.lng,s({},this.properties));for(var e in this)"properties"!=e&&(t[e]=this[e]);return t},i}();function _(t){var e=t.lat,i=t.lon;return void 0===e&&t.center&&(e=t.center.lat,i=t.center.lon),new I(t.id,i,e,t.tags)}var x,P=function(){function t(t){this.client=t}return t.prototype.queryRaw=function(e){return h(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,f(this.client).fetch(this.client.config.overpassUrl+"/api/interpreter","POST-RAW",e)];case 1:return[2,t.sent().elements.filter(function(t){return!!t.tags}).map(function(t){return _(t)})]}})})},t.prototype.query=function(t,i){function n(t){if("*"===t.tag||null==t.tag)return'"'+t.type+'"';if(t.type&&t.tag)return'"'+t.type+'"="'+t.tag+'"';throw new Error("invalid query"+JSON.stringify(t))}var r=[];t.forEach(function(e){i.forEach(function(t){r.push("\n way["+n(e)+"]\n ("+t.southWest.lat+","+t.southWest.lng+","+t.northEast.lat+","+t.northEast.lng+");\n node["+n(e)+"]\n ("+t.southWest.lat+","+t.southWest.lng+","+t.northEast.lat+","+t.northEast.lng+");\n ")})});var e="\n [out:json];\n (\n "+r.join("")+"\n );\n out center;\n ";return this.queryRaw(e)},t.prototype.queryGetCustom=function(e){return h(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,f(this.client).fetch(e)];case 1:return[2,t.sent().elements.map(function(t){return _(t)})]}})})},t.prototype.reachable=function(i,n){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return e=this.client.config.poiUrl+"/reachability",[4,f(this.client).fetch(e,"POST",new R(this.client,i,n))];case 1:return[2,t.sent()]}})})},t}(),M=function(){},N=function(){};(x=u.StatisticsGroups||(u.StatisticsGroups={}))[x.GERMANY_ZENSUS_100M_STATISTICS=9]="GERMANY_ZENSUS_100M_STATISTICS",x[x.GERMANY_ZENSUS_200M_STATISTICS=2]="GERMANY_ZENSUS_200M_STATISTICS",x[x.GERMANY_ZENSUS_500M_STATISTICS=11]="GERMANY_ZENSUS_500M_STATISTICS",x[x.GERMANY_ZENSUS_1000M_STATISTICS=3]="GERMANY_ZENSUS_1000M_STATISTICS",x[x.GERMANY_ZENSUS_2000M_STATISTICS=10]="GERMANY_ZENSUS_2000M_STATISTICS",x[x.NORWAY_STATISTICS=4]="NORWAY_STATISTICS",x[x.CENSUS_BRANDENBURG_POPULATION=12]="CENSUS_BRANDENBURG_POPULATION",x[x.CANADA_BLOCK_STATISTICS=8]="CANADA_BLOCK_STATISTICS",x[x.CANADA_AREA_STATISTICS=5]="CANADA_AREA_STATISTICS",x[x.BERLIN_STATISTICS=6]="BERLIN_STATISTICS";var D,k,G,W=function(){},B=function(t){for(var e in this.values=t,this.total=0,this.values)this.total+=this.values[e]};(D=u.SRID||(u.SRID={}))[D.SRID_3857=3857]="SRID_3857",D[D.SRID_4326=4326]="SRID_4326",(k=u.MultigraphRequestAggregation||(u.MultigraphRequestAggregation={})).NONE="none",k.SUM="sum",k.MAX="max",k.MIN="min",k.MEAN="mean",k.MEDIAN="median",k.NEAREST="nearest",k.UNION="routing_union",(G=u.MultigraphRequestLayer||(u.MultigraphRequestLayer={})).EDGE="edge",G.NODE="node",G.TILE="tile",G.HEXAGON="hexagon",G.TILE_NODE="tile_node",G.HEXAGON_NODE="hexagon_node";var j=new(function(){function t(){this.R=6378137}return t.prototype.project=function(t){var e=Math.PI/180,i=Math.max(Math.min(Math.sin(t.lat*e),1-1e-15),-(1-1e-15));return{x:this.R*t.lng*e,y:this.R*Math.log((1+i)/(1-i))/2}},t.prototype.unproject=function(t){var e=180/Math.PI;return{lat:(2*Math.atan(Math.exp(t.y/this.R))-Math.PI/2)*e,lng:t.x*e/this.R}},t}()),F=6371.01,L=Math.PI/180;function H(t,e){var i=L*t.lat,n=L*t.lng,r=L*e.lat,s=L*e.lng;return Math.acos(Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos(n-s))*F}function z(t,e){e*=1e3;var i=t.lat,n=t.lng,r=i*L,s=e/1e3/110.574235,o=e/1e3/(110.572833*Math.cos(r));return{northEast:{lat:i+s,lng:n+o},southWest:{lat:i-s,lng:n-o}}}function q(t){switch(t.travelType){case"walk":return 10;case"bike":return 25;case"transit":return 150;default:return 120}}function K(t,i,e){return i instanceof Array?V(t,i,e).filter(function(e){return!i.some(function(t){return t==e})}):V(t,i,e).filter(function(t){return i!=t})}function V(t,i,n){return i instanceof Array?t.filter(function(e){return i.some(function(t){return H(e,t)<=n})}):t.filter(function(t){return H(t,i)<=n})}function J(t,e){var i=j.unproject(t);return null!=e?{lat:i.lat,lng:i.lng,elevation:e}:i}var Y,Z=Object.freeze({contains:function(t,e){return e.lat>=t.southWest.lat&&e.lat<=t.northEast.lat&&e.lng>=t.southWest.lng&&e.lng<=t.northEast.lng},calculateDistance:H,boundingBox:z,locationsWithinTravelOptions:function(t,e,i){var n,r=i.maxEdgeWeight;switch(i.travelType){case"walk":n=10;break;case"bike":n=25;break;case"transit":n=150;break;default:n=120}return K(t,e,"distance"===i.edgeWeight?Math.round(r/1e3):n*r/3600)},boundingBoxWithinTravelOptions:function(t,e){var i=e.maxEdgeWeight,n=q(e);return z(t,"distance"===e.edgeWeight?Math.round(i/1e3):n*i/3600)},boundingBoxFromLocationArray:function(t){return t.reduce(function(t,e){return t.northEast.lat=e.lat>t.northEast.lat?e.lat:t.northEast.lat,t.northEast.lng=e.lng>t.northEast.lng?e.lng:t.northEast.lng,t.southWest.lat=e.lat<t.southWest.lat?e.lat:t.southWest.lat,t.southWest.lng=e.lng<t.southWest.lng?e.lng:t.southWest.lng,t},{northEast:{lat:t[0].lat,lng:t[0].lng},southWest:{lat:t[0].lat,lng:t[0].lng}})},boundingBoxListWithinTravelOptions:function(t,e){var i=e.maxEdgeWeight,n=q(e),r="distance"===e.edgeWeight?Math.round(i/1e3):n*i/3600,s={northEast:{lat:-1/0,lng:-1/0},southWest:{lat:1/0,lng:1/0}};return t.forEach(function(t){var e=z(t,r);s.northEast.lat=Math.max(s.northEast.lat,e.northEast.lat),s.northEast.lng=Math.max(s.northEast.lng,e.northEast.lng),s.southWest.lat=Math.min(s.southWest.lat,e.southWest.lat),s.southWest.lng=Math.min(s.southWest.lng,e.southWest.lng)}),s},locationsWithinDistance:K,locationsWithinDistanceInclusive:V,webMercatorToLatLng:J,latLngToWebMercator:function(t){return j.project(t)}}),X=function(t,e){var i=this;this.points=[],this.type=e.type,this.travelTime=e.travelTime,this.distance=e.length/1e3,this.warning=e.warning,this.elevationGain=e.elevationGain,this.transitSegment=!1,this.startName=e.startname,this.endName=e.endname,e.points.forEach(function(t){i.points.push(J({x:t[1],y:t[0]},t[2]))}),e.isTransit&&(this.transitSegment=!0,this.routeType=e.routeType,this.routeShortName=e.routeShortName,this.startName=e.startname,this.endName=e.endname,this.departureTime=e.departureTime,this.arrivalTime=e.arrivalTime,this.tripHeadSign=e.tripHeadSign)},$=function(){function t(i,t,e,n){var r=this;this.travelTime=t,this.routeSegments=[],this.targetHeight=void 0,this.sourceHeight=void 0,this.sourceId=void 0,this.targetId=void 0,this.length=void 0;var s=0,o=[];e.reverse().forEach(function(t){var e=new X(i,t);r.routeSegments.push(e),"TRANSFER"===e.type&&s++,o=o.concat(e.points.reverse())}),this.points=o,this.transfers=s,void 0!==n&&(this.sourceId=n.source_id,this.targetId=n.target_id,this.length=n.length);var a=this.calculateElevationDifferences(this.points);this.targetHeight=a.targetHeight,this.sourceHeight=a.sourceHeight,this.uphillMeter=a.uphillMeter,this.downhillMeter=a.downhillMeter,this.totalElevationDifference=Math.abs(this.sourceHeight-this.targetHeight),this.departureTime=this.calculateDepartureTime(),this.arrivalTime=this.calculateArrivalTime(),this.distance=this.calculateDistance(),this.elevationGain=this.calculateElevationGain()}return t.prototype.calculateDistance=function(){for(var t=0,e=0;e<this.routeSegments.length;e++)t+=this.routeSegments[e].distance;return t},t.prototype.calculateElevationGain=function(){for(var t=void 0,e=0;e<this.routeSegments.length;e++)isFinite(this.routeSegments[e].elevationGain)&&(t=(t||0)+this.routeSegments[e].elevationGain);return t},t.prototype.calculateElevationDifferences=function(t){for(var e=void 0,i=void 0,n=void 0,r=0,s=0,o=this.points.length-1;0<=o;o--)0==o&&(i=this.points[o].elevation),o==this.points.length-1&&(n=this.points[o].elevation),void 0!==e&&(e>this.points[o].elevation?r+=e-this.points[o].elevation:e<this.points[o].elevation&&(s+=this.points[o].elevation-e)),e=this.points[o].elevation;return{targetHeight:i,sourceHeight:n,uphillMeter:r,downhillMeter:s}},t.prototype.calculateDepartureTime=function(){for(var t=0,e=0;e<this.routeSegments.length;e++){var i=this.routeSegments[e];if(null!=i.departureTime)return i.departureTime-t;t+=i.travelTime||0}},t.prototype.calculateArrivalTime=function(){for(var t=0,e=this.routeSegments.length-1;0<=e;e--){var i=this.routeSegments[e];if(null!=i.arrivalTime)return i.arrivalTime-t;t+=i.travelTime||0}},t}(),Q=function(t,s){function e(t){for(var e={},i=0,n=s;i<n.length;i++){var r=n[i];e[r.name]=new B(t[r.id])}return e}var i={};if(t.individualStatistics)for(var n in t.individualStatistics)t.individualStatistics[n]&&t.individualStatistics[n].statistics&&(i[n]=e(t.individualStatistics[n].statistics));this.statistics=e(t.statistics),this.individualStatistics=i,this.raw=t};(Y=u.MultigraphStatus||(u.MultigraphStatus={})).CREATED="CREATED",Y.ROUTING="ROUTING",Y.MERGING="MERGING",Y.AGGREGATING="AGGREGATING",Y.COMPLETED="COMPLETED",Y.FAILED="FAILED";var tt=function(){},et=function(t,e){this.values={};var i={};e.forEach(function(t){i[t.id]=t.name}),this.raw=t;var n=this.values;for(var r in t){var s=t[r],o=(s.aggregation||"").toLowerCase();n[o]=n[o]||{};var a=i[s.statisticId];n[o][a]={value:s.value}}},it=function(){this.minPolygonHoleSize=1e7,this.buffer=50,this.simplify=50,this.srid=u.SRID.SRID_4326,this.quadrantSegments=2,this.intersectionMode="union",this.decimalPrecision=6},nt=function(r){function t(t,e,i){var n=r.call(this,i)||this;return n.polygon=new it,n.sources=n.buildSourcesCfg(e),n.polygon.values=i.travelEdgeWeights,n.polygon.serializer=i.serializer,n.polygon.simplify=i.simplify,n.polygon.srid=i.srid,n.polygon.buffer=i.buffer,n.polygon.minPolygonHoleSize=i.minPolygonHoleSize,n.polygon.quadrantSegments=i.quadrantSegments,n.polygon.intersectionMode=i.intersectionMode,n.polygon.decimalPrecision=i.decimalPrecision,n}return i(t,r),t}(w),rt=function(){function t(t){this.client=t}return t.prototype.fetch=function(n,r){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new nt(this.client,n,r),[4,this._executeFetch(n,r,e)];case 1:return i=t.sent(),"json"===r.serializer?[2,i]:"geojson"===r.serializer?[2,i]:[2]}})})},t.prototype._executeFetch=function(t,n,r){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/polygon").key().toString(),[4,f(this.client).fetchCachedData(n.useClientCache,e,"POST",r)];case 1:return(i=t.sent()).metadata=n,[2,i]}})})},t}(),st=function(s){function t(t,e,i,n){var r=s.call(this,n)||this;return r.sources=r.buildSourcesCfg(e),r.targets=r.buildTargetsCfg(i),r}return i(t,s),t}(w),ot=function(){function t(t){this.client=t}return t.prototype.individual=function(n,r,s){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/time").key().toString(),i=new st(this.client,n,r,s),[4,f(this.client).fetchCachedData(s.useClientCache,e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.combined=function(n,r,s){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/reachability").key().toString(),i=new st(this.client,n,r,s),[4,f(this.client).fetchCachedData(s.useClientCache,e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype.count=function(e,i,n){return h(this,void 0,void 0,function(){return y(this,function(t){switch(t.label){case 0:return[4,this.locations(e,i,n)];case 1:return[2,t.sent().length]}})})},t.prototype.locations=function(e,n,r){return h(this,void 0,void 0,function(){var i;return y(this,function(t){switch(t.label){case 0:return i={},n.forEach(function(t){return i[String(t.id)]=-1}),[4,this.combined(e,n,r)];case 1:return t.sent().forEach(function(t){var e=String(t.id);i[e]?-1<t.travelTime&&(-1<i[e]?i[e]=Math.min(i[e],t.travelTime):i[e]=t.travelTime):console.warn("NOT FOUND",String(t.id))}),[2,n.filter(function(t){var e=String(t.id);return t.travelTime=i[e],-1<i[e]})]}})})},t}(),at=function(s){function t(t,e,i,n){var r=s.call(this,n)||this;return r.sources=r.buildSourcesCfg(e),r.targets=r.buildTargetsCfg(i),r.pathSerializer=n.pathSerializer,"boolean"==typeof n.recommendations&&(n.recommendations=n.recommendations?1:0),Number.isInteger(n.recommendations)&&r.sources&&r.sources.forEach(function(t){if(null!=t.tm)for(var e in t.tm)t.tm[e].recommendations=n.recommendations}),r}return i(t,s),t}(w),ct=function(){function t(t){this.client=t}return t.prototype.fetch=function(s,o,a){return h(this,void 0,void 0,function(){var e,i,n,r=this;return y(this,function(t){switch(t.label){case 0:return e=new at(this.client,s,o,a),i=new u.UrlUtil.TargomoUrl(this.client).part(this.client.serviceUrl).version().part("/route").key().params({cfg:encodeURIComponent(JSON.stringify(e))}).toString(),[4,f(this.client).fetchCachedData(a.useClientCache,i,"GET",void 0,{Accept:"application/json,application/javascript,*/*"})];case 1:return(n=t.sent()).routes?[2,n.routes.map(function(t){return new $(r.client,t.travelTime,t.segments,t)})]:[2,null]}})})},t}(),lt=function(){function t(t){this.client=t}return t.prototype.metadata=function(i){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("similarity/meta/").version().part("/"+encodeURIComponent(""+i)).key().toString(),[4,f(this.client).fetch(e)];case 1:return[2,t.sent()]}})})},t.prototype.fetch=function(s,o,a,c,l){return h(this,void 0,void 0,function(){var e,i,n,r;return y(this,function(t){switch(t.label){case 0:return e={west:c.southWest.lng,south:c.southWest.lat,east:c.northEast.lng,north:c.northEast.lat},i={bounds:e,refCellId:o,scores:a.map(function(t){return{source:t.source,minutes:t.minutes,factor:t.factor||1}})},n=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("similarity/scores_cumulative/").version().part("/"+encodeURIComponent(""+s)).key(),r=l?n.params({normalizeOnViewport:!!l}).toString():n.toString(),[4,f(this.client).fetch(r,"POST",i)];case 1:return[2,t.sent()]}})})},t}();var ut=function(t,e,i){this.inactiveSources=[],this.getClosestSources=!1,this.serviceUrl=t.serviceUrl,this.serviceKey=t.serviceKey,this.useCache=null==i.useCache||i.useCache,this.sources=e.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}),this.iFeelLucky=i.iFeelLucky,this.travelType=i.travelType,this.edgeWeight=i.edgeWeight,this.maxEdgeWeight=i.maxEdgeWeight,i.inactiveSources&&(this.inactiveSources=i.inactiveSources.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}));var n=[];i.statistics&&(this.omitIndividualStatistics=i.omitIndividualStatistics,n=i.statistics.map(function(t){return t instanceof Number||"number"==typeof t?+t:t.id})),this.statisticGroupId=+i.statisticsGroup,this.statisticIds=n,i.closestSources&&(this.getClosestSources=!0)},ht=function(t,e,i){var n=i.statistics.map(function(t){return t instanceof Number||"number"==typeof t?+t:t.id});this.statisticGroupId=+i.statisticsGroup,this.statisticIds=n,this.intersectionGeometry={data:e,crs:i.crs||4326}},ft=function(){function t(t){this.client=t,this.statisticsMetadataCache=new e(200),this.statisticsEnsemblesCache=new e(200)}return t.prototype.combined=function(i,n){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return[4,this.dependent(i,n)];case 1:return[2,(e=t.sent())&&e.statistics]}})})},t.prototype.individual=function(i,n){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return[4,this.dependent(i,n)];case 1:return[2,(e=t.sent())&&e.individualStatistics]}})})},t.prototype.travelTimes=function(i,n){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return i.length?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("traveltimes").params({serviceUrl:this.client.serviceUrl}).toString(),[4,f(this.client).fetch(e,"POST",new ut(this.client,i,n))]):[2,null];case 1:return[2,t.sent()]}})})},t.prototype.dependent=function(n,r){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return n.length?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("charts/dependent").params({serviceUrl:this.client.serviceUrl}).toString(),[4,f(this.client).fetch(e,"POST",new ut(this.client,n,r))]):[2,null];case 1:return i=t.sent(),[2,new Q(i,r.statistics)]}})})},t.prototype.geometry=function(n,r){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return n?(e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("values/geometry").params({serviceUrl:this.client.serviceUrl}).toString(),[4,f(this.client).fetch(e,"POST",new ht(this.client,n,r))]):[2,null];case 1:return i=t.sent(),[2,new et(i,r.statistics)]}})})},t.prototype.metadata=function(s){return h(this,void 0,void 0,function(){var e,n,i,r=this;return y(this,function(t){switch(t.label){case 0:return e=this.client.config.tilesUrl,n="number"==typeof s?s:s.id,i=e+"-"+n,[4,this.statisticsMetadataCache.get(i,function(){return h(r,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("statistics/meta/").version().part("/"+n).key().toString(),[4,f(this.client).fetch(e)];case 1:return!(i=t.sent()).name&&i.names&&i.names.en&&(i.name=i.names.en),i.stats&&i.stats.length&&i.stats.forEach(function(t){!t.name&&t.names&&t.names.en&&(t.name=t.names.en)}),[2,i]}})})})];case 1:return[2,t.sent()]}})})},t.prototype.metadataKey=function(s,o){return h(this,void 0,void 0,function(){var e,i,n,r;return y(this,function(t){switch(t.label){case 0:return[4,this.metadata(s)];case 1:for(e=t.sent(),i=0,n=e.stats;i<n.length;i++)if(r=n[i],o.id==r.statistic_id||r.names&&r.names.en==o.name)return[2,r];return[2,null]}})})},t.prototype.tileRoute=function(t,e){var i="number"==typeof t?t:t.id,n=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("statistics/tiles/").version().part("/"+i+"/{z}/{x}/{y}.mvt").key();return e&&0<e.length?n.params({columns:encodeURIComponent(e.map(function(t){return+t.id}).join(","))}).toString():n.toString()},t.prototype.ensembles=function(){return h(this,void 0,void 0,function(){var e,i=this;return y(this,function(t){switch(t.label){case 0:return e=this.client.config.tilesUrl,[4,this.statisticsEnsemblesCache.get(e,function(){return h(i,void 0,void 0,function(){var e,i,n,r;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.tilesUrl).part("ensemble/list/").version().key().toString(),[4,f(this.client).fetch(e,"GET")];case 1:for(n in i=t.sent())i[n]&&((r=i[n]).id=+r.id,r.groups&&r.groups.length&&r.groups.forEach(function(t){t.hierarchy=+t.hierarchy,t.id=+t.id}));return[2,i]}})})})];case 1:return[2,t.sent()]}})})},t}(),pt=function(r){function t(t,e,i){var n=r.call(this,t,e,i)||this;return delete n.inactiveSources,delete n.statisticGroupId,delete n.statisticIds,delete n.getClosestSources,delete n.useCache,i&&(n.multiGraphSerializationType=i.multigraph.serialization.format,n.multiGraphSerializationDecimalPrecision=i.multigraph.serialization.decimalPrecision,i.multigraph.aggregation&&(n.multiGraphAggregationType=i.multigraph.aggregation.type||null,n.multiGraphAggregationIgnoreOutlier=i.multigraph.aggregation.ignoreOutliers||null,n.multiGraphAggregationMinSourcesRatio=i.multigraph.aggregation.minSourcesRatio||null,n.multiGraphAggregationMinSourcesCount=i.multigraph.aggregation.minSourcesCount||null,n.multiGraphAggregationMaxResultValueRatio=i.multigraph.aggregation.maxResultValueRatio||null,n.multiGraphAggregationMaxResultValue=i.multigraph.aggregation.maxResultValue||null)),n}return i(t,r),t}(ut),dt=function(){function t(t){this.client=t}return t.prototype.create=function(n,r){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("multigraph").key().toString(),i=new pt(this.client,n,r),[4,f(this.client).fetchCachedData(r.useClientCache,e,"POST",i,{Accept:"text/plain"})];case 1:return[2,t.sent()]}})})},t.prototype.info=function(n){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("multigraph/"+n).key().toString(),[4,f(this.client).fetch(e,"GET")];case 1:return(i=t.sent()).boundingBoxNorthEast&&i.boundingBoxSouthWest&&(i.boundingBox={northEast:{lat:i.boundingBoxNorthEast.y,lng:i.boundingBoxNorthEast.x},southWest:{lat:i.boundingBoxSouthWest.y,lng:i.boundingBoxSouthWest.x}},delete i.boundingBoxNorthEast,delete i.boundingBoxSouthWest),[2,i]}})})},t.prototype.redo=function(i){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.statisticsUrl).part("multigraph/"+i+"/update").key().toString(),[4,f(this.client).fetch(e,"PATCH")];case 1:return[2,t.sent()]}})})},t}(),gt=function(){function t(t){this.client=t}return t.prototype.fetch=function(n,r,s,o){return h(this,void 0,void 0,function(){var e,i;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.fleetsUrl).version().part("/api/key-auth/optimizations").key().toString(),i=this._createPayload(this.client,n,r,s,o),[4,f(this.client).fetch(e,"POST",i)];case 1:return[2,t.sent()]}})})},t.prototype._createPayload=function(t,e,i,n,r){return{optimizationTime:r.optimizationTime,optimizationAlgorithm:r.optimizationAlgorithm,optimizationMetadata:{costMatrixSource:r.costMatrixSource,geojsonCreation:r.geojsonCreation,unimprovedWaitingTime:r.unimprovedWaitingTime,filterOrdersWithMissedDeadline:r.filterOrdersWithMissedDeadline,filterOrdersOutsideOfValidWorkingHours:r.filterOrdersOutsideOfValidWorkingHours,prohibitFilteringOfOrdersWithDeadlinesEarlierEqualsThan:r.prohibitFilteringOfOrdersWithDeadlinesEarlierEqualsThan,secondsToPenaltyRatioForDeadlineMissed:r.secondsToPenaltyRatioForDeadlineMissed,secondsToPenaltyRatioForOutOfWorkingHours:r.secondsToPenaltyRatioForOutOfWorkingHours,timeConstraintPenaltyToTravelCostRatio:r.timeConstraintPenaltyToTravelCostRatio,longestTourPenaltyFactor:r.longestTourPenaltyFactor,nonParallelOrdersByTags:r.nonParallelOrdersByTags,travelOptions:{travelType:r.travelType,serviceKey:t.serviceKey,serviceUrl:t.serviceUrl,travelTimeFactors:r.travelTimeFactors,fallbackServiceUrl:"",edgeWeight:r.edgeWeight,maxEdgeWeight:r.maxEdgeWeight,elevation:r.elevation,rushHour:r.rushHour}},stores:e,transports:n,orders:i}},t}(),mt=function(){function t(t){this.client=t,this.basemapsLookup={Bright:"osm-bright-gl-style",Light:"positron-gl-style","Light No-Labels":"positron-nolabels-gl-style",Dark:"dark-matter-gl-style","Dark No-Labels":"dark-matter-nolabels-gl-style",Gray:"gray-gl-style","Gray No-Labels":"gray-nolabels-gl-style","Light blue":"blueberry-gl-style","Dark blue":"fiord-color-gl-style","Dark blue No-Labels":"fiord-color-nolabels-gl-style",Basic:"klokantech-basic-gl-style",Toner:"toner-gl-style"}}return Object.defineProperty(t.prototype,"basemapNames",{get:function(){return Object.keys(this.basemapsLookup)},enumerable:!0,configurable:!0}),t.prototype.getGLStyleURL=function(t){if(!t||!this.basemapsLookup[t])throw new Error("valid style name required to access Targomo basemap");return new u.UrlUtil.TargomoUrl(this.client).host(this.client.config.basemapsUrl).part(this.basemapsLookup[t]+".json").params({key:this.client.serviceKey}).toString()},t}(),vt=function(t,e){this.esri=t,this.photon=e},yt=function(){function t(t,e,i){if(this.serviceKey=e,!t)throw new TypeError("Region parameter is missing");this.config=new n(i),t.includes("http")||t.includes("localhost")||t.includes("/")?this.serviceUrl=t:this.serviceUrl="https://api.targomo.com/"+t+"/",this.pois=new P(this),this.statistics=new ft(this),this.reachability=new ot(this),this.optimizations=new O(this),this.geocoding=new vt(new g,new m(this)),this.polygons=new rt(this),this.routes=new ct(this),this.similarity=new lt(this),this.benchmarks=new d(this),this.statefulMultigraph=new dt(this),this.multigraph=new E(this),this.basemaps=new mt(this),this.fleets=new gt(this)}return Object.defineProperty(t.prototype,"endpoint",{get:function(){var t=this.serviceUrl.split("/").filter(function(t){return!!t});return t[t.length-1]},enumerable:!0,configurable:!0}),t.prototype.metadata=function(){return h(this,void 0,void 0,function(){var e;return y(this,function(t){switch(t.label){case 0:return e=new u.UrlUtil.TargomoUrl(this).part(this.serviceUrl).version().part("/metadata/network").key().toString(),[4,f(this).fetch(e)];case 1:return[2,t.sent()]}})})},t}(),bt=Z;u.geometry=bt,u.PointsOfInterestClient=P,u.ClientConfig=n,u.BenchmarksClient=d,u.GeocodeEsriClient=g,u.GeocodePhotonClient=m,u.MultigraphClient=E,u.OptimizationsClient=O,u.PolygonsClient=rt,u.ReachabilityClient=ot,u.RoutesClient=ct,u.SimilarityClient=lt,u.StatisticsClient=ft,u.GeocodingClients=vt,u.TargomoClient=yt,u.FleetsClient=gt,u.LatLng=M,u.BoundingBox=N,u.TravelSpeedValues=W,u.StatisticValues=B,u.UseCacheRequestOptions=v,u.BaseRequestOptions=S,u.TravelRequestOptions=T,u.Route=$,u.RouteSegment=X,u.StatisticsResult=Q,u.FpResult=tt,u.OptimizationResult=C,u.StatisticsGeometryResult=et,u.RequestsUtil=o,u.requests=f,u.SimpleLRU=e,u.SimpleCache=t,Object.defineProperty(u,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=targomo-core.umd.min.js.map |
@@ -30,2 +30,3 @@ import { TargomoClient } from './targomoClient'; | ||
* @Example | ||
* ``` js | ||
* const basemaps = targomoClient.basemaps; | ||
@@ -36,7 +37,8 @@ * const basemapNames = basemaps.basemapNames; | ||
* yourMapboxMap.setStyle(styleUrl); | ||
* ``` | ||
* @Return Url for mapbox-gl style. | ||
* @Param basemapName | ||
* #General A string of valid basemap name (which you can get from the basemapNames accessor) | ||
* A string of valid basemap name (which you can get from the basemapNames accessor) | ||
*/ | ||
getGLStyleURL(basemapName: string): string; | ||
} |
@@ -17,2 +17,3 @@ export interface ClientOptions { | ||
}[]; | ||
debug?: boolean; | ||
} | ||
@@ -31,3 +32,4 @@ export declare class ClientConfig implements ClientOptions { | ||
version: number; | ||
debug: boolean; | ||
constructor(options: ClientOptions); | ||
} |
@@ -37,3 +37,4 @@ import { FpResult } from './../types/responses/FleetResult'; | ||
* @Example | ||
* ```const stores = [{ uuid: '1', address: { lat: 52.474257, lng: 13.378094 } }]; | ||
* ``` js | ||
* const stores = [{ uuid: '1', address: { lat: 52.474257, lng: 13.378094 } }]; | ||
* const orders = [{ storeUuid: '1', address: { lat: 52.4, lng: 13.4 } }, | ||
@@ -50,8 +51,9 @@ * { storeUuid: '1', address: { lat: 52.6, lng: 13.6 } }, | ||
* @Param stores | ||
* #General The stores, or otherwise called 'depots' from which their respective vehicles start their routes. | ||
* The stores, or otherwise called 'depots' from which their respective vehicles start their routes. | ||
* A store has a relation with zero or more orders, and zero or more vehicles. | ||
* @Param orders | ||
* #General The orders that need to be serviced by a vehicle from the store which is concerns this order. | ||
* The orders that need to be serviced by a vehicle from the store which is concerns this order. | ||
* An order has a relation with one store. | ||
* #Performance The amount of orders has a significant on the time it takes to optimize the routes. | ||
* ##### Performance | ||
* The amount of orders has a significant on the time it takes to optimize the routes. | ||
* When using the default settings for optimizationTime and unimprovedWaitingTime in combination with more than 100 orders, | ||
@@ -62,5 +64,6 @@ * you can expect the results to be less optimized. | ||
* @Param transports | ||
* #General The transports (vehicles). Each of which are assigned to a certain store. | ||
* The transports (vehicles). Each of which are assigned to a certain store. | ||
* @Param options | ||
* #Performance Various different options within this options object can have a significant noticable impact on the request duration. | ||
* ##### Performance | ||
* Various different options within this options object can have a significant noticable impact on the request duration. | ||
*/ | ||
@@ -67,0 +70,0 @@ fetch(stores: FpStore[], orders: FpOrder[], transports: FpTransport[], options: FpRequestOptions): Promise<FpResult>; |
@@ -16,5 +16,5 @@ import { BaseRequestOptions } from '../requestOptions'; | ||
* e.g. routing, parsing, serializing of the request response, take longer. | ||
* @Min 1 (Not exclusive) | ||
* @Min `1` (Not exclusive) | ||
* @Max Varies depending on your API plan | ||
* @Default 1 | ||
* @Default `1` | ||
*/ | ||
@@ -44,3 +44,3 @@ optimizationTime?: number; | ||
* individual addresses. Using this source is a lot more accurate than using "AIR_DISTANCE" | ||
* @Default TRAVEL_COST_SERVICE | ||
* @Default `TRAVEL_COST_SERVICE` | ||
*/ | ||
@@ -55,3 +55,3 @@ costMatrixSource?: 'AIR_DISTANCE' | 'TRAVEL_COST_SERVICE'; | ||
* arrival, etc. into the Tour and TourItems that have not yet been set during the optimization. | ||
* @Default STRAIGHT_LINE | ||
* @Default `STRAIGHT_LINE` | ||
*/ | ||
@@ -76,3 +76,3 @@ geojsonCreation?: 'NONE' | 'STRAIGHT_LINE' | 'ROUTING_SERVICE'; | ||
* @Performance Enabling this option can lead to orders never being part of a tour if the deadline has already been passed. | ||
* @Default false, i.e. no orders are removed due to a missed deadline. | ||
* @Default `false`, i.e. no orders are removed due to a missed deadline. | ||
*/ | ||
@@ -90,3 +90,3 @@ filterOrdersWithMissedDeadline?: boolean; | ||
* transports is set too early. | ||
* @Default false, i.e. no orders are removed due to not fitting into the working hours of the transports. | ||
* @Default `false`, i.e. no orders are removed due to not fitting into the working hours of the transports. | ||
*/ | ||
@@ -99,3 +99,4 @@ filterOrdersOutsideOfValidWorkingHours?: boolean; | ||
* @Format Time in seconds. | ||
* @Example secondsToPenaltyRatioForDeadlineMissed = 60: | ||
* @Example | ||
* `secondsToPenaltyRatioForDeadlineMissed = 60;` | ||
* (1) Every order with no missed deadline will not cause a penalty; | ||
@@ -105,3 +106,3 @@ * (2) a deadline that was missed by one second constitutes one penalty point; | ||
* @Min Greater than 0. | ||
* @Default If secondsToPenaltyRatioForDeadlineMissed set to 'null' (which is also the default value if nothing was specified), | ||
* @Default If secondsToPenaltyRatioForDeadlineMissed set to `null` (which is also the default value if nothing was specified), | ||
* that means that every missed deadline counts for exactly one penalty point regardless of the time passed between the deadline and | ||
@@ -115,3 +116,4 @@ * the expected delivery. | ||
* @Format Time in seconds. | ||
* @Example secondsToPenaltyRatioForOutOfWorkingHours = 600: | ||
* @Example | ||
* `secondsToPenaltyRatioForOutOfWorkingHours = 600;` | ||
* (1) Every planned tour that stays within the working hours of a transport (i.e. tour is finished before latestArrivalTime) | ||
@@ -121,3 +123,3 @@ * will not cause a penalty; | ||
* (3) If a tour has missed the latestArrivalTime by 31 minutes that causes 4 penalty points. | ||
* @Default If secondsToPenaltyRatioForOutOfWorkingHours set to 'null' (which is also the default value if nothing was specified), | ||
* @Default If secondsToPenaltyRatioForOutOfWorkingHours set to `null` (which is also the default value if nothing was specified), | ||
* that means that every tour that exceeds its working hours counts for exactly one penalty point regardless of the time passed between | ||
@@ -145,3 +147,3 @@ * the lastArrivalTime and the planned tour end. | ||
* @Min A sensible value should have at least three digits. | ||
* @Default null | ||
* @Default `null` | ||
*/ | ||
@@ -154,3 +156,3 @@ timeConstraintPenaltyToTravelCostRatio?: number; | ||
* progress. | ||
* @Default 0 | ||
* @Default `0` | ||
*/ | ||
@@ -165,3 +167,3 @@ longestTourPenaltyFactor?: number; | ||
* present and he cannot be at two places at the same time. | ||
* @Default [] | ||
* @Default `[]` | ||
*/ | ||
@@ -172,5 +174,5 @@ nonParallelOrdersByTags?: string[]; | ||
* all plans are allowed to enable it. | ||
* @Default false | ||
* @Default `false` | ||
*/ | ||
rushHour?: boolean; | ||
} |
@@ -10,3 +10,3 @@ import { TravelSpeedValues, TravelType, TravelTimeFactors } from './types'; | ||
* @Format time (distance in seconds) or distance (distance in meters) | ||
* @Default 'time' | ||
* @Default `'time'` | ||
*/ | ||
@@ -17,3 +17,3 @@ edgeWeight?: 'time' | 'distance'; | ||
* @General Whether or not the an elevetion heuristic will be used (e.g. downhill with bike quicker then uphill). | ||
* @Default false | ||
* @Default `false` | ||
*/ | ||
@@ -26,5 +26,8 @@ elevation?: boolean; | ||
* Transit travel times are not affected by the travelTimeFactors | ||
* @Example "travelTimeFactors" : { "all":0.5, "motorway":1.5, .... (other specific edge classes possible) },.. | ||
* @Min Minimum allowed cumulative travel time factor is 0.5; | ||
* @Max Maximum allowed cumulative travel time factor is 100.0 | ||
* @Example | ||
* ``` js | ||
* "travelTimeFactors" : { "all":0.5, "motorway":1.5, .... (other specific edge classes possible) },.. | ||
* ``` | ||
* @Min Minimum allowed cumulative travel time factor is `0.5` | ||
* @Max Maximum allowed cumulative travel time factor is `100.0` | ||
* @Format | ||
@@ -60,3 +63,3 @@ * Travel time factor of 1.5 means 50% more time is needed | ||
* all plans are allowed to enable it. | ||
* @Default false | ||
* @Default `false` | ||
*/ | ||
@@ -63,0 +66,0 @@ rushHour?: boolean; |
@@ -116,2 +116,3 @@ import { FpVehicle, FpStore, FpAddress, FpOrder, FpTransport } from './../types'; | ||
* @Example | ||
* ``` js | ||
* loadSum = { | ||
@@ -121,2 +122,3 @@ * weight: 123.1, | ||
* } | ||
* ``` | ||
*/ | ||
@@ -123,0 +125,0 @@ loadSum?: { |
@@ -451,3 +451,5 @@ /** | ||
* However, for the optimization only the fields lat, lng, and avgHandlingTime are of relevance. | ||
* @Example address = { | ||
* @Example | ||
* ``` js | ||
* address = { | ||
* lat: 13.380707532171671, | ||
@@ -457,2 +459,3 @@ * lng: 52.532420302239096, | ||
* } | ||
* ``` | ||
* @Performance It is sufficient to specify an order’s address without geo-coordinates. | ||
@@ -477,3 +480,5 @@ * The missing information is derived from the address details via geocoding. | ||
* or upper boundaries only breaks in which the order cannot be serviced. | ||
* @Example visitingTimes = [{ | ||
* @Example | ||
* ``` js | ||
* visitingTimes = [{ | ||
* end: "2012-04-23T18:00:00.000Z" | ||
@@ -483,2 +488,3 @@ * },{ | ||
* }] | ||
* ``` | ||
* means that the order cannot be serviced between 23.04.2012, 6pm and 24.04.2012, 8am but at any other time before or after. | ||
@@ -488,3 +494,3 @@ * | ||
* start or end of a single visiting time interval, e.g. | ||
* visitingTimes = [{ end: "2012-04-23T18:00:00.000Z" }] | ||
* `visitingTimes = [{ end: "2012-04-23T18:00:00.000Z" }]` | ||
* means that the order must have been serviced/visited before the specified time (including the handling time at the address). | ||
@@ -514,2 +520,3 @@ * @Alternative If only an upper boundary for the visit is important the user can also simply choose to define this via the deadline | ||
* @Example | ||
* ``` js | ||
* load = { | ||
@@ -520,2 +527,3 @@ * bottles: 12 | ||
* } | ||
* ``` | ||
* @Min Greater than or equal to 0 | ||
@@ -528,3 +536,3 @@ * It is not allowed to have a single Order whose single load is smaller than the smallest minSingle of all of the load's | ||
* In addition, the total loads of all Orders of a Store must not exceed the total of all of the load's maxSum of its associated Vehicles. | ||
* @Default If no value was defined for a load for which a load restriction exists that load is assumed to be 0.0. | ||
* @Default If no value was defined for a load for which a load restriction exists, then that load is assumed to be 0.0. | ||
* If no restrictions for a load in any of the vehicles of the associated store exist the value is ignored (i.e. removed from the list). | ||
@@ -565,3 +573,3 @@ * @Format The physical units of the load values, e.g. for weight and volume, must match the units of the associated loadRestrictions | ||
* @Example | ||
* demands = ["dangerous_goods", "region_germany"] | ||
* `demands = ["dangerous_goods", "region_germany"]` | ||
* Means that this order needs to be serviced by a transport that has at least "dangerous_goods" and "region_germany" in its list of | ||
@@ -608,2 +616,3 @@ * supplies. | ||
* @Example | ||
* ``` js | ||
* loadRestrictions = { | ||
@@ -614,2 +623,3 @@ * weight: { maxSum": 100 }, | ||
* } | ||
* ``` | ||
*/ | ||
@@ -638,3 +648,3 @@ loadRestrictions?: { | ||
* service this order. | ||
* @Example supplies = ["dangerous_goods", "normal_goods", "region_germany", "region_benelux"] | ||
* @Example `supplies = ["dangerous_goods", "normal_goods", "region_germany", "region_benelux"]` | ||
* Means that this vehicle can service any order that demands "normal_goods", "dangerous_goods", "region_germany", or | ||
@@ -664,2 +674,3 @@ * "region_benelux" or any combination of that, e.g. its tour can include an order with dangerous goods in Germany. | ||
* working hours. In the example below the vehicle has a valid working hour from 8 to 18 with a 2 hour break from 12 to 14: | ||
* ``` js | ||
* metadata = { | ||
@@ -673,2 +684,3 @@ * earliestDepartureTime: "2012-04-23T08:00:00.000Z", | ||
* } | ||
* ``` | ||
*/ | ||
@@ -721,5 +733,5 @@ export interface FpTransportMetadata { | ||
* Transit travel times are not affected by the travelTimeFactors | ||
* @Example "travelTimeFactors" : { "all":0.5, "motorway":1.5, .... (other specific edge classes possible) },.. | ||
* @Min Minimum allowed cumulative travel time factor is 0.5; | ||
* @Max Maximum allowed cumulative travel time factor is 100.0 | ||
* @Example `"travelTimeFactors" : { "all":0.5, "motorway":1.5, .... (other specific edge classes possible) },..` | ||
* @Min Minimum allowed cumulative travel time factor is `0.5` | ||
* @Max Maximum allowed cumulative travel time factor is `100.0` | ||
* @Format | ||
@@ -726,0 +738,0 @@ * Travel time factor of 1.5 means 50% more time is needed |
import { Cache } from '../util/cache'; | ||
import { TargomoClient } from '../api/index'; | ||
export declare class RequestsUtil { | ||
constructor(); | ||
private options?; | ||
constructor(options?: { | ||
debug?: boolean; | ||
timeout?: number; | ||
}); | ||
fetch(url: string, method?: string, payload?: any, headers?: { | ||
@@ -6,0 +10,0 @@ [index: string]: string; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1076187
9087