@targomo/core
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -5,3 +5,3 @@ { | ||
"author": "Targomo", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "repository": "github:targomo/targomo-js", |
@@ -61,2 +61,2 @@ # targomo-js | ||
Documentation is available at [https://targomo.com/developers/guide/](https://targomo.com/developers/guide/) | ||
Documentation is available at [https://targomo.com/developers/guide/](https://targomo.com/developers/guide/), although this still contains the documentation for the r360-js lib, until the docs are finished for this lib. |
/** | ||
* @targomo/core "0.1.5" http://targomo.com | ||
* @targomo/core "0.1.6" http://targomo.com | ||
* The JavaScript (& TypeScript) API for Targomo's time-based access mapping services. | ||
* (c) 2018 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(t){"use strict";function e(t,e){function n(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function n(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}u((i=i.apply(t,e||[])).next())})}function i(t,e){function n(n){return function(s){return function(n){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,r&&(o=r[2&n[0]?"return":n[0]?"throw":"next"])&&!(o=o.call(r,n[1])).done)return o;switch(r=0,o&&(n=[0,o.value]),n[0]){case 0:case 1:o=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,r=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(o=a.trys,!(o=o.length>0&&o[o.length-1])&&(6===n[0]||2===n[0])){a=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){a.label=n[1];break}if(6===n[0]&&a.label<o[1]){a.label=o[1],o=n;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(n);break}o[2]&&a.ops.pop(),a.trys.pop();continue}n=e.call(t,a)}catch(t){n=[6,t],r=0}finally{i=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,s])}}var i,r,o,s,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s}function r(t,e){return new b}function o(t,e){var n=M*t.lat,i=M*t.lng,r=M*e.lat,o=M*e.lng;return Math.acos(Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos(i-o))*x}function s(t,e){e*=1e3;var n=t.lat,i=t.lng,r=n*M,o=e/1e3/110.574235,s=e/1e3/(110.572833*Math.cos(r));return{northEast:{lat:n+o,lng:i+s},southWest:{lat:n-o,lng:i-s}}}function a(t){switch(t.travelType){case"walk":return 10;case"bike":return 25;case"transit":return 150;default:return 120}}function u(t,e,n){return e instanceof Array?c(t,e,n).filter(function(t){return!e.some(function(e){return e==t})}):c(t,e,n).filter(function(t){return e!=t})}function c(t,e,n){return e instanceof Array?t.filter(function(t){return e.some(function(e){return o(t,e)<=n})}):t.filter(function(t){return o(t,e)<=n})}function l(t,e){var n=_.unproject(t);return void 0!=e?{lat:n.lat,lng:n.lng,elevation:e}:n}function h(t){var e=t.lat,n=t.lon;return void 0===e&&t.center&&(e=t.center.lat,n=t.center.lon),new H(t.id,n,e,t.tags)}!function(t){function e(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 n(t){return"string"!=typeof t&&(t=String(t)),t}function i(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return d.iterable&&(e[Symbol.iterator]=function(){return e}),e}function r(t){this.map={},t instanceof r?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function o(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function s(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function a(t){var e=new FileReader,n=s(e);return e.readAsArrayBuffer(t),n}function u(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(d.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(d.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(d.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(d.arrayBuffer&&d.blob&&m(t))this._bodyArrayBuffer=u(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!d.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!g(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=u(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):d.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},d.blob&&(this.blob=function(){var t=o(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?o(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(a)}),this.text=function(){var t=o(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,n=s(e);return e.readAsText(t),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),i=0;i<e.length;i++)n[i]=String.fromCharCode(e[i]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},d.formData&&(this.formData=function(){return this.text().then(h)}),this.json=function(){return this.text().then(JSON.parse)},this}function l(t,e){var n=(e=e||{}).body;if(t instanceof l){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new r(t.headers)),this.method=t.method,this.mode=t.mode,n||null==t._bodyInit||(n=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 r(e.headers)),this.method=function(t){var e=t.toUpperCase();return v.indexOf(e)>-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function h(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),i=n.shift().replace(/\+/g," "),r=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(r))}}),e}function f(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new r(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var d={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(d.arrayBuffer)var p=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],m=function(t){return t&&DataView.prototype.isPrototypeOf(t)},g=ArrayBuffer.isView||function(t){return t&&p.indexOf(Object.prototype.toString.call(t))>-1};r.prototype.append=function(t,i){t=e(t),i=n(i);var r=this.map[t];this.map[t]=r?r+","+i:i},r.prototype.delete=function(t){delete this.map[e(t)]},r.prototype.get=function(t){return t=e(t),this.has(t)?this.map[t]:null},r.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},r.prototype.set=function(t,i){this.map[e(t)]=n(i)},r.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},r.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),i(t)},r.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),i(t)},r.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),i(t)},d.iterable&&(r.prototype[Symbol.iterator]=r.prototype.entries);var v=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];l.prototype.clone=function(){return new l(this,{body:this._bodyInit})},c.call(l.prototype),c.call(f.prototype),f.prototype.clone=function(){return new f(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new r(this.headers),url:this.url})},f.error=function(){var t=new f(null,{status:0,statusText:""});return t.type="error",t};var y=[301,302,303,307,308];f.redirect=function(t,e){if(-1===y.indexOf(e))throw new RangeError("Invalid status code");return new f(null,{status:e,headers:{location:t}})},t.Headers=r,t.Request=l,t.Response=f,t.fetch=function(t,e){return new Promise(function(n,i){var o=new l(t,e),s=new XMLHttpRequest;s.onload=function(){var t={status:s.status,statusText:s.statusText,headers:function(t){var e=new r;return t.split(/\r?\n/).forEach(function(t){var n=t.split(":"),i=n.shift().trim();if(i){var r=n.join(":").trim();e.append(i,r)}}),e}(s.getAllResponseHeaders()||"")};t.url="responseURL"in s?s.responseURL:t.headers.get("X-Request-URL");var e="response"in s?s.response:s.responseText;n(new f(e,t))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.open(o.method,o.url,!0),"include"===o.credentials&&(s.withCredentials=!0),"responseType"in s&&d.blob&&(s.responseType="blob"),o.headers.forEach(function(t,e){s.setRequestHeader(e,t)}),s.send(void 0===o._bodyInit?null:o._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:window);var f=function(){return 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",Object.assign(this,t)}}(),d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},p=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},m=function(){return function(t,e,n,i){this.value=t,this.key=e,this.previous=n,this.next=i}}(),g=function(){function t(t){void 0===t&&(t=0),this.capacity=t,this.map={},this.size=0}return t.prototype.get=function(t,e){return n(this,void 0,void 0,function(){var n,r,o,s,a;return i(this,function(i){switch(i.label){case 0:return void 0===(n=this.map[t])?[3,2]:(this.oldest==n&&n.next&&(this.oldest=n.next),n.next&&(n.next.previous=n.previous),n.previous&&(n.previous.next=n.next),n.previous=this.newest,n.next=null,this.newest=n,[4,n.value]);case 1:return[2,i.sent()];case 2:return e?(r=e(),o=this.map[t]=new m(r,t,this.newest,null),[4,r]):[3,4];case 3:return s=i.sent(),this.newest&&(this.newest.next=o),this.newest=o,this.capacity&&(this.size>=this.capacity?(a=this.oldest)&&(this.oldest=a.next,delete this.map[a.key]):this.size++),this.oldest||(this.oldest=this.newest),[2,s];case 4:return[2,void 0]}})})},t}(),v=function(){function t(){this.map={}}return t.prototype.get=function(t,e){return n(this,void 0,void 0,function(){var n,r;return i(this,function(i){switch(i.label){case 0:return n="string"==typeof t?t:JSON.stringify(t),void 0==this.map[n]?[3,1]:[2,this.map[n]];case 1:return[4,e()];case 2:return r=i.sent(),this.map[n]=r,[2,r]}})})},t}(),y=new v,b=function(){function t(){}return t.prototype.fetch=function(t,e,r,o){return void 0===e&&(e="GET"),void 0===o&&(o={}),n(this,void 0,void 0,function(){var n,s,a,u,c,l,h,f,d,p;return i(this,function(i){switch(i.label){case 0:return n=e,"JSONP"!==e?o.Accept=o.Accept?o.Accept:"application/json":n="GET","POST-RAW"===e&&(n="POST"),"PUT"!==n&&"POST"!==n||(o["Content-Type"]="application/json"),s={method:n,headers:new Headers(o)},"POST-RAW"===e?s.body=r:"GET"!==e&&"JSONP"!==e&&(s.body=JSON.stringify(r)),[4,fetch(t,s)];case 1:return(a=i.sent()).status>=400?"application/json"!==a.headers.get("content-type")?[3,3]:(h=(l=JSON).stringify,[4,a.text()]):[3,6];case 2:return c=h.apply(l,[i.sent(),null,2]),[3,5];case 3:return[4,a.text()];case 4:c=i.sent(),i.label=5;case 5:throw u=c,new Error("[ERROR] in service request\n status = "+a.status+" "+a.statusText+"\n url = "+t+"\n body = "+u);case 6:return"JSONP"!==e?[3,8]:[4,a.text()];case 7:return f=i.sent(),d=f.indexOf("("),p=f.lastIndexOf(")"),d>-1&&p>-1?[2,JSON.parse(f.substring(d+1,p))]:[2,JSON.parse(f)];case 8:return[2,a.json()];case 9:return[2]}})})},t.prototype.fetchData=function(t,e,r,o){return void 0===e&&(e="GET"),n(this,void 0,void 0,function(){var n;return i(this,function(i){switch(i.label){case 0:return[4,this.fetch(t,e,r,o)];case 1:return(n=i.sent()).data?[2,n.data]:(console.warn("No data object was transmitted by "+t+" \nReturning raw response"),[2,n])}})})},t.prototype.fetchCached=function(t,e,n,i,r){var o=this;if(void 0===n&&(n="GET"),!1!==t){!0!==t&&t||(t=y);var s=JSON.stringify({url:e,method:n,payload:i});return t.get(s,function(){return o.fetch(e,n,i,r)})}return this.fetch(e,n,i)},t.prototype.fetchCachedData=function(t,e,n,i,r){var o=this;if(void 0===n&&(n="GET"),!1!==t){!0!==t&&t||(t=y);var s=JSON.stringify({url:e,method:n,payload:i});return t.get(s,function(){return o.fetchData(e,n,i,r)})}return this.fetchData(e,n,i,r)},t}(),S=function(){function t(t){this.client=t}return t.prototype.fetch=function(t,e,o){return n(this,void 0,void 0,function(){var n,s,a;return i(this,function(i){switch(i.label){case 0:return n={west:o.southWest.lng,south:o.southWest.lat,east:o.northEast.lng,north:o.northEast.lat},s={bounds:n,benchmarks:e.map(function(t){return{source:t.source,minEnd:t.minEnd,minStart:t.minStart,factor:t.factor}})},a=this.client.config.tilesUrl+"/benchmarks/scores_cumulative/v1/"+encodeURIComponent(""+t),[4,r(this.client).fetch(a,"POST",s)];case 1:return[2,i.sent()]}})})},t.prototype.metadata=function(t){return n(this,void 0,void 0,function(){var e;return i(this,function(n){switch(n.label){case 0:return e=this.client.config.tilesUrl+"/benchmarks/meta/v1/"+encodeURIComponent(""+t),[4,r(this.client).fetch(e)];case 1:return[2,n.sent()]}})})},t}();!function(t){t.queryToString=function(t){var e=[];for(var n in t){var i=t[n];void 0!==i&&e.push(n+"="+encodeURIComponent(i))}return e.join("&")},t.buildTargomoUrl=function(t,e,n,i){return void 0===i&&(i=!0),"/"!==t[t.length-1]&&(t+="/"),t+(i?"v1/":"")+e+"?key="+n}}(t.UrlUtil||(t.UrlUtil={}));var T=function(){function e(){}return e.prototype.geocode=function(e,o,s,a,u){return n(this,void 0,void 0,function(){var n,s,c,l;return i(this,function(i){switch(i.label){case 0:return n={singleLine:e,f:"json",countryCode:a,maxLocations:5},o&&(n.location=o.lng+","+o.lat),u&&(n.magicKey=u),s="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?"+t.UrlUtil.queryToString(n),[4,r().fetch(s)];case 1:return c=i.sent(),l=c.candidates.map(function(t){return{lat:t.location.y,lng:t.location.x,description:t.address}}),[2,l]}})})},e.prototype.suggest=function(e,o,s,a,u){return void 0===u&&(u=5),n(this,void 0,void 0,function(){var n,s;return i(this,function(i){switch(i.label){case 0:return n={text:e,f:"json",countryCode:a,maxSuggestions:u},o&&(n.location=o.lng+","+o.lat),[4,r().fetch("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest?"+t.UrlUtil.queryToString(n))];case 1:return s=i.sent(),[2,s.suggestions]}})})},e.prototype.reverseGeocode=function(e,o){return n(this,void 0,void 0,function(){var n,o,s;return i(this,function(i){switch(i.label){case 0:return n={f:"json"},n.location=e.lng+","+e.lat,[4,r().fetch("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?"+t.UrlUtil.queryToString(n))];case 1:return(o=i.sent())&&o.address?(s={address:o.address.Match_addr,city:o.address.City,countryCode:o.address.CountryCode,location:o.address.Loc_name,region:o.address.Region,subregion:o.address.Subregion,zip:o.address.Postal},[2,s]):[2,{}]}})})},e}(),w=function(){function t(t){this.client=t}return t.prototype.geocode=function(t,e,o){return n(this,void 0,void 0,function(){var n,s,a,u,c=this;return i(this,function(i){switch(i.label){case 0:return n=this.client.config.photonGeocoderUrl,s=n+"/api/?q="+encodeURIComponent(t)+"&limit=5",e&&(s+="&lat="+e.lat+"&lon="+e.lng),o&&(s+="&lang="+encodeURIComponent(o)),[4,r().fetch(s)];case 1:return(a=i.sent()).features.forEach(function(t,e,n){"boundary"==t.properties.osm_key&&n.splice(e,1)}),u=a.features.map(function(t){return t.value=t.properties.osm_id,t.description=c.buildPlaceDescription(t.properties),t}),[2,u]}})})},t.prototype.buildPlaceDescription=function(t){var e=function(t,e){return void 0===e&&(e=" "),t.filter(function(t){return!!t}).join(e).trim()},n=function(n,i){return e(n.map(function(e){return t[e]}),i)},i=n(["street","housenumber"]," "),r=e([n(["postcode","city"]," "),t.country],", "),o={title:"",meta1:"",meta2:"",full:""};return void 0!==t.name?(o.title=t.name,o.meta1=i,o.meta2=r):(o.title=i,o.meta1=r),t.name!==i&&(o.full=o.title),o.meta1&&t.name!==i&&(o.full+=", "+o.meta1),o.meta1&&t.name===i&&(o.full+=o.meta1),o.full=e([o.full,o.meta2],", "),o},t}(),E=function(){function t(t){if(this.closestSources=!1,this.requestTimeout=null,this.walkSpeed={},this.bikeSpeed={},this.sources=[],this.targets=[],this.rushHour=!1,this.reverse=!1,this.recommendations=!1,this.pathSerializer="compact",this.polygonSerializer="json",this.pointReduction=!0,this.maxEdgeWeight=1800,this.travelType="bike",this.travelSpeed="medium",this.edgeWeight="time",this.transitFrameDuration=void 0,this.transitFrameDate=20170801,this.transitFrameTime=39600,this.date=this.transitFrameDate,this.time=this.transitFrameTime,this.elevation=!0,this.useCache=!0,this.travelEdgeWeights=null,Object.assign(this,t),null!=t.transitFrameDateTime){var e=new Date(t.transitFrameDateTime),n=e?1e4*e.getFullYear()+100*(e.getMonth()+1)+e.getDate():void 0,i=e?3600*e.getHours()+60*e.getMinutes():void 0;this.date=this.transitFrameDate=n||this.transitFrameDate,this.time=this.transitFrameTime=i||this.transitFrameTime}}return 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 e=this;return t.map(function(t){var n={lat:t.lat,lng:t.lng,id:t.id,tm:t.tm};if(!n.tm)switch(e.travelType){case"car":n.tm={car:e.rushHour?{rushHour:e.rushHour}:{}};break;case"walk":n.tm={walk:e.walkSpeed};break;case"bike":n.tm={bike:e.bikeSpeed};break;case"transit":n.tm={transit:{frame:{date:e.transitFrameDate,time:e.transitFrameTime},duration:e.transitFrameDuration}}}return n})},t}(),U=(function(t){function n(e){var n=t.call(this,e)||this;return n.maxSolutions=1,n.name="",n.description="",n.email="",n.callbackUrl=null,n.useCache=!0,n}e(n,t)}(E),function(){return function(t,e,n){if(this.inactiveSources=[],this.sources=[],this.getClosestSources=!1,this.intersectionMode="union",this.appendTravelTimes=!1,this.date=n.transitFrameDate||20170801,this.time=n.transitFrameTime||39600,null!=n.transitFrameDateTime){var i=new Date(n.transitFrameDateTime),r=i?1e4*i.getFullYear()+100*(i.getMonth()+1)+i.getDate():void 0,o=i?3600*i.getHours()+60*i.getMinutes():void 0;this.date=this.date=r||this.date,this.time=this.time=o||this.time}this.edgeWeight=void 0==n.edgeWeight?"time":n.edgeWeight,this.useCache=void 0==n.useCache||n.useCache,this.travelType=n.travelType,this.intersectionMode=n.intersectionMode||"union",this.sources=e.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}),n.inactiveSources&&(this.inactiveSources=n.inactiveSources.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}));var s=[];n.statistics&&(s=n.statistics.map(function(t){return t instanceof Number||"number"==typeof t?+t:t.id})),this.statisticGroupId=+n.statisticsGroup,this.statisticIds=s,this.maxEdgeWeight=n.maxEdgeWeight,this.serviceKey=t.serviceKey,this.serviceUrl=t.serviceUrl,n.closestSources&&(this.getClosestSources=!0),n.walkSpeed&&(this.walkDownhill=n.walkSpeed.downhill,this.walkSpeed=n.walkSpeed.speed,this.walkUphill=n.walkSpeed.uphill),n.bikeSpeed&&(this.bikeDownhill=n.bikeSpeed.downhill,this.bikeSpeed=n.bikeSpeed.speed,this.bikeUphill=n.bikeSpeed.uphill)}}()),A=function(){return function(){}}(),C=function(){return function(){}}();!function(t){t[t.GERMANY_ZENSUS_100M_STATISTICS=9]="GERMANY_ZENSUS_100M_STATISTICS",t[t.GERMANY_ZENSUS_200M_STATISTICS=2]="GERMANY_ZENSUS_200M_STATISTICS",t[t.GERMANY_ZENSUS_500M_STATISTICS=11]="GERMANY_ZENSUS_500M_STATISTICS",t[t.GERMANY_ZENSUS_1000M_STATISTICS=3]="GERMANY_ZENSUS_1000M_STATISTICS",t[t.GERMANY_ZENSUS_2000M_STATISTICS=10]="GERMANY_ZENSUS_2000M_STATISTICS",t[t.NORWAY_STATISTICS=4]="NORWAY_STATISTICS",t[t.CENSUS_BRANDENBURG_POPULATION=12]="CENSUS_BRANDENBURG_POPULATION",t[t.CANADA_BLOCK_STATISTICS=8]="CANADA_BLOCK_STATISTICS",t[t.CANADA_AREA_STATISTICS=5]="CANADA_AREA_STATISTICS",t[t.BERLIN_STATISTICS=6]="BERLIN_STATISTICS"}(t.StatisticsSet||(t.StatisticsSet={}));var I=function(){return function(){}}(),R=function(){return function(t){this.values=t,this.total=0;for(var e in this.values)this.total+=this.values[e]}}();!function(t){t[t.SRID_3857=3857]="SRID_3857",t[t.SRID_4326=4326]="SRID_4326"}(t.SRID||(t.SRID={})),function(t){t.NONE="none",t.SUM="sum",t.MAX="max",t.MIN="min",t.MEAN="mean",t.MEDIAN="median",t.NEAREST="nearest"}(t.MultigraphRequestAggregation||(t.MultigraphRequestAggregation={}));var _=new(function(){function t(){this.R=6378137}return t.prototype.project=function(t){var e=Math.PI/180,n=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+n)/(1-n))/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}()),x=6371.01,M=Math.PI/180,O=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:o,boundingBox:s,locationsWithinTravelOptions:function(t,e,n){var i,r=n.maxEdgeWeight;switch(n.travelType){case"walk":i=10;break;case"bike":i=25;break;case"transit":i=150;break;default:i=120}return u(t,e,"distance"===n.edgeWeight?Math.round(r/1e3):i*r/3600)},boundingBoxWithinTravelOptions:function(t,e){var n=e.maxEdgeWeight,i=a(e);return s(t,"distance"===e.edgeWeight?Math.round(n/1e3):i*n/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 n=e.maxEdgeWeight,i=a(e),r="distance"===e.edgeWeight?Math.round(n/1e3):i*n/3600,o={northEast:{lat:-1/0,lng:-1/0},southWest:{lat:1/0,lng:1/0}};return t.forEach(function(t){var e=s(t,r);o.northEast.lat=Math.max(o.northEast.lat,e.northEast.lat),o.northEast.lng=Math.max(o.northEast.lng,e.northEast.lng),o.southWest.lat=Math.min(o.southWest.lat,e.southWest.lat),o.southWest.lng=Math.min(o.southWest.lng,e.southWest.lng)}),o},locationsWithinDistance:u,locationsWithinDistanceInclusive:c,webMercatorToLatLng:l,latLngToWebMercator:function(t){var e=_.project(t);return e.x*=6378137,e.y*=6378137,e}}),N=function(){return function(t,e){var n=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){n.points.push(l({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)}}(),D=function(){function t(t,e,n,i){var r=this;this.travelTime=e,this.routeSegments=[],this.targetHeight=void 0,this.sourceHeight=void 0,this.sourceId=void 0,this.targetId=void 0,this.length=void 0;var o=0,s=[];n.reverse().forEach(function(e){var n=new N(t,e);r.routeSegments.push(n),"TRANSFER"===n.type&&o++,s=s.concat(n.points.reverse())}),this.points=s,this.transfers=o,void 0!==i&&(this.sourceId=i.source_id,this.targetId=i.target_id,this.length=i.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,n=void 0,i=void 0,r=0,o=0,s=this.points.length-1;s>=0;s--)0==s&&(n=this.points[s].elevation),s==this.points.length-1&&(i=this.points[s].elevation),void 0!==e&&(e>this.points[s].elevation?r+=e-this.points[s].elevation:e<this.points[s].elevation&&(o+=this.points[s].elevation-e)),e=this.points[s].elevation;return{targetHeight:n,sourceHeight:i,uphillMeter:r,downhillMeter:o}},t.prototype.calculateDepartureTime=function(){for(var t=0,e=0;e<this.routeSegments.length;e++){var n=this.routeSegments[e];if(null!=n.departureTime)return n.departureTime-t;t+=n.travelTime||0}},t.prototype.calculateArrivalTime=function(){for(var t=0,e=this.routeSegments.length-1;e>=0;e--){var n=this.routeSegments[e];if(null!=n.arrivalTime)return n.arrivalTime-t;t+=n.travelTime||0}},t}(),P=function(){return function(t,e){function n(t){for(var n={},i=0,r=e;i<r.length;i++){var o=r[i];n[o.name]=new R(t[o.id])}return n}var i={};if(t.individualStatistics)for(var r in t.individualStatistics)t.individualStatistics[r]&&t.individualStatistics[r].statistics&&(i[r]=n(t.individualStatistics[r].statistics));this.statistics=n(t.statistics),this.individualStatistics=i,this.raw=t}}();!function(t){t.CREATED="CREATED",t.ROUTING="ROUTING",t.MERGING="MERGING",t.AGGREGATING="AGGREGATING",t.COMPLETED="COMPLETED",t.FAILED="FAILED"}(t.MultigraphStatus||(t.MultigraphStatus={}));var G=function(){return function(){this.minPolygonHoleSize=1e7,this.buffer=50,this.simplify=50,this.srid=t.SRID.SRID_4326,this.quadrantSegments=2,this.intersectionMode="union",this.decimalPrecision=6}}(),B=function(t){function n(e,n,i){var r=t.call(this,i)||this;return r.polygon=new G,r.sources=r.buildSourcesCfg(n),r.polygon.values=i.travelEdgeWeights,r.polygon.serializer=i.serializer,r.polygon.simplify=i.simplifyMeters,r.polygon.srid=i.srid,r.polygon.buffer=i.buffer,r.polygon.minPolygonHoleSize=i.minPolygonHoleSize,r.polygon.quadrantSegments=i.quadrantSegments,r.polygon.intersectionMode=i.intersectionMode,r}return e(n,t),n}(E),W=function(t){function n(e,n,i){var r=t.call(this,i)||this;return r.osmTypes=[],r.sources=r.buildSourcesCfg([n]),r.osmTypes=i.osmTypes,r.serviceKey=e.serviceKey,r.serviceUrl=e.serviceUrl,r}return e(n,t),n}(E),k=function(t){function n(e,n,i,r){var o=t.call(this,r)||this;return o.sources=o.buildSourcesCfg(n),o.targets=o.buildTargetsCfg(i),null!=r.intersectionMode&&(o.polygon={intersectionMode:r.intersectionMode}),o}return e(n,t),n}(E),j=function(t){function n(e,n,i){var r=t.call(this,e,n,i)||this;return delete r.inactiveSources,delete r.statisticGroupId,delete r.statisticIds,delete r.getClosestSources,delete r.useCache,i&&(r.multiGraphSerializationType=i.serialization&&i.serialization.type,r.multiGraphSerializationDecimalPrecision=i.serialization&&i.serialization.decimalPrecision,i.aggregation&&(r.multiGraphAggregationType=i.aggregation.type||null,r.multiGraphAggregationIgnoreOutlier=i.aggregation.ignoreOutliers||null,r.multiGraphAggregationMinSourcesRatio=i.aggregation.minSourcesRatio||null,r.multiGraphAggregationMinSourcesCount=i.aggregation.minSourceCount||null,r.multiGraphAggregationMaxResultValueRatio=i.aggregation.maxResultValueRatio||null,r.multiGraphAggregationMaxResultValue=i.aggregation.maxResultValue||null)),r}return e(n,t),n}(U),F=function(){function e(t){this.client=t}return e.prototype.create=function(e,o){return n(this,void 0,void 0,function(){var n,s,a;return i(this,function(i){switch(i.label){case 0:return n=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"multigraph",this.client.serviceKey,!1),s=new j(this.client,e,o),[4,r(this.client).fetchCachedData(o.useClientCache,n,"POST",s,{Accept:"text/plain"})];case 1:return a=i.sent(),[2,a]}})})},e.prototype.info=function(e){return n(this,void 0,void 0,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return n=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"multigraph/"+e,this.client.serviceKey,!1),[4,r(this.client).fetch(n,"GET")];case 1:return(o=i.sent()).boundingBoxNorthEast&&o.boundingBoxSouthWest&&(o.boundingBox={northEast:{lat:o.boundingBoxNorthEast.y,lng:o.boundingBoxNorthEast.x},southWest:{lat:o.boundingBoxSouthWest.y,lng:o.boundingBoxSouthWest.x}},delete o.boundingBoxNorthEast,delete o.boundingBoxSouthWest),[2,o]}})})},e.prototype.redo=function(e){return n(this,void 0,void 0,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return n=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"multigraph/"+e+"/update",this.client.serviceKey,!1),[4,r(this.client).fetch(n,"PATCH")];case 1:return o=i.sent(),[2,o]}})})},e}(),L=function(){function t(t){this.client=t}return t.prototype.create=function(t,e){return n(this,void 0,void 0,function(){return i(this,function(e){if(!t.length)return[2,null];throw new Error("not implemented yet")})})},t.prototype.ready=function(t){return n(this,void 0,void 0,function(){var e;return i(this,function(n){return t instanceof Array||(t=[t]),e=this.client.config.statisticsUrl+"/simulation/ready?"+t.map(function(t){return"simulationId="+encodeURIComponent(""+ +t)}).join("&")+"&serviceUrl="+encodeURIComponent(this.client.serviceUrl),[2,r(this.client).fetch(e)]})})},t.prototype.fetch=function(t){return n(this,void 0,void 0,function(){var e;return i(this,function(n){return e=this.client.config.statisticsUrl+"/simulation/"+encodeURIComponent(""+ +t)+"?serviceUrl="+encodeURIComponent(this.client.serviceUrl),console.log("URL",e),[2,r(this.client).fetch(e)]})})},t}(),H=function(){function t(t,e,n,i){this.id=t,this.lng=e,this.lat=n,this.properties=i,this.properties&&(this.properties["marker-size"]=1)}return t.prototype.toString=function(){return this.properties?this.properties.name:""},t.prototype.copy=function(){var e=new t(this.id,this.lat,this.lng,p({},this.properties));for(var n in this)"properties"!=n&&(e[n]=this[n]);return e},t}(),q=function(){function t(t){this.client=t}return t.prototype.queryRaw=function(t){return n(this,void 0,void 0,function(){var e;return i(this,function(n){switch(n.label){case 0:return[4,r(this.client).fetch(this.client.config.overpassUrl+"/api/interpreter","POST-RAW",t)];case 1:return e=n.sent(),[2,e.elements.filter(function(t){return!!t.tags}).map(function(t){return h(t)})]}})})},t.prototype.query=function(t,e){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 i=[];t.forEach(function(t){e.forEach(function(e){i.push("\n way["+n(t)+"]\n ("+e.southWest.lat+","+e.southWest.lng+","+e.northEast.lat+","+e.northEast.lng+");\n node["+n(t)+"]\n ("+e.southWest.lat+","+e.southWest.lng+","+e.northEast.lat+","+e.northEast.lng+");\n ")})});var r="\n [out:json];\n (\n "+i.join("")+"\n );\n out center;\n ";return this.queryRaw(r)},t.prototype.queryGetCustom=function(t){return n(this,void 0,void 0,function(){var e;return i(this,function(n){switch(n.label){case 0:return[4,r(this.client).fetch(t)];case 1:return e=n.sent(),[2,e.elements.map(function(t){return h(t)})]}})})},t.prototype.reachable=function(t,e){return n(this,void 0,void 0,function(){var n;return i(this,function(i){switch(i.label){case 0:return n=this.client.config.poiUrl+"/reachability",[4,r(this.client).fetch(n,"POST",new W(this.client,t,e))];case 1:return[2,i.sent()]}})})},t}(),z=function(){function e(t){this.client=t}return e.prototype.fetch=function(e,o){return n(this,void 0,void 0,function(){var n,s,a;return i(this,function(i){switch(i.label){case 0:return n=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"polygon",this.client.serviceKey),s=new B(this.client,e,o),[4,r(this.client).fetchCachedData(o.useClientCache,n,"POST",s)];case 1:if(a=i.sent(),"geojson"==o.serializer)return a.metadata=o,[2,a];throw new Error("TODO: svg parsing")}})})},e}(),K=function(){function e(t){this.client=t}return e.prototype.individual=function(e,o,s){return n(this,void 0,void 0,function(){var n,a;return i(this,function(i){switch(i.label){case 0:return n=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"time",this.client.serviceKey),a=new k(this.client,e,o,s),[4,r(this.client).fetchCachedData(s.useClientCache,n,"POST",a)];case 1:return[2,i.sent()]}})})},e.prototype.combined=function(e,o,s){return n(this,void 0,void 0,function(){var n,a;return i(this,function(i){switch(i.label){case 0:return n=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"reachability",this.client.serviceKey),a=new k(this.client,e,o,s),[4,r(this.client).fetchCachedData(s.useClientCache,n,"POST",a)];case 1:return[2,i.sent()]}})})},e.prototype.count=function(t,e,r){return n(this,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,this.locations(t,e,r)];case 1:return[2,n.sent().length]}})})},e.prototype.locations=function(t,e,r){return n(this,void 0,void 0,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return n={},e.forEach(function(t){return n[String(t.id)]=-1}),[4,this.combined(t,e,r)];case 1:return(o=i.sent()).forEach(function(t){var e=String(t.id);n[e]?t.travelTime>-1&&(n[e]>-1?n[e]=Math.min(n[e],t.travelTime):n[e]=t.travelTime):console.warn("NOT FOUND",String(t.id))}),[2,e.filter(function(t){var e=String(t.id);return t.travelTime=n[e],n[e]>-1})]}})})},e}(),J=function(t){function n(e,n,i,r){var o=t.call(this,e,n,i,r)||this;return r.recommendations&&o.sources&&o.sources.forEach(function(t){if(null!=t.tm)for(var e in t.tm)t.tm[e].recommendations=1}),o}return e(n,t),n}(k),Y=function(){function e(t){this.client=t}return e.prototype.fetch=function(e,o,s){return n(this,void 0,void 0,function(){var n,a,u,c=this;return i(this,function(i){switch(i.label){case 0:return n=new J(this.client,e,o,s),a=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"route",this.client.serviceKey)+"&cb=cb&cfg="+encodeURIComponent(JSON.stringify(n)),[4,r(this.client).fetchCachedData(s.useClientCache,a,"JSONP")];case 1:return u=i.sent(),[2,u.routes.map(function(t){return new D(c.client,t.travelTime,t.segments,t)})]}})})},e}(),Z=function(){function t(t){this.client=t}return t.prototype.metadata=function(t){return n(this,void 0,void 0,function(){var e;return i(this,function(n){switch(n.label){case 0:return e=this.client.config.tilesUrl+"/similarity/meta/v1/"+encodeURIComponent(""+t),[4,r(this.client).fetch(e)];case 1:return[2,n.sent()]}})})},t.prototype.fetch=function(t,e,o,s,a){return n(this,void 0,void 0,function(){var n,u,c,l;return i(this,function(i){switch(i.label){case 0:return n={west:s.southWest.lng,south:s.southWest.lat,east:s.northEast.lng,north:s.northEast.lat},u={bounds:n,refCellId:e,scores:o.map(function(t){return{source:t.source,minutes:t.minutes,factor:t.factor||1}})},c=a?"?normalizeOnViewport="+!!a:"",l=this.client.config.tilesUrl+"/similarity/scores_cumulative/v1/"+encodeURIComponent(""+t)+c,[4,r(this.client).fetch(l,"POST",u)];case 1:return[2,i.sent()]}})})},t}(),V=function(){function t(t){this.client=t,this.statisticsMetadataCache=new g(200)}return t.prototype.combined=function(t,e){return n(this,void 0,void 0,function(){var n;return i(this,function(i){switch(i.label){case 0:return[4,this.dependent(t,e)];case 1:return n=i.sent(),[2,n&&n.statistics]}})})},t.prototype.individual=function(t,e){return n(this,void 0,void 0,function(){var n;return i(this,function(i){switch(i.label){case 0:return[4,this.dependent(t,e)];case 1:return n=i.sent(),[2,n&&n.individualStatistics]}})})},t.prototype.travelTimes=function(t,e){return n(this,void 0,void 0,function(){var n;return i(this,function(i){switch(i.label){case 0:return t.length?(n=this.client.config.statisticsUrl+"/traveltimes?serviceUrl="+encodeURIComponent(this.client.serviceUrl),[4,r(this.client).fetch(n,"POST",new U(this.client,t,e))]):[2,null];case 1:return[2,i.sent()]}})})},t.prototype.dependent=function(t,e){return n(this,void 0,void 0,function(){var n,o;return i(this,function(i){switch(i.label){case 0:return t.length?(n=this.client.config.statisticsUrl+"/charts/dependent?serviceUrl="+encodeURIComponent(this.client.serviceUrl),[4,r(this.client).fetch(n,"POST",new U(this.client,t,e))]):[2,null];case 1:return o=i.sent(),[2,new P(o,e.statistics)]}})})},t.prototype.metadata=function(t){return n(this,void 0,void 0,function(){var e,o,s,a=this;return i(this,function(u){switch(u.label){case 0:return e=this.client.config.tilesUrl,o="number"==typeof t?t:t.id,s=e+"-"+o,[4,this.statisticsMetadataCache.get(s,function(){return n(a,void 0,void 0,function(){var t;return i(this,function(n){switch(n.label){case 0:return[4,r(this.client).fetch(e+"/statistics/meta/v1/"+o)];case 1:return!(t=n.sent()).name&&t.names&&t.names.en&&(t.name=t.names.en),t.stats&&t.stats.length&&t.stats.forEach(function(t){!t.name&&t.names&&t.names.en&&(t.name=t.names.en)}),[2,t]}})})})];case 1:return[2,u.sent()]}})})},t.prototype.metadataKey=function(t,e){return n(this,void 0,void 0,function(){var n,r,o,s;return i(this,function(i){switch(i.label){case 0:return[4,this.metadata(t)];case 1:for(n=i.sent(),r=0,o=n.stats;r<o.length;r++)if(s=o[r],e.id==s.statistic_id||s.names&&s.names.en==e.name)return[2,s];return[2,null]}})})},t.prototype.tileRoute=function(t,e){return this.client.config.tilesUrl+"/statistics/tiles/v1/"+("number"==typeof t?t:t.id)+"/{z}/{x}/{y}.mvt?columns="+encodeURIComponent(e.map(function(t){return'"'+t.id+'"'}).join(","))+"&key="+encodeURIComponent(this.client.serviceKey)},t}(),X=function(){return function(t,e){this.esri=t,this.photon=e}}(),$=function(){function t(t,e,n){if(this.serviceKey=e,!t)throw new TypeError("Region parameter is missing");this.config=new f(n),t.includes("http")||t.includes("localhost")||t.includes("/")?this.serviceUrl=t:this.serviceUrl="https://api.targomo.com/"+t+"/",this.pois=new q(this),this.statistics=new V(this),this.reachability=new K(this),this.optimizations=new L(this),this.geocoding=new X(new T,new w(this)),this.polygons=new z(this),this.routes=new Y(this),this.similarity=new Z(this),this.benchmarks=new S(this),this.multigraph=new F(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 n(this,void 0,void 0,function(){var t,e,n;return i(this,function(i){switch(i.label){case 0:return t=this.endpoint,e=this.serviceKey,n=this.config.serverUrl+"/"+t+"/v1/metadata/network?key="+encodeURIComponent(e),[4,r().fetch(n)];case 1:return[2,i.sent()]}})})},t}(),Q=O;t.geometry=Q,t.PointsOfInterestClient=q,t.ClientConfig=f,t.BenchmarksClient=S,t.GeocodeEsriClient=T,t.GeocodePhotonClient=w,t.MultigraphClient=F,t.OptimizationsClient=L,t.PolygonsClient=z,t.ReachabilityClient=K,t.RoutesClient=Y,t.SimilarityClient=Z,t.StatisticsClient=V,t.GeocodingClients=X,t.TargomoClient=$,t.LatLng=A,t.BoundingBox=C,t.TravelSpeedValues=I,t.Statistics=R,t.Route=D,t.RouteSegment=N,t.StatisticsResult=P,t.RequestsUtil=b,t.requests=r,t.SimpleLRU=g,t.SimpleCache=v,Object.defineProperty(t,"__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(t){"use strict";function e(t,e){function i(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function i(t,e,i,n){return new(i||(i=Promise))(function(r,s){function o(t){try{u(n.next(t))}catch(t){s(t)}}function a(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(o,a)}u((n=n.apply(t,e||[])).next())})}function n(t,e){function i(i){return function(o){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(s=r[2&i[0]?"return":i[0]?"throw":"next"])&&!(s=s.call(r,i[1])).done)return s;switch(r=0,s&&(i=[0,s.value]),i[0]){case 0:case 1:s=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(s=a.trys,!(s=s.length>0&&s[s.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){a.label=i[1];break}if(6===i[0]&&a.label<s[1]){a.label=s[1],s=i;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(i);break}s[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,o])}}var n,r,s,o,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o}function r(t,e){return new b}function s(t,e){var i=D*t.lat,n=D*t.lng,r=D*e.lat,s=D*e.lng;return Math.acos(Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos(n-s))*x}function o(t,e){e*=1e3;var i=t.lat,n=t.lng,r=i*D,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 a(t){switch(t.travelType){case"walk":return 10;case"bike":return 25;case"transit":return 150;default:return 120}}function u(t,e,i){return e instanceof Array?c(t,e,i).filter(function(t){return!e.some(function(e){return e==t})}):c(t,e,i).filter(function(t){return e!=t})}function c(t,e,i){return e instanceof Array?t.filter(function(t){return e.some(function(e){return s(t,e)<=i})}):t.filter(function(t){return s(t,e)<=i})}function l(t,e){var i=_.unproject(t);return void 0!=e?{lat:i.lat,lng:i.lng,elevation:e}:i}function h(t){var e=t.lat,i=t.lon;return void 0===e&&t.center&&(e=t.center.lat,i=t.center.lon),new K(t.id,i,e,t.tags)}!function(t){function e(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 i(t){return"string"!=typeof t&&(t=String(t)),t}function n(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return d.iterable&&(e[Symbol.iterator]=function(){return e}),e}function r(t){this.map={},t instanceof r?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function s(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function o(t){return new Promise(function(e,i){t.onload=function(){e(t.result)},t.onerror=function(){i(t.error)}})}function a(t){var e=new FileReader,i=o(e);return e.readAsArrayBuffer(t),i}function u(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function c(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(d.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(d.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(d.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(d.arrayBuffer&&d.blob&&m(t))this._bodyArrayBuffer=u(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!d.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!v(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=u(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):d.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},d.blob&&(this.blob=function(){var t=s(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?s(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(a)}),this.text=function(){var t=s(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,i=o(e);return e.readAsText(t),i}(this._bodyBlob);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)},d.formData&&(this.formData=function(){return this.text().then(h)}),this.json=function(){return this.text().then(JSON.parse)},this}function l(t,e){var i=(e=e||{}).body;if(t instanceof l){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new r(t.headers)),this.method=t.method,this.mode=t.mode,i||null==t._bodyInit||(i=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 r(e.headers)),this.method=function(t){var e=t.toUpperCase();return g.indexOf(e)>-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function h(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var i=t.split("="),n=i.shift().replace(/\+/g," "),r=i.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(r))}}),e}function f(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new r(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var d={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(d.arrayBuffer)var p=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],m=function(t){return t&&DataView.prototype.isPrototypeOf(t)},v=ArrayBuffer.isView||function(t){return t&&p.indexOf(Object.prototype.toString.call(t))>-1};r.prototype.append=function(t,n){t=e(t),n=i(n);var r=this.map[t];this.map[t]=r?r+","+n:n},r.prototype.delete=function(t){delete this.map[e(t)]},r.prototype.get=function(t){return t=e(t),this.has(t)?this.map[t]:null},r.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},r.prototype.set=function(t,n){this.map[e(t)]=i(n)},r.prototype.forEach=function(t,e){for(var i in this.map)this.map.hasOwnProperty(i)&&t.call(e,this.map[i],i,this)},r.prototype.keys=function(){var t=[];return this.forEach(function(e,i){t.push(i)}),n(t)},r.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),n(t)},r.prototype.entries=function(){var t=[];return this.forEach(function(e,i){t.push([i,e])}),n(t)},d.iterable&&(r.prototype[Symbol.iterator]=r.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];l.prototype.clone=function(){return new l(this,{body:this._bodyInit})},c.call(l.prototype),c.call(f.prototype),f.prototype.clone=function(){return new f(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new r(this.headers),url:this.url})},f.error=function(){var t=new f(null,{status:0,statusText:""});return t.type="error",t};var y=[301,302,303,307,308];f.redirect=function(t,e){if(-1===y.indexOf(e))throw new RangeError("Invalid status code");return new f(null,{status:e,headers:{location:t}})},t.Headers=r,t.Request=l,t.Response=f,t.fetch=function(t,e){return new Promise(function(i,n){var s=new l(t,e),o=new XMLHttpRequest;o.onload=function(){var t={status:o.status,statusText:o.statusText,headers:function(t){var e=new r;return t.split(/\r?\n/).forEach(function(t){var i=t.split(":"),n=i.shift().trim();if(n){var r=i.join(":").trim();e.append(n,r)}}),e}(o.getAllResponseHeaders()||"")};t.url="responseURL"in o?o.responseURL:t.headers.get("X-Request-URL");var e="response"in o?o.response:o.responseText;i(new f(e,t))},o.onerror=function(){n(new TypeError("Network request failed"))},o.ontimeout=function(){n(new TypeError("Network request failed"))},o.open(s.method,s.url,!0),"include"===s.credentials&&(o.withCredentials=!0),"responseType"in o&&d.blob&&(o.responseType="blob"),s.headers.forEach(function(t,e){o.setRequestHeader(e,t)}),o.send(void 0===s._bodyInit?null:s._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:window);var f=function(){return 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",Object.assign(this,t)}}(),d=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])},p=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},m=function(){return function(t,e,i,n){this.value=t,this.key=e,this.previous=i,this.next=n}}(),v=function(){function t(t){void 0===t&&(t=0),this.capacity=t,this.map={},this.size=0}return t.prototype.get=function(t,e){return i(this,void 0,void 0,function(){var i,r,s,o,a,u;return n(this,function(n){switch(n.label){case 0:if(void 0===(i=this.map[t]))return[3,5];this.oldest==i&&i.next&&(this.oldest=i.next),i.next&&(i.next.previous=i.previous),i.previous&&(i.previous.next=i.next),i.previous=this.newest,i.next=null,this.newest=i,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,i.value];case 2:return[2,n.sent()];case 3:return r=n.sent(),this.map[t]=void 0,[2,this.get(t,e)];case 4:return[3,8];case 5:return e?(s=e(),o=this.map[t]=new m(s,t,this.newest,null),[4,s]):[3,7];case 6:return a=n.sent(),this.newest&&(this.newest.next=o),this.newest=o,this.capacity&&(this.size>=this.capacity?(u=this.oldest)&&(this.oldest=u.next,delete this.map[u.key]):this.size++),this.oldest||(this.oldest=this.newest),[2,a];case 7:return[2,void 0];case 8:return[2]}})})},t}(),g=function(){function t(){this.map={}}return t.prototype.get=function(t,e){return i(this,void 0,void 0,function(){var i,r;return n(this,function(n){switch(n.label){case 0:return i="string"==typeof t?t:JSON.stringify(t),void 0==this.map[i]?[3,1]:[2,this.map[i]];case 1:return[4,e()];case 2:return r=n.sent(),this.map[i]=r,[2,r]}})})},t}(),y=new g,b=function(){function t(){}return t.prototype.fetch=function(t,e,r,s){return void 0===e&&(e="GET"),void 0===s&&(s={}),i(this,void 0,void 0,function(){var i,o,a,u,c,l,h,f,d,p;return n(this,function(n){switch(n.label){case 0:return i=e,"JSONP"!==e?s.Accept=s.Accept?s.Accept:"application/json":i="GET","POST-RAW"===e&&(i="POST"),"PUT"!==i&&"POST"!==i||(s["Content-Type"]="application/json"),o={method:i,headers:new Headers(s)},"POST-RAW"===e?o.body=r:"GET"!==e&&"JSONP"!==e&&(o.body=JSON.stringify(r)),[4,fetch(t,o)];case 1:return(a=n.sent()).status>=400?"application/json"!==a.headers.get("content-type")?[3,3]:(h=(l=JSON).stringify,[4,a.text()]):[3,6];case 2:return c=h.apply(l,[n.sent(),null,2]),[3,5];case 3:return[4,a.text()];case 4:c=n.sent(),n.label=5;case 5:throw u=c,console.error("[ERROR] in service request\n status = "+a.status+" "+a.statusText+"\n url = "+t+"\n body = "+u),new Error(u);case 6:return"JSONP"!==e?[3,8]:[4,a.text()];case 7:return f=n.sent(),d=f.indexOf("("),p=f.lastIndexOf(")"),d>-1&&p>-1?[2,JSON.parse(f.substring(d+1,p))]:[2,JSON.parse(f)];case 8:return[2,a.json()];case 9:return[2]}})})},t.prototype.fetchData=function(t,e,r,s){return void 0===e&&(e="GET"),i(this,void 0,void 0,function(){var i;return n(this,function(n){switch(n.label){case 0:return[4,this.fetch(t,e,r,s)];case 1:return(i=n.sent()).data?[2,i.data]:(console.warn("No data object was transmitted by "+t+" \nReturning raw response"),[2,i])}})})},t.prototype.fetchCached=function(t,e,i,n,r){var s=this;if(void 0===i&&(i="GET"),!1!==t){!0!==t&&t||(t=y);var o=JSON.stringify({url:e,method:i,payload:n});return t.get(o,function(){return s.fetch(e,i,n,r)})}return this.fetch(e,i,n)},t.prototype.fetchCachedData=function(t,e,i,n,r){var s=this;if(void 0===i&&(i="GET"),!1!==t){!0!==t&&t||(t=y);var o=JSON.stringify({url:e,method:i,payload:n});return t.get(o,function(){return s.fetchData(e,i,n,r)})}return this.fetchData(e,i,n,r)},t}(),S=function(){function t(t){this.client=t}return t.prototype.fetch=function(t,e,s){return i(this,void 0,void 0,function(){var i,o,a;return n(this,function(n){switch(n.label){case 0:return i={west:s.southWest.lng,south:s.southWest.lat,east:s.northEast.lng,north:s.northEast.lat},o={bounds:i,benchmarks:e.map(function(t){return{source:t.source,minEnd:t.minEnd,minStart:t.minStart,factor:t.factor}})},a=this.client.config.tilesUrl+"/benchmarks/scores_cumulative/v1/"+encodeURIComponent(""+t),[4,r(this.client).fetch(a,"POST",o)];case 1:return[2,n.sent()]}})})},t.prototype.metadata=function(t){return i(this,void 0,void 0,function(){var e;return n(this,function(i){switch(i.label){case 0:return e=this.client.config.tilesUrl+"/benchmarks/meta/v1/"+encodeURIComponent(""+t),[4,r(this.client).fetch(e)];case 1:return[2,i.sent()]}})})},t}();!function(t){t.queryToString=function(t){var e=[];for(var i in t){var n=t[i];void 0!==n&&e.push(i+"="+encodeURIComponent(n))}return e.join("&")},t.buildTargomoUrl=function(t,e,i,n){return void 0===n&&(n=!0),"/"!==t[t.length-1]&&(t+="/"),t+(n?"v1/":"")+e+"?key="+i}}(t.UrlUtil||(t.UrlUtil={}));var T=function(){function e(){}return e.prototype.geocode=function(e,s,o,a,u){return i(this,void 0,void 0,function(){var i,o,c,l;return n(this,function(n){switch(n.label){case 0:return i={singleLine:e,f:"json",countryCode:a,maxLocations:5},s&&(i.location=s.lng+","+s.lat),u&&(i.magicKey=u),o="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates?"+t.UrlUtil.queryToString(i),[4,r().fetch(o)];case 1:return c=n.sent(),l=c.candidates.map(function(t){return{lat:t.location.y,lng:t.location.x,description:t.address}}),[2,l]}})})},e.prototype.suggest=function(e,s,o,a,u){return void 0===u&&(u=5),i(this,void 0,void 0,function(){var i,o;return n(this,function(n){switch(n.label){case 0:return i={text:e,f:"json",countryCode:a,maxSuggestions:u},s&&(i.location=s.lng+","+s.lat),[4,r().fetch("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/suggest?"+t.UrlUtil.queryToString(i))];case 1:return o=n.sent(),[2,o.suggestions]}})})},e.prototype.reverseGeocode=function(e,s){return i(this,void 0,void 0,function(){var i,s,o;return n(this,function(n){switch(n.label){case 0:return i={f:"json"},i.location=e.lng+","+e.lat,[4,r().fetch("https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?"+t.UrlUtil.queryToString(i))];case 1:return(s=n.sent())&&s.address?(o={address:s.address.Match_addr,city:s.address.City,countryCode:s.address.CountryCode,location:s.address.Loc_name,region:s.address.Region,subregion:s.address.Subregion,zip:s.address.Postal},[2,o]):[2,{}]}})})},e}(),w=function(){function t(t){this.client=t}return t.prototype.geocode=function(t,e,s){return i(this,void 0,void 0,function(){var i,o,a,u,c=this;return n(this,function(n){switch(n.label){case 0:return i=this.client.config.photonGeocoderUrl,o=i+"/api/?q="+encodeURIComponent(t)+"&limit=5",e&&(o+="&lat="+e.lat+"&lon="+e.lng),s&&(o+="&lang="+encodeURIComponent(s)),[4,r().fetch(o)];case 1:return(a=n.sent()).features.forEach(function(t,e,i){"boundary"==t.properties.osm_key&&i.splice(e,1)}),u=a.features.map(function(t){return t.value=t.properties.osm_id,t.description=c.buildPlaceDescription(t.properties),t}),[2,u]}})})},t.prototype.buildPlaceDescription=function(t){var e=function(t,e){return void 0===e&&(e=" "),t.filter(function(t){return!!t}).join(e).trim()},i=function(i,n){return e(i.map(function(e){return t[e]}),n)},n=i(["street","housenumber"]," "),r=e([i(["postcode","city"]," "),t.country],", "),s={title:"",meta1:"",meta2:"",full:""};return void 0!==t.name?(s.title=t.name,s.meta1=n,s.meta2=r):(s.title=n,s.meta1=r),t.name!==n&&(s.full=s.title),s.meta1&&t.name!==n&&(s.full+=", "+s.meta1),s.meta1&&t.name===n&&(s.full+=s.meta1),s.full=e([s.full,s.meta2],", "),s},t}(),U=function(){return function(t,e,i,n){var r=this;if(this.sources={},this.transitFrameDuration=void 0,this.transitFrameDate=20170801,this.transitFrameTime=39600,this.time=this.transitFrameDate,this.date=this.transitFrameTime,this.travelType=n.travelType,this.maxEdgeWeight=n.maxEdgeWeight,this.edgeWeight=n.edgeWeight,this.date=this.transitFrameDate=n.transitFrameDate,this.time=this.transitFrameTime=n.transitFrameTime,this.transitFrameDuration=n.transitFrameDuration,null!=n.transitFrameDateTime){var s=new Date(n.transitFrameDateTime),o=s?1e4*s.getFullYear()+100*(s.getMonth()+1)+s.getDate():void 0,a=s?3600*s.getHours()+60*s.getMinutes():void 0;this.date=this.transitFrameDate=o||this.transitFrameDate,this.time=this.transitFrameTime=a||this.transitFrameTime}this.description=n.description||"",this.maxEdgeWeight=n.maxEdgeWeight,this.serviceUrl=t,this.serviceKey=e,this.email=n.email||"developers@targomo.com",this.sendMail=!1,this.callbackUrl=n.callbackUrl||"https://localhost/",this.useCache=n.useCache,this.pointsPerSolution=n.pointsPerSolution,this.maxSolutions=n.maxSolutions||1,this.statisticGroupId=n.statisticGroup,n.statistic instanceof Number||"number"==typeof n.statistic?this.statisticId=+n.statistic:this.statisticId=n.statistic.id,i.forEach(function(t){r.sources[t.id]={id:t.id,x:t.lng,y:t.lat}})}}(),E=function(){return function(t,e,i){if(this.inactiveSources=[],this.sources=[],this.getClosestSources=!1,this.intersectionMode="union",this.appendTravelTimes=!1,this.date=i.transitFrameDate||20170801,this.time=i.transitFrameTime||39600,null!=i.transitFrameDateTime){var n=new Date(i.transitFrameDateTime),r=n?1e4*n.getFullYear()+100*(n.getMonth()+1)+n.getDate():void 0,s=n?3600*n.getHours()+60*n.getMinutes():void 0;this.date=this.date=r||this.date,this.time=this.time=s||this.time}this.edgeWeight=void 0==i.edgeWeight?"time":i.edgeWeight,this.useCache=void 0==i.useCache||i.useCache,this.travelType=i.travelType,this.intersectionMode=i.intersectionMode||"union",this.sources=e.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}),i.inactiveSources&&(this.inactiveSources=i.inactiveSources.map(function(t){return{id:t.id,y:t.lat,x:t.lng}}));var o=[];i.statistics&&(this.omitIndividualStatistics=i.omitIndividualStatistics,o=i.statistics.map(function(t){return t instanceof Number||"number"==typeof t?+t:t.id})),this.statisticGroupId=+i.statisticsGroup,this.statisticIds=o,this.maxEdgeWeight=i.maxEdgeWeight,this.serviceKey=t.serviceKey,this.serviceUrl=t.serviceUrl,i.closestSources&&(this.getClosestSources=!0),i.walkSpeed&&(this.walkDownhill=i.walkSpeed.downhill,this.walkSpeed=i.walkSpeed.speed,this.walkUphill=i.walkSpeed.uphill),i.bikeSpeed&&(this.bikeDownhill=i.bikeSpeed.downhill,this.bikeSpeed=i.bikeSpeed.speed,this.bikeUphill=i.bikeSpeed.uphill)}}(),C=function(){return function(){}}(),A=function(){return function(){}}();!function(t){t[t.GERMANY_ZENSUS_100M_STATISTICS=9]="GERMANY_ZENSUS_100M_STATISTICS",t[t.GERMANY_ZENSUS_200M_STATISTICS=2]="GERMANY_ZENSUS_200M_STATISTICS",t[t.GERMANY_ZENSUS_500M_STATISTICS=11]="GERMANY_ZENSUS_500M_STATISTICS",t[t.GERMANY_ZENSUS_1000M_STATISTICS=3]="GERMANY_ZENSUS_1000M_STATISTICS",t[t.GERMANY_ZENSUS_2000M_STATISTICS=10]="GERMANY_ZENSUS_2000M_STATISTICS",t[t.NORWAY_STATISTICS=4]="NORWAY_STATISTICS",t[t.CENSUS_BRANDENBURG_POPULATION=12]="CENSUS_BRANDENBURG_POPULATION",t[t.CANADA_BLOCK_STATISTICS=8]="CANADA_BLOCK_STATISTICS",t[t.CANADA_AREA_STATISTICS=5]="CANADA_AREA_STATISTICS",t[t.BERLIN_STATISTICS=6]="BERLIN_STATISTICS"}(t.StatisticsSet||(t.StatisticsSet={}));var I=function(){return function(){}}(),R=function(){return function(t){this.values=t,this.total=0;for(var e in this.values)this.total+=this.values[e]}}();!function(t){t[t.SRID_3857=3857]="SRID_3857",t[t.SRID_4326=4326]="SRID_4326"}(t.SRID||(t.SRID={})),function(t){t.NONE="none",t.SUM="sum",t.MAX="max",t.MIN="min",t.MEAN="mean",t.MEDIAN="median",t.NEAREST="nearest"}(t.MultigraphRequestAggregation||(t.MultigraphRequestAggregation={}));var _=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}()),x=6371.01,D=Math.PI/180,M=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:s,boundingBox:o,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 u(t,e,"distance"===i.edgeWeight?Math.round(r/1e3):n*r/3600)},boundingBoxWithinTravelOptions:function(t,e){var i=e.maxEdgeWeight,n=a(e);return o(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=a(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=o(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:u,locationsWithinDistanceInclusive:c,webMercatorToLatLng:l,latLngToWebMercator:function(t){return _.project(t)}}),O=function(){return 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(l({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)}}(),P=function(){function t(t,e,i,n){var r=this;this.travelTime=e,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=[];i.reverse().forEach(function(e){var i=new O(t,e);r.routeSegments.push(i),"TRANSFER"===i.type&&s++,o=o.concat(i.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;o>=0;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;e>=0;e--){var i=this.routeSegments[e];if(null!=i.arrivalTime)return i.arrivalTime-t;t+=i.travelTime||0}},t}(),N=function(){return function(t,e){function i(t){for(var i={},n=0,r=e;n<r.length;n++){var s=r[n];i[s.name]=new R(t[s.id])}return i}var n={};if(t.individualStatistics)for(var r in t.individualStatistics)t.individualStatistics[r]&&t.individualStatistics[r].statistics&&(n[r]=i(t.individualStatistics[r].statistics));this.statistics=i(t.statistics),this.individualStatistics=n,this.raw=t}}();!function(t){t.CREATED="CREATED",t.ROUTING="ROUTING",t.MERGING="MERGING",t.AGGREGATING="AGGREGATING",t.COMPLETED="COMPLETED",t.FAILED="FAILED"}(t.MultigraphStatus||(t.MultigraphStatus={}));var G=function(){return 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}})}}(),W=function(){return 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}}}}(),B=function(){function t(t){if(this.closestSources=!1,this.requestTimeout=null,this.walkSpeed={},this.bikeSpeed={},this.sources=[],this.targets=[],this.rushHour=!1,this.reverse=!1,this.recommendations=!1,this.pathSerializer="compact",this.polygonSerializer="json",this.pointReduction=!0,this.maxEdgeWeight=1800,this.travelType="bike",this.travelSpeed="medium",this.edgeWeight="time",this.transitFrameDuration=void 0,this.transitFrameDate=20170801,this.transitFrameTime=39600,this.date=this.transitFrameDate,this.time=this.transitFrameTime,this.elevation=!0,this.useCache=!0,this.travelEdgeWeights=null,Object.assign(this,t),null!=t.transitFrameDateTime){var e=new Date(t.transitFrameDateTime),i=e?1e4*e.getFullYear()+100*(e.getMonth()+1)+e.getDate():void 0,n=e?3600*e.getHours()+60*e.getMinutes():void 0;this.date=this.transitFrameDate=i||this.transitFrameDate,this.time=this.transitFrameTime=n||this.transitFrameTime}}return 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 e=this;return t.map(function(t){var i={lat:t.lat,lng:t.lng,id:t.id,tm:t.tm};if(!i.tm)switch(e.travelType){case"car":i.tm={car:e.rushHour?{rushHour:e.rushHour}:{}};break;case"walk":i.tm={walk:e.walkSpeed};break;case"bike":i.tm={bike:e.bikeSpeed};break;case"transit":i.tm={transit:{frame:{date:e.transitFrameDate,time:e.transitFrameTime},duration:e.transitFrameDuration}}}return i})},t}(),F=function(){return function(){this.minPolygonHoleSize=1e7,this.buffer=50,this.simplify=50,this.srid=t.SRID.SRID_4326,this.quadrantSegments=2,this.intersectionMode="union",this.decimalPrecision=6}}(),k=function(t){function i(e,i,n){var r=t.call(this,n)||this;return r.polygon=new F,r.sources=r.buildSourcesCfg(i),r.polygon.values=n.travelEdgeWeights,r.polygon.serializer=n.serializer,r.polygon.simplify=n.simplifyMeters,r.polygon.srid=n.srid,r.polygon.buffer=n.buffer,r.polygon.minPolygonHoleSize=n.minPolygonHoleSize,r.polygon.quadrantSegments=n.quadrantSegments,r.polygon.intersectionMode=n.intersectionMode,r}return e(i,t),i}(B),j=function(t){function i(e,i,n){var r=t.call(this,n)||this;return r.osmTypes=[],r.sources=r.buildSourcesCfg([i]),r.osmTypes=n.osmTypes,r.serviceKey=e.serviceKey,r.serviceUrl=e.serviceUrl,r}return e(i,t),i}(B),L=function(t){function i(e,i,n,r){var s=t.call(this,r)||this;return s.sources=s.buildSourcesCfg(i),s.targets=s.buildTargetsCfg(n),null!=r.intersectionMode&&(s.polygon={intersectionMode:r.intersectionMode}),s}return e(i,t),i}(B),H=function(t){function i(e,i,n){var r=t.call(this,e,i,n)||this;return delete r.inactiveSources,delete r.statisticGroupId,delete r.statisticIds,delete r.getClosestSources,delete r.useCache,n&&(r.multiGraphSerializationType=n.serialization&&n.serialization.type,r.multiGraphSerializationDecimalPrecision=n.serialization&&n.serialization.decimalPrecision,n.aggregation&&(r.multiGraphAggregationType=n.aggregation.type||null,r.multiGraphAggregationIgnoreOutlier=n.aggregation.ignoreOutliers||null,r.multiGraphAggregationMinSourcesRatio=n.aggregation.minSourcesRatio||null,r.multiGraphAggregationMinSourcesCount=n.aggregation.minSourceCount||null,r.multiGraphAggregationMaxResultValueRatio=n.aggregation.maxResultValueRatio||null,r.multiGraphAggregationMaxResultValue=n.aggregation.maxResultValue||null)),r}return e(i,t),i}(E),q=function(){function e(t){this.client=t}return e.prototype.create=function(e,s){return i(this,void 0,void 0,function(){var i,o,a;return n(this,function(n){switch(n.label){case 0:return i=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"multigraph",this.client.serviceKey,!1),o=new H(this.client,e,s),[4,r(this.client).fetchCachedData(s.useClientCache,i,"POST",o,{Accept:"text/plain"})];case 1:return a=n.sent(),[2,a]}})})},e.prototype.info=function(e){return i(this,void 0,void 0,function(){var i,s;return n(this,function(n){switch(n.label){case 0:return i=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"multigraph/"+e,this.client.serviceKey,!1),[4,r(this.client).fetch(i,"GET")];case 1:return(s=n.sent()).boundingBoxNorthEast&&s.boundingBoxSouthWest&&(s.boundingBox={northEast:{lat:s.boundingBoxNorthEast.y,lng:s.boundingBoxNorthEast.x},southWest:{lat:s.boundingBoxSouthWest.y,lng:s.boundingBoxSouthWest.x}},delete s.boundingBoxNorthEast,delete s.boundingBoxSouthWest),[2,s]}})})},e.prototype.redo=function(e){return i(this,void 0,void 0,function(){var i,s;return n(this,function(n){switch(n.label){case 0:return i=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"multigraph/"+e+"/update",this.client.serviceKey,!1),[4,r(this.client).fetch(i,"PATCH")];case 1:return s=n.sent(),[2,s]}})})},e}(),z=function(){function e(t){this.client=t}return e.prototype.create=function(e,s){return i(this,void 0,void 0,function(){var i,o,a;return n(this,function(n){switch(n.label){case 0:return e.length?(i=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"simulation/start",this.client.serviceKey,!1)+"&serviceUrl="+encodeURIComponent(this.client.serviceUrl),o=new U(this.client.serviceUrl,this.client.serviceKey,e,s),[4,r(this.client).fetch(i,"POST",o)]):[2,null];case 1:return a=n.sent(),[2,a&&+a.id]}})})},e.prototype.ready=function(e){return i(this,void 0,void 0,function(){var i;return n(this,function(n){return e instanceof Array||(e=[e]),i=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"simulation/ready",this.client.serviceKey,!1)+"&serviceUrl="+encodeURIComponent(this.client.serviceUrl)+e.map(function(t){return"&simulationId="+encodeURIComponent(""+ +t)}),[2,r(this.client).fetch(i)]})})},e.prototype.fetch=function(e){return i(this,void 0,void 0,function(){var i,s;return n(this,function(n){switch(n.label){case 0:return i=t.UrlUtil.buildTargomoUrl(this.client.config.statisticsUrl,"simulation/"+e,this.client.serviceKey,!1)+"&serviceUrl="+encodeURIComponent(this.client.serviceUrl),s=G.bind,[4,r(this.client).fetch(i)];case 1:return[2,new(s.apply(G,[void 0,n.sent()]))]}})})},e}(),K=function(){function t(t,e,i,n){this.id=t,this.lng=e,this.lat=i,this.properties=n,this.properties&&(this.properties["marker-size"]=1)}return t.prototype.toString=function(){return this.properties?this.properties.name:""},t.prototype.copy=function(){var e=new t(this.id,this.lat,this.lng,p({},this.properties));for(var i in this)"properties"!=i&&(e[i]=this[i]);return e},t}(),Y=function(){function t(t){this.client=t}return t.prototype.queryRaw=function(t){return i(this,void 0,void 0,function(){var e;return n(this,function(i){switch(i.label){case 0:return[4,r(this.client).fetch(this.client.config.overpassUrl+"/api/interpreter","POST-RAW",t)];case 1:return e=i.sent(),[2,e.elements.filter(function(t){return!!t.tags}).map(function(t){return h(t)})]}})})},t.prototype.query=function(t,e){function i(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 n=[];t.forEach(function(t){e.forEach(function(e){n.push("\n way["+i(t)+"]\n ("+e.southWest.lat+","+e.southWest.lng+","+e.northEast.lat+","+e.northEast.lng+");\n node["+i(t)+"]\n ("+e.southWest.lat+","+e.southWest.lng+","+e.northEast.lat+","+e.northEast.lng+");\n ")})});var r="\n [out:json];\n (\n "+n.join("")+"\n );\n out center;\n ";return this.queryRaw(r)},t.prototype.queryGetCustom=function(t){return i(this,void 0,void 0,function(){var e;return n(this,function(i){switch(i.label){case 0:return[4,r(this.client).fetch(t)];case 1:return e=i.sent(),[2,e.elements.map(function(t){return h(t)})]}})})},t.prototype.reachable=function(t,e){return i(this,void 0,void 0,function(){var i;return n(this,function(n){switch(n.label){case 0:return i=this.client.config.poiUrl+"/reachability",[4,r(this.client).fetch(i,"POST",new j(this.client,t,e))];case 1:return[2,n.sent()]}})})},t}(),J=function(){function e(t){this.client=t}return e.prototype.fetch=function(e,s){return i(this,void 0,void 0,function(){var i,o,a;return n(this,function(n){switch(n.label){case 0:return i=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"polygon",this.client.serviceKey),o=new k(this.client,e,s),[4,r(this.client).fetchCachedData(s.useClientCache,i,"POST",o)];case 1:if(a=n.sent(),"geojson"==s.serializer)return a.metadata=s,[2,a];throw new Error("TODO: svg parsing")}})})},e}(),V=function(){function e(t){this.client=t}return e.prototype.individual=function(e,s,o){return i(this,void 0,void 0,function(){var i,a;return n(this,function(n){switch(n.label){case 0:return i=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"time",this.client.serviceKey),a=new L(this.client,e,s,o),[4,r(this.client).fetchCachedData(o.useClientCache,i,"POST",a)];case 1:return[2,n.sent()]}})})},e.prototype.combined=function(e,s,o){return i(this,void 0,void 0,function(){var i,a;return n(this,function(n){switch(n.label){case 0:return i=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"reachability",this.client.serviceKey),a=new L(this.client,e,s,o),[4,r(this.client).fetchCachedData(o.useClientCache,i,"POST",a)];case 1:return[2,n.sent()]}})})},e.prototype.count=function(t,e,r){return i(this,void 0,void 0,function(){return n(this,function(i){switch(i.label){case 0:return[4,this.locations(t,e,r)];case 1:return[2,i.sent().length]}})})},e.prototype.locations=function(t,e,r){return i(this,void 0,void 0,function(){var i,s;return n(this,function(n){switch(n.label){case 0:return i={},e.forEach(function(t){return i[String(t.id)]=-1}),[4,this.combined(t,e,r)];case 1:return(s=n.sent()).forEach(function(t){var e=String(t.id);i[e]?t.travelTime>-1&&(i[e]>-1?i[e]=Math.min(i[e],t.travelTime):i[e]=t.travelTime):console.warn("NOT FOUND",String(t.id))}),[2,e.filter(function(t){var e=String(t.id);return t.travelTime=i[e],i[e]>-1})]}})})},e}(),Z=function(t){function i(e,i,n,r){var s=t.call(this,e,i,n,r)||this;return r.recommendations&&s.sources&&s.sources.forEach(function(t){if(null!=t.tm)for(var e in t.tm)t.tm[e].recommendations=1}),s}return e(i,t),i}(L),X=function(){function e(t){this.client=t}return e.prototype.fetch=function(e,s,o){return i(this,void 0,void 0,function(){var i,a,u,c=this;return n(this,function(n){switch(n.label){case 0:return i=new Z(this.client,e,s,o),a=t.UrlUtil.buildTargomoUrl(this.client.serviceUrl,"route",this.client.serviceKey)+"&cb=cb&cfg="+encodeURIComponent(JSON.stringify(i)),[4,r(this.client).fetchCachedData(o.useClientCache,a,"JSONP")];case 1:return u=n.sent(),[2,u.routes.map(function(t){return new P(c.client,t.travelTime,t.segments,t)})]}})})},e}(),$=function(){function t(t){this.client=t}return t.prototype.metadata=function(t){return i(this,void 0,void 0,function(){var e;return n(this,function(i){switch(i.label){case 0:return e=this.client.config.tilesUrl+"/similarity/meta/v1/"+encodeURIComponent(""+t),[4,r(this.client).fetch(e)];case 1:return[2,i.sent()]}})})},t.prototype.fetch=function(t,e,s,o,a){return i(this,void 0,void 0,function(){var i,u,c,l;return n(this,function(n){switch(n.label){case 0:return i={west:o.southWest.lng,south:o.southWest.lat,east:o.northEast.lng,north:o.northEast.lat},u={bounds:i,refCellId:e,scores:s.map(function(t){return{source:t.source,minutes:t.minutes,factor:t.factor||1}})},c=a?"?normalizeOnViewport="+!!a:"",l=this.client.config.tilesUrl+"/similarity/scores_cumulative/v1/"+encodeURIComponent(""+t)+c,[4,r(this.client).fetch(l,"POST",u)];case 1:return[2,n.sent()]}})})},t}(),Q=function(){return function(t,e,i){this.useCache=void 0==i.useCache||i.useCache;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.serviceKey=t.serviceKey,this.serviceUrl=t.serviceUrl,this.intersectionGeometry={data:e,crs:i.crs||4326}}}(),tt=function(){function t(t){this.client=t,this.statisticsMetadataCache=new v(200)}return t.prototype.combined=function(t,e){return i(this,void 0,void 0,function(){var i;return n(this,function(n){switch(n.label){case 0:return[4,this.dependent(t,p({},e,{omitIndividualStatistics:!0}))];case 1:return i=n.sent(),[2,i&&i.statistics]}})})},t.prototype.individual=function(t,e){return i(this,void 0,void 0,function(){var i;return n(this,function(n){switch(n.label){case 0:return[4,this.dependent(t,e)];case 1:return i=n.sent(),[2,i&&i.individualStatistics]}})})},t.prototype.travelTimes=function(t,e){return i(this,void 0,void 0,function(){var i;return n(this,function(n){switch(n.label){case 0:return t.length?(i=this.client.config.statisticsUrl+"/traveltimes?serviceUrl="+encodeURIComponent(this.client.serviceUrl),[4,r(this.client).fetch(i,"POST",new E(this.client,t,e))]):[2,null];case 1:return[2,n.sent()]}})})},t.prototype.dependent=function(t,e){return i(this,void 0,void 0,function(){var i,s;return n(this,function(n){switch(n.label){case 0:return t.length?(i=this.client.config.statisticsUrl+"/charts/dependent?serviceUrl="+encodeURIComponent(this.client.serviceUrl),[4,r(this.client).fetch(i,"POST",new E(this.client,t,e))]):[2,null];case 1:return s=n.sent(),[2,new N(s,e.statistics)]}})})},t.prototype.geometry=function(t,e){return i(this,void 0,void 0,function(){var i,s;return n(this,function(n){switch(n.label){case 0:return t?(i=this.client.config.statisticsUrl+"/values/geometry?serviceUrl="+encodeURIComponent(this.client.serviceUrl),[4,r(this.client).fetch(i,"POST",new Q(this.client,t,e))]):[2,null];case 1:return s=n.sent(),[2,new W(s,e.statistics)]}})})},t.prototype.metadata=function(t){return i(this,void 0,void 0,function(){var e,s,o,a=this;return n(this,function(u){switch(u.label){case 0:return e=this.client.config.tilesUrl,s="number"==typeof t?t:t.id,o=e+"-"+s,[4,this.statisticsMetadataCache.get(o,function(){return i(a,void 0,void 0,function(){var t;return n(this,function(i){switch(i.label){case 0:return[4,r(this.client).fetch(e+"/statistics/meta/v1/"+s)];case 1:return!(t=i.sent()).name&&t.names&&t.names.en&&(t.name=t.names.en),t.stats&&t.stats.length&&t.stats.forEach(function(t){!t.name&&t.names&&t.names.en&&(t.name=t.names.en)}),[2,t]}})})})];case 1:return[2,u.sent()]}})})},t.prototype.metadataKey=function(t,e){return i(this,void 0,void 0,function(){var i,r,s,o;return n(this,function(n){switch(n.label){case 0:return[4,this.metadata(t)];case 1:for(i=n.sent(),r=0,s=i.stats;r<s.length;r++)if(o=s[r],e.id==o.statistic_id||o.names&&o.names.en==e.name)return[2,o];return[2,null]}})})},t.prototype.tileRoute=function(t,e){return this.client.config.tilesUrl+"/statistics/tiles/v1/"+("number"==typeof t?t:t.id)+"/{z}/{x}/{y}.mvt?columns="+encodeURIComponent(e.map(function(t){return+t.id}).join(","))+"&key="+encodeURIComponent(this.client.serviceKey)},t}(),et=function(){return function(t,e){this.esri=t,this.photon=e}}(),it=function(){function t(t,e,i){if(this.serviceKey=e,!t)throw new TypeError("Region parameter is missing");this.config=new f(i),t.includes("http")||t.includes("localhost")||t.includes("/")?this.serviceUrl=t:this.serviceUrl="https://api.targomo.com/"+t+"/",this.pois=new Y(this),this.statistics=new tt(this),this.reachability=new V(this),this.optimizations=new z(this),this.geocoding=new et(new T,new w(this)),this.polygons=new J(this),this.routes=new X(this),this.similarity=new $(this),this.benchmarks=new S(this),this.multigraph=new q(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 i(this,void 0,void 0,function(){var t,e,i;return n(this,function(n){switch(n.label){case 0:return t=this.endpoint,e=this.serviceKey,i=this.config.serverUrl+"/"+t+"/v1/metadata/network?key="+encodeURIComponent(e),[4,r().fetch(i)];case 1:return[2,n.sent()]}})})},t}(),nt=M;t.geometry=nt,t.PointsOfInterestClient=Y,t.ClientConfig=f,t.BenchmarksClient=S,t.GeocodeEsriClient=T,t.GeocodePhotonClient=w,t.MultigraphClient=q,t.OptimizationsClient=z,t.PolygonsClient=J,t.ReachabilityClient=V,t.RoutesClient=X,t.SimilarityClient=$,t.StatisticsClient=tt,t.GeocodingClients=et,t.TargomoClient=it,t.LatLng=C,t.BoundingBox=A,t.TravelSpeedValues=I,t.Statistics=R,t.Route=P,t.RouteSegment=O,t.StatisticsResult=N,t.OptimizationResult=G,t.StatisticsGeometryResult=W,t.RequestsUtil=b,t.requests=r,t.SimpleLRU=v,t.SimpleCache=g,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=targomo-core.umd.min.js.map |
import { TargomoClient } from './targomoClient'; | ||
import { LatLngId } from '../index'; | ||
import { OptimizationRequestOptions } from '../types/options/optimizationRequestOptions'; | ||
import { LatLngId } from '../types/types'; | ||
import { OptimizationResult } from '../types/responses/optimizationResult'; | ||
export declare class OptimizationsClient { | ||
@@ -8,14 +9,23 @@ private client; | ||
/** | ||
* Initiates a an optimimization simulation. Given a list of locations and simulation parameters it tries to | ||
* derive a subset of these locations that are optimal. | ||
* | ||
* @param sources | ||
* @param matrixOptions | ||
* @param options | ||
*/ | ||
create(sources: LatLngId[], options: OptimizationRequestOptions): Promise<any>; | ||
ready(optimizationId: number | number[]): Promise<any>; | ||
/** | ||
* Checks if the given optimization simulation have completed and have results ready for retrieval | ||
* | ||
* @param optimizationId | ||
*/ | ||
fetch(optimizationId: number): Promise<any>; | ||
ready(optimizationId: number | number[]): Promise<{ | ||
[id: string]: boolean; | ||
}>; | ||
/** | ||
* Retrieve the results of an optimization simulation | ||
* | ||
* @param optimizationId | ||
*/ | ||
fetch(optimizationId: number): Promise<OptimizationResult>; | ||
} |
import { OptimizationRequestOptions } from '../../types/options/optimizationRequestOptions'; | ||
import { TravelRequestPayload } from './travelRequestPayload'; | ||
export declare class OptimizationRequestPayload extends TravelRequestPayload implements OptimizationRequestOptions { | ||
pointsPerSolution: number; | ||
statistic: number; | ||
statisticGroup: number; | ||
maxSolutions: number; | ||
name: string; | ||
import { LatLngId, TravelType } from '../../types/types'; | ||
import { TravelTypeEdgeWeightOptions } from '../../types/travelOptions'; | ||
export declare class OptimizationRequestPayload implements TravelTypeEdgeWeightOptions { | ||
description: string; | ||
statisticGroupId: number; | ||
serviceUrl: string; | ||
serviceKey: string; | ||
email: string; | ||
sendMail: boolean; | ||
callbackUrl: string; | ||
useCache: boolean; | ||
constructor(options: OptimizationRequestOptions); | ||
pointsPerSolution: number; | ||
maxSolutions: number; | ||
statisticId: number; | ||
sources: { | ||
[id: string]: { | ||
id: string; | ||
x: number; | ||
y: number; | ||
}; | ||
}; | ||
travelType: TravelType; | ||
maxEdgeWeight: number; | ||
edgeWeight: 'time' | 'distance'; | ||
transitFrameDuration: number; | ||
transitFrameDate: number; | ||
transitFrameTime: number; | ||
time: number; | ||
date: number; | ||
constructor(serviceUrl: string, serviceKey: string, sources: LatLngId[], options: OptimizationRequestOptions); | ||
} |
@@ -31,3 +31,4 @@ import { LatLngId } from '../../types'; | ||
bikeUphill?: number; | ||
omitIndividualStatistics: boolean; | ||
constructor(client: TargomoClient, sources: LatLngId[], options: StatisticsRequestOptions | StatisticsTravelRequestOptions); | ||
} |
import { TargomoClient } from './targomoClient'; | ||
import { LatLngId, StatisticsGroup, ReachableTile, StatisticsSetMeta, StatisticsSet, StatisticsKey, StatisticsKeyMeta } from '../index'; | ||
import { StatisticsRequestOptions, StatisticsTravelRequestOptions } from '../types/options/statisticsRequestOptions'; | ||
import { StatisticsRequestOptions, StatisticsTravelRequestOptions, StatisticsGeometryRequestOptions } from '../types/options/statisticsRequestOptions'; | ||
import { StatisticsResult } from '../types/responses/index'; | ||
import { StatisticsGeometryResult } from '../types/responses/statisticsGeometryResult'; | ||
export declare class StatisticsClient { | ||
@@ -33,2 +34,8 @@ private client; | ||
* | ||
* @param sources | ||
* @param options | ||
*/ | ||
geometry(geometry: any, options: StatisticsGeometryRequestOptions): Promise<StatisticsGeometryResult>; | ||
/** | ||
* | ||
* @param group | ||
@@ -35,0 +42,0 @@ */ |
import { StatisticsSet, StatisticsKey, TravelRequestOptions } from '../index'; | ||
/** | ||
* Parameters for an optimization simulation run. Optimization simulations take a set of locations | ||
* and return an optimal subset of these based on these parameters | ||
*/ | ||
export interface OptimizationRequestOptions extends TravelRequestOptions { | ||
/** | ||
* How many locations should be included in the optimal subset | ||
*/ | ||
pointsPerSolution: number; | ||
/** | ||
* Based on which statistic should the simulation be calculated | ||
*/ | ||
statistic: StatisticsKey | number; | ||
/** | ||
* Based on which statistic group should the simulation be calculated | ||
*/ | ||
statisticGroup: StatisticsSet; | ||
/** | ||
* How many result variation should be returned. Default is 1 | ||
*/ | ||
maxSolutions?: number; | ||
@@ -7,0 +23,0 @@ name?: string; |
@@ -11,2 +11,10 @@ import { StatisticsSet, StatisticsKey, TravelRequestOptions } from '../index'; | ||
statistics: StatisticsKey[]; | ||
omitIndividualStatistics?: boolean; | ||
} | ||
export interface StatisticsGeometryRequestOptions { | ||
statisticsGroup: StatisticsSet; | ||
statistics: StatisticsKey[]; | ||
useCache?: boolean; | ||
requestTimeout?: number; | ||
crs?: number; | ||
} |
@@ -5,1 +5,3 @@ export * from './route'; | ||
export * from './multigraphInfo'; | ||
export * from './optimizationResult'; | ||
export * from './statisticsGeometryResult'; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
777113
61
6716