From e47a15d6b937040a782ccfbbc5ffe421154513ff Mon Sep 17 00:00:00 2001 From: Amandus Butzer Date: Thu, 11 Jul 2024 15:57:57 +0200 Subject: [PATCH] chore(release): 0.4.0 --- CHANGELOG.md | 54 ++++++++++++++++++++++++++++++++++ dist/ors-js-client.cjs | 2 +- dist/ors-js-client.cjs.map | 2 +- dist/ors-js-client.js | 32 ++++++++------------ dist/ors-js-client.js.map | 2 +- dist/ors-js-client.umd.cjs | 2 +- dist/ors-js-client.umd.cjs.map | 2 +- package-lock.json | 4 +-- package.json | 2 +- 9 files changed, 74 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95f4148..d540bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,60 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [0.4.0](https://github.com/GIScience/openrouteservice-js/compare/v0.3.2...v0.4.0) (2024-07-11) + + +### Features + +* add snapping functionality ([b625597](https://github.com/GIScience/openrouteservice-js/commit/b62559736535a88b9717c1a915ae568711ad80a4)) +* add html example for snap ([634eab6](https://github.com/GIScience/openrouteservice-js/commit/634eab64f2bbaf4cae00ae9523786ffdd4d0d0ac)) +* avoid needing api-key for defined host ([659fe90](https://github.com/GIScience/openrouteservice-js/commit/659fe90ecedd6f321b130d8d992ec75a17b19559)) +* add dev_app components & maps for services ([eee14a7](https://github.com/GIScience/openrouteservice-js/commit/eee14a7d80b9a437c7875ca40995a9030e7a4988)) + + +### Bug Fixes + +* **eslint:** leftover linting issues ([5a7cd33](https://github.com/GIScience/openrouteservice-js/commit/5a7cd3318f5603c9e7a366a36baedaebda01908b)) + + +### Docs + +* **README:** add snap example ([2839ae6](https://github.com/GIScience/openrouteservice-js/commit/2839ae6aa3809aab517110d8ab31d7b1ee768be7)) +* **README:** fix missing await in examples ([b375cb2](https://github.com/GIScience/openrouteservice-js/commit/b375cb232ce9e6a3673af1ff6129e9abda90dd4e)) + + +### Styling + +* reformat html examples ([21e72f1](https://github.com/GIScience/openrouteservice-js/commit/21e72f191100e02c2ec0aba1860d9b430c4e9f94)) + + +### Code Refactoring + +* **examples:** use try/catch with async/await syntax ([2ba8aa4](https://github.com/GIScience/openrouteservice-js/commit/2ba8aa4c19b3f4e088ab23fc10e89905666cc174)) + + +### Build System + +* add leaflet dependencies ([114dc42](https://github.com/GIScience/openrouteservice-js/commit/114dc421c8df1d54671d8c9157e4ba54387571f0)) +* **deps:** upgrade eslint & plugins ([62eac28](https://github.com/GIScience/openrouteservice-js/commit/62eac28aa42f317c6c88e1b82694627bad263db5)) +* update dependencies ([aeb48c0](https://github.com/GIScience/openrouteservice-js/commit/aeb48c059c2b87353dc3c44de3be42cd4f0f4c93)) + + +### CI + +* add user id for ff testing ([6f5296b](https://github.com/GIScience/openrouteservice-js/commit/6f5296b0675b4d8f75622d992434502eab51eca4)) +* update actions & container image ([f1cbac1](https://github.com/GIScience/openrouteservice-js/commit/f1cbac194d0d25326c839730eb78d91ec6aebd50)) +* use --host for ci test run for gh-actions to work ([eb907d5](https://github.com/GIScience/openrouteservice-js/commit/eb907d5d35a0350b7447ec893f56a3de4e66a5b1)) + + +### Tests + +* add IsochronesApp component test ([5997dbd](https://github.com/GIScience/openrouteservice-js/commit/5997dbd374b5218ae0a002b558fde9a28fc468f1)) +* add test for other parameters ([fe8fd0a](https://github.com/GIScience/openrouteservice-js/commit/fe8fd0a2559b773cb77723cf78f9a042fe0d5825)) +* e2e test for route services in dev-app ([4c74a1d](https://github.com/GIScience/openrouteservice-js/commit/4c74a1de81cd5ee00d7d78129509adbd8d6631c6)) +* snapping functionality ([fa2bead](https://github.com/GIScience/openrouteservice-js/commit/fa2bead8dff5d9f6c5559d459c7d3a5fe6a9d19f)) +* verify OrsBase works for defined host without api_key ([7fdd364](https://github.com/GIScience/openrouteservice-js/commit/7fdd364302b6b2ca1b3b66346be1d7f29d2a93d2)) + ### [0.3.2](https://github.com/GIScience/openrouteservice-js/compare/v0.3.1...v0.3.2) (2023-09-22) diff --git a/dist/ors-js-client.cjs b/dist/ors-js-client.cjs index 225b4aa..ae1e76c 100644 --- a/dist/ors-js-client.cjs +++ b/dist/ors-js-client.cjs @@ -1,2 +1,2 @@ -"use strict";const e={defaultAPIVersion:"v2",defaultHost:"https://api.openrouteservice.org",missingAPIKeyMsg:"Please add your openrouteservice api_key..",baseUrlConstituents:["host","service","api_version","mime_type"],propNames:{apiKey:"api_key",host:"host",service:"service",apiVersion:"api_version",mimeType:"mime_type",profile:"profile",format:"format",timeout:"timeout"}};class s{fillArgs(e,s){return s={...e,...s}}saveArgsToCache(s){return{host:s[e.propNames.host],api_version:s[e.propNames.apiVersion],profile:s[e.propNames.profile],format:s[e.propNames.format],service:s[e.propNames.service],api_key:s[e.propNames.apiKey],mime_type:s[e.propNames.mimeType]}}prepareRequest(s){return delete s[e.propNames.mimeType],delete s[e.propNames.host],delete s[e.propNames.apiVersion],delete s[e.propNames.service],delete s[e.propNames.apiKey],delete s[e.propNames.profile],delete s[e.propNames.format],delete s[e.propNames.timeout],{...s}}prepareUrl(s){let t=s[e.propNames.host],r=[s[e.propNames.apiVersion],s[e.propNames.service],s[e.propNames.profile],s[e.propNames.format]];return r=r.join("/"),r=r.replace(/\/(\/)+/g,"/"),"/"===r[0]&&(r=r.slice(1)),"/"===r.slice(-1)[0]&&(r=r.slice(0,-1)),t=t+"/"+r,t}}const t=new s;class r{constructor(e){this.defaultArgs={},this.requestArgs={},this.argsCache=null,this.customHeaders={},this._setRequestDefaults(e)}_setRequestDefaults(s){if(this.defaultArgs[e.propNames.host]=e.defaultHost,s[e.propNames.host]&&(this.defaultArgs[e.propNames.host]=s[e.propNames.host]),s[e.propNames.service]&&(this.defaultArgs[e.propNames.service]=s[e.propNames.service]),!(e.propNames.apiKey in s))throw console.error(e.missingAPIKeyMsg),new Error(e.missingAPIKeyMsg);this.defaultArgs[e.propNames.apiKey]=s[e.propNames.apiKey]}checkHeaders(){this.requestArgs.customHeaders&&(this.customHeaders=this.requestArgs.customHeaders,delete this.requestArgs.customHeaders),"Content-type"in this.customHeaders||(this.customHeaders={...this.customHeaders,"Content-type":"application/json"})}async fetchRequest(s,r){let i=t.prepareUrl(this.argsCache);"pois"===this.argsCache[e.propNames.service]&&(i+=i.indexOf("?")>-1?"&":"?");const o={Authorization:this.argsCache[e.propNames.apiKey]};return await fetch(i,{method:"POST",body:JSON.stringify(s),headers:{...o,...this.customHeaders},signal:r.signal})}async createRequest(s){var t;const r=new AbortController,i=setTimeout((()=>r.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchRequest(s,r);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return"gpx"===(null==(t=this.argsCache)?void 0:t.format)?await e.text():await e.json()}finally{clearTimeout(i)}}getBody(){return this.httpArgs}async calculate(e){this.requestArgs=e,this.checkHeaders(),this.requestArgs=t.fillArgs(this.defaultArgs,this.requestArgs),this.argsCache=t.saveArgsToCache(this.requestArgs),this.httpArgs=t.prepareRequest(this.requestArgs);const s=this.getBody(this.httpArgs);return await this.createRequest(s)}}const i=new s;const o=new s;const a=new s;const n=new s;const p={Geocode:class extends r{constructor(e){super(e),this.lookupParameter={api_key:function(e,s){return e+"="+s},text:function(e,s){return"&"+e+"="+encodeURIComponent(s)},focus_point:function(e,s){let t="";return t+="&focus.point.lon="+s[1],t+="&focus.point.lat="+s[0],t},boundary_bbox:function(e,s){let t="";return t+="&boundary.rect.min_lon="+s[0][1],t+="&boundary.rect.min_lat="+s[0][0],t+="&boundary.rect.max_lon="+s[1][1],t+="&boundary.rect.max_lat="+s[1][0],t},point:function(e,s){if(s&&Array.isArray(s.lat_lng)){let e="";return e+="&point.lon="+s.lat_lng[1],e+="&point.lat="+s.lat_lng[0],e}},boundary_circle:function(e,s){let t="";return t+="&boundary.circle.lon="+s.lat_lng[1],t+="&boundary.circle.lat="+s.lat_lng[0],t+="&boundary.circle.radius="+s.radius,t},sources:function(e,s){let t="&sources=";if(s){for(const e in s)Number(e)>0&&(t+=","),t+=s[e];return t}},layers:function(e,s){let t="&layers=",r=0;for(e in s)r>0&&(t+=","),t+=s[e],r++;return t},boundary_country:function(e,s){return"&boundary.country="+s},size:function(e,s){return"&"+e+"="+s},address:function(e,s){return"&"+e+"="+s},neighbourhood:function(e,s){return"&"+e+"="+s},borough:function(e,s){return"&"+e+"="+s},locality:function(e,s){return"&"+e+"="+s},county:function(e,s){return"&"+e+"="+s},region:function(e,s){return"&"+e+"="+s},postalcode:function(e,s){return"&"+e+"="+s},country:function(e,s){return"&"+e+"="+s}}}getParametersAsQueryString(s){let t="";for(const r in s){const i=s[r];e.baseUrlConstituents.indexOf(r)<=-1&&(t+=this.lookupParameter[r](r,i))}return t}async fetchGetRequest(e){let s=i.prepareUrl(this.requestArgs);return s+="?"+this.getParametersAsQueryString(this.requestArgs),await fetch(s,{method:"GET",headers:this.customHeaders,signal:e.signal})}async geocodePromise(){const s=new AbortController,t=setTimeout((()=>s.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchGetRequest(s);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return await e.json()||e.text()}finally{clearTimeout(t)}}async geocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async reverseGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/reverse"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async structuredGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search/structured"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}},Isochrones:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs.service="isochrones"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){const s={};return e.restrictions&&(s.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(s.avoid_features=[...e.avoidables],delete e.avoidables),e.avoid_polygons&&(s.avoid_polygons={...e.avoid_polygons},delete e.avoid_polygons),Object.keys(s).length>0?{...e,options:s}:{...e}}},Directions:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="directions"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){return e.options&&"object"!=typeof e.options&&(e.options=JSON.parse(e.options)),e.restrictions&&(e.options=e.options||{},e.options.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(e.options=e.options||{},e.options.avoid_features=[...e.avoidables],delete e.avoidables),e}},Matrix:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="matrix"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}},Pois:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="pois")}generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)>-1||r===e.propNames.apiKey||r===e.propNames.timeout||(t[r]=s[r]);return t}async poisPromise(){this.requestArgs.request=this.requestArgs.request||"pois",this.argsCache=o.saveArgsToCache(this.requestArgs),this.requestArgs[e.propNames.service]&&delete this.requestArgs[e.propNames.service];const s=this.generatePayload(this.requestArgs);return await this.createRequest(s)}async pois(e){return this.requestArgs=e,this.checkHeaders(),this.requestArgs=o.fillArgs(this.defaultArgs,this.requestArgs),await this.poisPromise()}},Elevation:class extends r{generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async elevationPromise(){this.argsCache=a.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async lineElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/line"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}async pointElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/point"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}},Optimization:class extends r{generatePayload(s){let t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async optimizationPromise(){this.argsCache=n.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async optimize(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||s[e.propNames.service]||(s[e.propNames.service]="optimization"),this.requestArgs=n.fillArgs(this.defaultArgs,this.requestArgs),await this.optimizationPromise()}},Snap:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="snap"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){return e.options&&"object"!=typeof e.options&&(e.options=JSON.parse(e.options)),e.restrictions&&(e.options=e.options||{},e.options.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(e.options=e.options||{},e.options.avoid_features=[...e.avoidables],delete e.avoidables),e}}};"object"==typeof module&&"object"==typeof module.exports?module.exports=p:"function"==typeof define&&define.amd&&define(p),"undefined"!=typeof window&&(window.Openrouteservice=p),module.exports=p; +"use strict";const e={defaultAPIVersion:"v2",defaultHost:"https://api.openrouteservice.org",missingAPIKeyMsg:"Please add your openrouteservice api_key..",baseUrlConstituents:["host","service","api_version","mime_type"],propNames:{apiKey:"api_key",host:"host",service:"service",apiVersion:"api_version",mimeType:"mime_type",profile:"profile",format:"format",timeout:"timeout"}};class s{fillArgs(e,s){return s={...e,...s}}saveArgsToCache(s){return{host:s[e.propNames.host],api_version:s[e.propNames.apiVersion],profile:s[e.propNames.profile],format:s[e.propNames.format],service:s[e.propNames.service],api_key:s[e.propNames.apiKey],mime_type:s[e.propNames.mimeType]}}prepareRequest(s){return delete s[e.propNames.mimeType],delete s[e.propNames.host],delete s[e.propNames.apiVersion],delete s[e.propNames.service],delete s[e.propNames.apiKey],delete s[e.propNames.profile],delete s[e.propNames.format],delete s[e.propNames.timeout],{...s}}prepareUrl(s){let t=s[e.propNames.host],r=[s[e.propNames.apiVersion],s[e.propNames.service],s[e.propNames.profile],s[e.propNames.format]];return r=r.join("/"),r=r.replace(/\/(\/)+/g,"/"),"/"===r[0]&&(r=r.slice(1)),"/"===r.slice(-1)[0]&&(r=r.slice(0,-1)),t=t+"/"+r,t}}const t=new s;class r{constructor(e){this.defaultArgs={},this.requestArgs={},this.argsCache=null,this.customHeaders={},this._setRequestDefaults(e)}_setRequestDefaults(s){if(this.defaultArgs[e.propNames.host]=e.defaultHost,s[e.propNames.host]&&(this.defaultArgs[e.propNames.host]=s[e.propNames.host]),s[e.propNames.service]&&(this.defaultArgs[e.propNames.service]=s[e.propNames.service]),e.propNames.apiKey in s)this.defaultArgs[e.propNames.apiKey]=s[e.propNames.apiKey];else if(!s[e.propNames.host])throw console.error(e.missingAPIKeyMsg),new Error(e.missingAPIKeyMsg)}checkHeaders(){this.requestArgs.customHeaders&&(this.customHeaders=this.requestArgs.customHeaders,delete this.requestArgs.customHeaders),"Content-type"in this.customHeaders||(this.customHeaders={...this.customHeaders,"Content-type":"application/json"})}async fetchRequest(s,r){let i=t.prepareUrl(this.argsCache);"pois"===this.argsCache[e.propNames.service]&&(i+=i.indexOf("?")>-1?"&":"?");const o={Authorization:this.argsCache[e.propNames.apiKey]};return await fetch(i,{method:"POST",body:JSON.stringify(s),headers:{...o,...this.customHeaders},signal:r.signal})}async createRequest(s){var t;const r=new AbortController,i=setTimeout((()=>r.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchRequest(s,r);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return"gpx"===(null==(t=this.argsCache)?void 0:t.format)?await e.text():await e.json()}finally{clearTimeout(i)}}getBody(){return this.httpArgs}async calculate(e){this.requestArgs=e,this.checkHeaders(),this.requestArgs=t.fillArgs(this.defaultArgs,this.requestArgs),this.argsCache=t.saveArgsToCache(this.requestArgs),this.httpArgs=t.prepareRequest(this.requestArgs);const s=this.getBody(this.httpArgs);return await this.createRequest(s)}}const i=new s;const o=new s;const a=new s;const n=new s;const u={Geocode:class extends r{constructor(e){super(e),this.lookupParameter={api_key:function(e,s){return e+"="+s},text:function(e,s){return"&"+e+"="+encodeURIComponent(s)},focus_point:function(e,s){let t="";return t+="&focus.point.lon="+s[1],t+="&focus.point.lat="+s[0],t},boundary_bbox:function(e,s){let t="";return t+="&boundary.rect.min_lon="+s[0][1],t+="&boundary.rect.min_lat="+s[0][0],t+="&boundary.rect.max_lon="+s[1][1],t+="&boundary.rect.max_lat="+s[1][0],t},point:function(e,s){if(s&&Array.isArray(s.lat_lng)){let e="";return e+="&point.lon="+s.lat_lng[1],e+="&point.lat="+s.lat_lng[0],e}},boundary_circle:function(e,s){let t="";return t+="&boundary.circle.lon="+s.lat_lng[1],t+="&boundary.circle.lat="+s.lat_lng[0],t+="&boundary.circle.radius="+s.radius,t},sources:function(e,s){let t="&sources=";if(s){for(const e in s)Number(e)>0&&(t+=","),t+=s[e];return t}},layers:function(e,s){let t="&layers=",r=0;for(e in s)r>0&&(t+=","),t+=s[e],r++;return t},boundary_country:function(e,s){return"&boundary.country="+s},size:function(e,s){return"&"+e+"="+s},address:function(e,s){return"&"+e+"="+s},neighbourhood:function(e,s){return"&"+e+"="+s},borough:function(e,s){return"&"+e+"="+s},locality:function(e,s){return"&"+e+"="+s},county:function(e,s){return"&"+e+"="+s},region:function(e,s){return"&"+e+"="+s},postalcode:function(e,s){return"&"+e+"="+s},country:function(e,s){return"&"+e+"="+s}}}getParametersAsQueryString(s){let t="";for(const r in s){const i=s[r];e.baseUrlConstituents.indexOf(r)<=-1&&(t+=this.lookupParameter[r](r,i))}return t}async fetchGetRequest(e){let s=i.prepareUrl(this.requestArgs);return s+="?"+this.getParametersAsQueryString(this.requestArgs),await fetch(s,{method:"GET",headers:this.customHeaders,signal:e.signal})}async geocodePromise(){const s=new AbortController,t=setTimeout((()=>s.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchGetRequest(s);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return await e.json()||e.text()}finally{clearTimeout(t)}}async geocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async reverseGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/reverse"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async structuredGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search/structured"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}},Isochrones:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs.service="isochrones"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){const s={};return e.restrictions&&(s.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(s.avoid_features=[...e.avoidables],delete e.avoidables),e.avoid_polygons&&(s.avoid_polygons={...e.avoid_polygons},delete e.avoid_polygons),Object.keys(s).length>0?{...e,options:s}:{...e}}},Directions:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="directions"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){return e.options&&"object"!=typeof e.options&&(e.options=JSON.parse(e.options)),e.restrictions&&(e.options=e.options||{},e.options.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(e.options=e.options||{},e.options.avoid_features=[...e.avoidables],delete e.avoidables),e}},Matrix:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="matrix"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}},Pois:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="pois")}generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)>-1||r===e.propNames.apiKey||r===e.propNames.timeout||(t[r]=s[r]);return t}async poisPromise(){this.requestArgs.request=this.requestArgs.request||"pois",this.argsCache=o.saveArgsToCache(this.requestArgs),this.requestArgs[e.propNames.service]&&delete this.requestArgs[e.propNames.service];const s=this.generatePayload(this.requestArgs);return await this.createRequest(s)}async pois(e){return this.requestArgs=e,this.checkHeaders(),this.requestArgs=o.fillArgs(this.defaultArgs,this.requestArgs),await this.poisPromise()}},Elevation:class extends r{generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async elevationPromise(){this.argsCache=a.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async lineElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/line"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}async pointElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/point"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}},Optimization:class extends r{generatePayload(s){let t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async optimizationPromise(){this.argsCache=n.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async optimize(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||s[e.propNames.service]||(s[e.propNames.service]="optimization"),this.requestArgs=n.fillArgs(this.defaultArgs,this.requestArgs),await this.optimizationPromise()}},Snap:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="snap"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}}};"object"==typeof module&&"object"==typeof module.exports?module.exports=u:"function"==typeof define&&define.amd&&define(u),"undefined"!=typeof window&&(window.Openrouteservice=u),module.exports=u; //# sourceMappingURL=ors-js-client.cjs.map diff --git a/dist/ors-js-client.cjs.map b/dist/ors-js-client.cjs.map index 1ec43e5..8ed2b8c 100644 --- a/dist/ors-js-client.cjs.map +++ b/dist/ors-js-client.cjs.map @@ -1 +1 @@ -{"version":3,"file":"ors-js-client.cjs","sources":["../src/constants.js","../src/OrsUtil.js","../src/OrsBase.js","../src/OrsGeocode.js","../src/OrsPois.js","../src/OrsElevation.js","../src/OrsOptimization.js","../src/index.js","../src/OrsIsochrones.js","../src/OrsDirections.js","../src/OrsMatrix.js","../src/OrsSnap.js"],"sourcesContent":["const constants = {\n defaultAPIVersion: 'v2',\n defaultHost: 'https://api.openrouteservice.org',\n missingAPIKeyMsg: 'Please add your openrouteservice api_key..',\n baseUrlConstituents: ['host', 'service', 'api_version', 'mime_type'],\n propNames: {\n apiKey: 'api_key',\n host: 'host',\n service: 'service',\n apiVersion: 'api_version',\n mimeType: 'mime_type',\n profile: 'profile',\n format: 'format',\n timeout: 'timeout'\n }\n}\n\nexport default constants\n","import Constants from './constants.js'\nclass OrsUtil {\n fillArgs(defaultArgs, requestArgs) {\n requestArgs = {...defaultArgs, ...requestArgs}\n return requestArgs\n }\n\n saveArgsToCache(args) {\n return {\n host: args[Constants.propNames.host],\n api_version: args[Constants.propNames.apiVersion],\n profile: args[Constants.propNames.profile],\n format: args[Constants.propNames.format],\n service: args[Constants.propNames.service],\n api_key: args[Constants.propNames.apiKey],\n mime_type: args[Constants.propNames.mimeType]\n }\n }\n\n prepareRequest(args) {\n delete args[Constants.propNames.mimeType]\n delete args[Constants.propNames.host]\n delete args[Constants.propNames.apiVersion]\n delete args[Constants.propNames.service]\n delete args[Constants.propNames.apiKey]\n delete args[Constants.propNames.profile]\n delete args[Constants.propNames.format]\n delete args[Constants.propNames.timeout]\n return { ...args }\n }\n\n /**\n * Prepare the request url based on url constituents\n * @param {Object} args\n * @return {string} url\n */\n prepareUrl(args) {\n let url = args[Constants.propNames.host]\n let urlPathParts = [\n args[Constants.propNames.apiVersion],\n args[Constants.propNames.service],\n args[Constants.propNames.profile],\n args[Constants.propNames.format]\n ]\n\n urlPathParts = urlPathParts.join('/')\n urlPathParts = urlPathParts.replace(/\\/(\\/)+/g, '/')\n\n // The beginning and end of urlPathParts can not be a slash\n if (urlPathParts[0] === '/') {\n urlPathParts = urlPathParts.slice(1)\n }\n let end = urlPathParts.slice(-1)\n if (end[0] === '/') {\n urlPathParts = urlPathParts.slice(0, -1)\n }\n\n url = url + '/' + urlPathParts\n\n return url\n }\n}\n\nexport default OrsUtil\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsBase {\n constructor(args) {\n this.defaultArgs = {}\n this.requestArgs = {}\n this.argsCache = null\n this.customHeaders = {}\n\n this._setRequestDefaults(args)\n }\n\n /**\n * Set defaults for a request comparing with and overwriting default class arguments\n * @param {Object} args - constructor input\n */\n _setRequestDefaults(args) {\n this.defaultArgs[Constants.propNames.host] = Constants.defaultHost\n if (args[Constants.propNames.host]) {\n this.defaultArgs[Constants.propNames.host] = args[Constants.propNames.host]\n }\n if (args[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]\n }\n if (Constants.propNames.apiKey in args) {\n this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]\n } else {\n // eslint-disable-next-line no-console\n console.error(Constants.missingAPIKeyMsg)\n throw new Error(Constants.missingAPIKeyMsg)\n }\n\n }\n\n checkHeaders() {\n // Get custom header and remove from args\n if (this.requestArgs.customHeaders) {\n this.customHeaders = this.requestArgs.customHeaders\n delete this.requestArgs.customHeaders\n }\n // set default Content-type, since Postman sets Content-type to text/plain if not specified\n if (!('Content-type' in this.customHeaders)) {\n this.customHeaders = {...this.customHeaders, 'Content-type': 'application/json'}\n }\n }\n\n async fetchRequest(body, controller) {\n let url = orsUtil.prepareUrl(this.argsCache)\n if (this.argsCache[Constants.propNames.service] === 'pois') {\n url += url.indexOf('?') > -1 ? '&' : '?'\n }\n\n const authorization = {'Authorization': this.argsCache[Constants.propNames.apiKey]}\n\n return await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: {...authorization, ...this.customHeaders},\n signal: controller.signal\n })\n }\n\n async createRequest(body) {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchRequest(body, controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return this.argsCache?.format === 'gpx' ? await orsResponse.text() : await orsResponse.json()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n // is overidden in Directions and Isochrones class\n getBody() {\n return this.httpArgs;\n }\n\n async calculate(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n this.httpArgs = orsUtil.prepareRequest(this.requestArgs)\n const postBody = this.getBody(this.httpArgs)\n\n return await this.createRequest(postBody)\n }\n}\n\nexport default OrsBase\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsGeocode extends OrsBase {\n constructor(args) {\n super(args)\n\n this.lookupParameter = {\n api_key: function(key, val) {\n return key + '=' + val\n },\n text: function(key, val) {\n return '&' + key + '=' + encodeURIComponent(val)\n },\n focus_point: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'focus.point.lon' + '=' + val[1]\n urlParams += '&' + 'focus.point.lat' + '=' + val[0]\n return urlParams\n },\n boundary_bbox: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.rect.min_lon' + '=' + val[0][1]\n urlParams += '&' + 'boundary.rect.min_lat' + '=' + val[0][0]\n urlParams += '&' + 'boundary.rect.max_lon' + '=' + val[1][1]\n urlParams += '&' + 'boundary.rect.max_lat' + '=' + val[1][0]\n\n return urlParams\n },\n point: function(key, val) {\n if (val && Array.isArray(val.lat_lng)) {\n let urlParams = ''\n urlParams += '&' + 'point.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'point.lat' + '=' + val.lat_lng[0]\n return urlParams\n }\n },\n boundary_circle: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.circle.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'boundary.circle.lat' + '=' + val.lat_lng[0]\n urlParams += '&' + 'boundary.circle.radius' + '=' + val.radius\n\n return urlParams\n },\n sources: function(key, val) {\n let urlParams = '&sources='\n if (val) {\n for (const key in val) {\n if (Number(key) > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n }\n return urlParams\n }\n },\n layers: function(key, val) {\n let urlParams = '&layers='\n let counter = 0\n for (key in val) {\n if (counter > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n counter++\n }\n return urlParams\n },\n boundary_country: function(key, val) {\n return '&' + 'boundary.country' + '=' + val\n },\n size: function(key, val) {\n return '&' + key + '=' + val\n },\n address: function(key, val) {\n return '&' + key + '=' + val\n },\n neighbourhood: function(key, val) {\n return '&' + key + '=' + val\n },\n borough: function(key, val) {\n return '&' + key + '=' + val\n },\n locality: function(key, val) {\n return '&' + key + '=' + val\n },\n county: function(key, val) {\n return '&' + key + '=' + val\n },\n region: function(key, val) {\n return '&' + key + '=' + val\n },\n postalcode: function(key, val) {\n return '&' + key + '=' + val\n },\n country: function(key, val) {\n return '&' + key + '=' + val\n }\n }\n }\n\n getParametersAsQueryString(args) {\n let queryString = ''\n for (const key in args) {\n const val = args[key]\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n queryString += this.lookupParameter[key](key, val)\n }\n }\n return queryString\n }\n\n async fetchGetRequest(controller) {\n let url = orsUtil.prepareUrl(this.requestArgs)\n // Add url query string from args\n url += '?' + this.getParametersAsQueryString(this.requestArgs)\n\n // createRequest function from base class is not applicable: GET instead of POST request\n return await fetch(url, {\n method: 'GET',\n headers: this.customHeaders,\n signal: controller.signal\n })\n }\n\n async geocodePromise() {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchGetRequest(controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return await orsResponse.json() || orsResponse.text()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n async geocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async reverseGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/reverse'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async structuredGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search/structured'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n}\n\nexport default OrsGeocode\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsPois extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'pois'\n }\n }\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (\n !(\n Constants.baseUrlConstituents.indexOf(key) > -1 ||\n key === Constants.propNames.apiKey ||\n key === Constants.propNames.timeout\n )\n ) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async poisPromise() {\n // the request arg is required by the API as part of the body\n this.requestArgs.request = this.requestArgs.request || 'pois'\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n if (this.requestArgs[Constants.propNames.service]) {\n delete this.requestArgs[Constants.propNames.service]\n }\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async pois(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.poisPromise()\n }\n}\n\nexport default OrsPois\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\nclass OrsElevation extends OrsBase {\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async elevationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async lineElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/line'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n\n async pointElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/point'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n}\n\nexport default OrsElevation\n","import OrsUtil from \"./OrsUtil.js\"\nimport Constants from \"./constants.js\"\nimport OrsBase from \"./OrsBase.js\"\n\nconst orsUtil = new OrsUtil()\n\nclass OrsOptimization extends OrsBase {\n generatePayload(args) {\n let payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async optimizationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async optimize(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !reqArgs[Constants.propNames.service]) {\n reqArgs[Constants.propNames.service] = 'optimization'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.optimizationPromise()\n }\n}\n\nexport default OrsOptimization\n","import OrsGeocode from './OrsGeocode.js'\nimport OrsIsochrones from './OrsIsochrones.js'\nimport OrsMatrix from './OrsMatrix.js'\nimport OrsDirections from './OrsDirections.js'\nimport OrsPois from './OrsPois.js'\nimport OrsElevation from './OrsElevation.js'\nimport OrsOptimization from './OrsOptimization.js'\nimport OrsSnap from './OrsSnap.js';\n\nconst Openrouteservice = {\n Geocode: OrsGeocode,\n Isochrones: OrsIsochrones,\n Directions: OrsDirections,\n Matrix: OrsMatrix,\n Pois: OrsPois,\n Elevation: OrsElevation,\n Optimization: OrsOptimization,\n Snap: OrsSnap\n}\n\n// Define Openrouteservice for Node module pattern loaders, including Browserify\nif (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = Openrouteservice\n // define Openrouteservice as an AMD module\n // eslint-disable-next-line no-undef\n} else if (typeof define === 'function' && define.amd) {\n // eslint-disable-next-line no-undef\n define(Openrouteservice)\n}\n\nif (typeof window !== 'undefined') {\n window.Openrouteservice = Openrouteservice\n}\n\nexport default Openrouteservice\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsIsochrones extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs.service = 'isochrones'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n const options = {}\n\n if (args.restrictions) {\n options.profile_params = {\n restrictions: {\n ...args.restrictions\n }\n }\n delete args.restrictions\n }\n if (args.avoidables) {\n options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n\n if (args.avoid_polygons) {\n options.avoid_polygons = {\n ...args.avoid_polygons\n }\n delete args.avoid_polygons\n }\n\n if (Object.keys(options).length > 0) {\n return {\n ...args,\n options: options\n }\n } else {\n return {\n ...args\n }\n }\n }\n}\n\nexport default OrsIsochrones\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsDirections extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'directions'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsDirections\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsMatrix extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'matrix'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsMatrix\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsSnap extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'snap'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsSnap\n"],"names":["constants","defaultAPIVersion","defaultHost","missingAPIKeyMsg","baseUrlConstituents","propNames","apiKey","host","service","apiVersion","mimeType","profile","format","timeout","OrsUtil","fillArgs","defaultArgs","requestArgs","saveArgsToCache","args","Constants","api_version","api_key","mime_type","prepareRequest","prepareUrl","url","urlPathParts","join","replace","slice","orsUtil","OrsBase","constructor","this","argsCache","customHeaders","_setRequestDefaults","console","error","Error","checkHeaders","async","body","controller","indexOf","authorization","Authorization","fetch","method","JSON","stringify","headers","signal","AbortController","setTimeout","abort","orsResponse","fetchRequest","ok","statusText","status","response","_a","text","json","clearTimeout","getBody","httpArgs","reqArgs","postBody","createRequest","Openrouteservice","Geocode","super","lookupParameter","key","val","encodeURIComponent","focus_point","urlParams","boundary_bbox","point","Array","isArray","lat_lng","boundary_circle","radius","sources","Number","layers","counter","boundary_country","size","address","neighbourhood","borough","locality","county","region","postalcode","country","getParametersAsQueryString","queryString","fetchGetRequest","geocodePromise","Isochrones","options","restrictions","profile_params","avoidables","avoid_features","avoid_polygons","Object","keys","length","Directions","parse","Matrix","Pois","generatePayload","payload","request","poisPromise","Elevation","elevationPromise","Optimization","optimizationPromise","Snap","module","exports","define","amd","window"],"mappings":"aAAA,MAAMA,EAAY,CAChBC,kBAAmB,KACnBC,YAAa,mCACbC,iBAAkB,6CAClBC,oBAAqB,CAAC,OAAQ,UAAW,cAAe,aACxDC,UAAW,CACTC,OAAQ,UACRC,KAAM,OACNC,QAAS,UACTC,WAAY,cACZC,SAAU,YACVC,QAAS,UACTC,OAAQ,SACRC,QAAS,YCZb,MAAMC,EACJC,SAASC,EAAaC,GAEb,OADPA,EAAc,IAAID,KAAgBC,EAEnC,CAEDC,gBAAgBC,GACP,MAAA,CACLZ,KAAMY,EAAKC,EAAUf,UAAUE,MAC/Bc,YAAaF,EAAKC,EAAUf,UAAUI,YACtCE,QAASQ,EAAKC,EAAUf,UAAUM,SAClCC,OAAQO,EAAK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,gBAAgBgB,KAAKjB,aAE9C,MAAMwG,EAAUvF,KAAKsF,gBAAgBtF,KAAKjB,aAEnC,aAAMiB,KAAKqC,cAAckD,EACjC,CAED/E,eAAe2B,GAUN,OATPnC,KAAKjB,YAAcoD,EAEnBnC,KAAKO,eAEAP,KAAKlB,YAAYI,EAAUf,UAAUG,UAAa6D,EAAQjD,EAAUf,UAAUG,WACzEY,EAAAA,EAAUf,UAAUG,SAAW,gBAEzC0B,KAAKjB,YAAcc,EAAQhB,SAASmB,KAAKlB,YAAakB,KAAKjB,mBAE9CiB,KAAK6F,qBACnB,GCpBDC,KIdF,cAAsBhG,EAClBC,YAAYd,GACRuD,MAAMvD,GACDe,KAAKlB,YAAYI,EAAUf,UAAUG,WACjC0B,KAAAlB,YAAYI,EAAUf,UAAUG,SAAW,QAE/CW,EAAKC,EAAUf,UAAUI,cACrByB,KAAAlB,YAAYK,YAAcD,EAAUnB,kBAEhD,CAEDkE,QAAQhD,GAkBG,OAjBHA,EAAKwF,SAAmC,iBAAjBxF,EAAKwF,UAC5BxF,EAAKwF,QAAUzD,KAAKmE,MAAMlG,EAAKwF,UAG/BxF,EAAKyF,eACAzF,EAAAwF,QAAUxF,EAAKwF,SAAW,CAAE,EACjCxF,EAAKwF,QAAQE,eAAiB,CAC1BD,aAAc,IAAKzF,EAAKyF,sBAErBzF,EAAKyF,cAGZzF,EAAK2F,aACA3F,EAAAwF,QAAUxF,EAAKwF,SAAW,CAAE,EACjCxF,EAAKwF,QAAQI,eAAiB,IAAI5F,EAAK2F,mBAChC3F,EAAK2F,YAET3F,CACV,IJZiB,iBAAX8G,QAAiD,iBAAnBA,OAAOC,QAC9CD,OAAOC,QAAU1D,EAGU,mBAAX2D,QAAyBA,OAAOC,KAEhDD,OAAO3D,GAGa,oBAAX6D,SACTA,OAAO7D,iBAAmBA"} \ No newline at end of file +{"version":3,"file":"ors-js-client.cjs","sources":["../src/constants.js","../src/OrsUtil.js","../src/OrsBase.js","../src/OrsGeocode.js","../src/OrsPois.js","../src/OrsElevation.js","../src/OrsOptimization.js","../src/index.js","../src/OrsIsochrones.js","../src/OrsDirections.js","../src/OrsMatrix.js","../src/OrsSnap.js"],"sourcesContent":["const constants = {\n defaultAPIVersion: 'v2',\n defaultHost: 'https://api.openrouteservice.org',\n missingAPIKeyMsg: 'Please add your openrouteservice api_key..',\n baseUrlConstituents: ['host', 'service', 'api_version', 'mime_type'],\n propNames: {\n apiKey: 'api_key',\n host: 'host',\n service: 'service',\n apiVersion: 'api_version',\n mimeType: 'mime_type',\n profile: 'profile',\n format: 'format',\n timeout: 'timeout'\n }\n}\n\nexport default constants\n","import Constants from './constants.js'\nclass OrsUtil {\n fillArgs(defaultArgs, requestArgs) {\n requestArgs = {...defaultArgs, ...requestArgs}\n return requestArgs\n }\n\n saveArgsToCache(args) {\n return {\n host: args[Constants.propNames.host],\n api_version: args[Constants.propNames.apiVersion],\n profile: args[Constants.propNames.profile],\n format: args[Constants.propNames.format],\n service: args[Constants.propNames.service],\n api_key: args[Constants.propNames.apiKey],\n mime_type: args[Constants.propNames.mimeType]\n }\n }\n\n prepareRequest(args) {\n delete args[Constants.propNames.mimeType]\n delete args[Constants.propNames.host]\n delete args[Constants.propNames.apiVersion]\n delete args[Constants.propNames.service]\n delete args[Constants.propNames.apiKey]\n delete args[Constants.propNames.profile]\n delete args[Constants.propNames.format]\n delete args[Constants.propNames.timeout]\n return { ...args }\n }\n\n /**\n * Prepare the request url based on url constituents\n * @param {Object} args\n * @return {string} url\n */\n prepareUrl(args) {\n let url = args[Constants.propNames.host]\n let urlPathParts = [\n args[Constants.propNames.apiVersion],\n args[Constants.propNames.service],\n args[Constants.propNames.profile],\n args[Constants.propNames.format]\n ]\n\n urlPathParts = urlPathParts.join('/')\n urlPathParts = urlPathParts.replace(/\\/(\\/)+/g, '/')\n\n // The beginning and end of urlPathParts can not be a slash\n if (urlPathParts[0] === '/') {\n urlPathParts = urlPathParts.slice(1)\n }\n let end = urlPathParts.slice(-1)\n if (end[0] === '/') {\n urlPathParts = urlPathParts.slice(0, -1)\n }\n\n url = url + '/' + urlPathParts\n\n return url\n }\n}\n\nexport default OrsUtil\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsBase {\n constructor(args) {\n this.defaultArgs = {}\n this.requestArgs = {}\n this.argsCache = null\n this.customHeaders = {}\n\n this._setRequestDefaults(args)\n }\n\n /**\n * Set defaults for a request comparing with and overwriting default class arguments\n * @param {Object} args - constructor input\n */\n _setRequestDefaults(args) {\n this.defaultArgs[Constants.propNames.host] = Constants.defaultHost\n if (args[Constants.propNames.host]) {\n this.defaultArgs[Constants.propNames.host] = args[Constants.propNames.host]\n }\n if (args[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]\n }\n if (Constants.propNames.apiKey in args) {\n this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]\n } else if (!args[Constants.propNames.host]) {\n // Do not error if a host is specified; useful for locally-run instances of ORS\n console.error(Constants.missingAPIKeyMsg)\n throw new Error(Constants.missingAPIKeyMsg)\n }\n\n }\n\n checkHeaders() {\n // Get custom header and remove from args\n if (this.requestArgs.customHeaders) {\n this.customHeaders = this.requestArgs.customHeaders\n delete this.requestArgs.customHeaders\n }\n // set default Content-type, since Postman sets Content-type to text/plain if not specified\n if (!('Content-type' in this.customHeaders)) {\n this.customHeaders = {...this.customHeaders, 'Content-type': 'application/json'}\n }\n }\n\n async fetchRequest(body, controller) {\n let url = orsUtil.prepareUrl(this.argsCache)\n if (this.argsCache[Constants.propNames.service] === 'pois') {\n url += url.indexOf('?') > -1 ? '&' : '?'\n }\n\n const authorization = {'Authorization': this.argsCache[Constants.propNames.apiKey]}\n\n return await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: {...authorization, ...this.customHeaders},\n signal: controller.signal\n })\n }\n\n async createRequest(body) {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchRequest(body, controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return this.argsCache?.format === 'gpx' ? await orsResponse.text() : await orsResponse.json()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n // is overridden in Directions and Isochrones class\n getBody() {\n return this.httpArgs;\n }\n\n async calculate(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n this.httpArgs = orsUtil.prepareRequest(this.requestArgs)\n const postBody = this.getBody(this.httpArgs)\n\n return await this.createRequest(postBody)\n }\n}\n\nexport default OrsBase\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsGeocode extends OrsBase {\n constructor(args) {\n super(args)\n\n this.lookupParameter = {\n api_key: function(key, val) {\n return key + '=' + val\n },\n text: function(key, val) {\n return '&' + key + '=' + encodeURIComponent(val)\n },\n focus_point: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'focus.point.lon' + '=' + val[1]\n urlParams += '&' + 'focus.point.lat' + '=' + val[0]\n return urlParams\n },\n boundary_bbox: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.rect.min_lon' + '=' + val[0][1]\n urlParams += '&' + 'boundary.rect.min_lat' + '=' + val[0][0]\n urlParams += '&' + 'boundary.rect.max_lon' + '=' + val[1][1]\n urlParams += '&' + 'boundary.rect.max_lat' + '=' + val[1][0]\n\n return urlParams\n },\n point: function(key, val) {\n if (val && Array.isArray(val.lat_lng)) {\n let urlParams = ''\n urlParams += '&' + 'point.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'point.lat' + '=' + val.lat_lng[0]\n return urlParams\n }\n },\n boundary_circle: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.circle.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'boundary.circle.lat' + '=' + val.lat_lng[0]\n urlParams += '&' + 'boundary.circle.radius' + '=' + val.radius\n\n return urlParams\n },\n sources: function(key, val) {\n let urlParams = '&sources='\n if (val) {\n for (const key in val) {\n if (Number(key) > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n }\n return urlParams\n }\n },\n layers: function(key, val) {\n let urlParams = '&layers='\n let counter = 0\n for (key in val) {\n if (counter > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n counter++\n }\n return urlParams\n },\n boundary_country: function(key, val) {\n return '&' + 'boundary.country' + '=' + val\n },\n size: function(key, val) {\n return '&' + key + '=' + val\n },\n address: function(key, val) {\n return '&' + key + '=' + val\n },\n neighbourhood: function(key, val) {\n return '&' + key + '=' + val\n },\n borough: function(key, val) {\n return '&' + key + '=' + val\n },\n locality: function(key, val) {\n return '&' + key + '=' + val\n },\n county: function(key, val) {\n return '&' + key + '=' + val\n },\n region: function(key, val) {\n return '&' + key + '=' + val\n },\n postalcode: function(key, val) {\n return '&' + key + '=' + val\n },\n country: function(key, val) {\n return '&' + key + '=' + val\n }\n }\n }\n\n getParametersAsQueryString(args) {\n let queryString = ''\n for (const key in args) {\n const val = args[key]\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n queryString += this.lookupParameter[key](key, val)\n }\n }\n return queryString\n }\n\n async fetchGetRequest(controller) {\n let url = orsUtil.prepareUrl(this.requestArgs)\n // Add url query string from args\n url += '?' + this.getParametersAsQueryString(this.requestArgs)\n\n // createRequest function from base class is not applicable: GET instead of POST request\n return await fetch(url, {\n method: 'GET',\n headers: this.customHeaders,\n signal: controller.signal\n })\n }\n\n async geocodePromise() {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchGetRequest(controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return await orsResponse.json() || orsResponse.text()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n async geocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async reverseGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/reverse'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async structuredGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search/structured'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n}\n\nexport default OrsGeocode\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsPois extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'pois'\n }\n }\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (\n !(\n Constants.baseUrlConstituents.indexOf(key) > -1 ||\n key === Constants.propNames.apiKey ||\n key === Constants.propNames.timeout\n )\n ) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async poisPromise() {\n // the request arg is required by the API as part of the body\n this.requestArgs.request = this.requestArgs.request || 'pois'\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n if (this.requestArgs[Constants.propNames.service]) {\n delete this.requestArgs[Constants.propNames.service]\n }\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async pois(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.poisPromise()\n }\n}\n\nexport default OrsPois\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\nclass OrsElevation extends OrsBase {\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async elevationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async lineElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/line'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n\n async pointElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/point'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n}\n\nexport default OrsElevation\n","import OrsUtil from \"./OrsUtil.js\"\nimport Constants from \"./constants.js\"\nimport OrsBase from \"./OrsBase.js\"\n\nconst orsUtil = new OrsUtil()\n\nclass OrsOptimization extends OrsBase {\n generatePayload(args) {\n let payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async optimizationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async optimize(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !reqArgs[Constants.propNames.service]) {\n reqArgs[Constants.propNames.service] = 'optimization'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.optimizationPromise()\n }\n}\n\nexport default OrsOptimization\n","import OrsGeocode from './OrsGeocode.js'\nimport OrsIsochrones from './OrsIsochrones.js'\nimport OrsMatrix from './OrsMatrix.js'\nimport OrsDirections from './OrsDirections.js'\nimport OrsPois from './OrsPois.js'\nimport OrsElevation from './OrsElevation.js'\nimport OrsOptimization from './OrsOptimization.js'\nimport OrsSnap from './OrsSnap.js';\n\nconst Openrouteservice = {\n Geocode: OrsGeocode,\n Isochrones: OrsIsochrones,\n Directions: OrsDirections,\n Matrix: OrsMatrix,\n Pois: OrsPois,\n Elevation: OrsElevation,\n Optimization: OrsOptimization,\n Snap: OrsSnap\n}\n\n// Define Openrouteservice for Node module pattern loaders, including Browserify\nif (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = Openrouteservice\n // define Openrouteservice as an AMD module\n // eslint-disable-next-line no-undef\n} else if (typeof define === 'function' && define.amd) {\n // eslint-disable-next-line no-undef\n define(Openrouteservice)\n}\n\nif (typeof window !== 'undefined') {\n window.Openrouteservice = Openrouteservice\n}\n\nexport default Openrouteservice\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsIsochrones extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs.service = 'isochrones'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n const options = {}\n\n if (args.restrictions) {\n options.profile_params = {\n restrictions: {\n ...args.restrictions\n }\n }\n delete args.restrictions\n }\n if (args.avoidables) {\n options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n\n if (args.avoid_polygons) {\n options.avoid_polygons = {\n ...args.avoid_polygons\n }\n delete args.avoid_polygons\n }\n\n if (Object.keys(options).length > 0) {\n return {\n ...args,\n options: options\n }\n } else {\n return {\n ...args\n }\n }\n }\n}\n\nexport default OrsIsochrones\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsDirections extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'directions'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsDirections\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsMatrix extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'matrix'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsMatrix\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsSnap extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'snap'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsSnap\n"],"names":["constants","defaultAPIVersion","defaultHost","missingAPIKeyMsg","baseUrlConstituents","propNames","apiKey","host","service","apiVersion","mimeType","profile","format","timeout","OrsUtil","fillArgs","defaultArgs","requestArgs","saveArgsToCache","args","Constants","api_version","api_key","mime_type","prepareRequest","prepareUrl","url","urlPathParts","join","replace","slice","orsUtil","OrsBase","constructor","this","argsCache","customHeaders","_setRequestDefaults","console","error","Error","checkHeaders","fetchRequest","body","controller","indexOf","authorization","Authorization","fetch","method","JSON","stringify","headers","signal","createRequest","AbortController","setTimeout","abort","orsResponse","ok","statusText","status","response","_a","text","json","clearTimeout","getBody","httpArgs","calculate","reqArgs","postBody","Openrouteservice","Geocode","super","lookupParameter","key","val","encodeURIComponent","focus_point","urlParams","boundary_bbox","point","Array","isArray","lat_lng","boundary_circle","radius","sources","Number","layers","counter","boundary_country","size","address","neighbourhood","borough","locality","county","region","postalcode","country","getParametersAsQueryString","queryString","fetchGetRequest","geocodePromise","geocode","reverseGeocode","structuredGeocode","Isochrones","options","restrictions","profile_params","avoidables","avoid_features","avoid_polygons","Object","keys","length","Directions","parse","Matrix","Pois","generatePayload","payload","poisPromise","request","pois","Elevation","elevationPromise","lineElevation","pointElevation","Optimization","optimizationPromise","optimize","Snap","module","exports","define","amd","window"],"mappings":"aAAA,MAAMA,EAAY,CAChBC,kBAAmB,KACnBC,YAAa,mCACbC,iBAAkB,6CAClBC,oBAAqB,CAAC,OAAQ,UAAW,cAAe,aACxDC,UAAW,CACTC,OAAQ,UACRC,KAAM,OACNC,QAAS,UACTC,WAAY,cACZC,SAAU,YACVC,QAAS,UACTC,OAAQ,SACRC,QAAS,YCZb,MAAMC,EACJ,QAAAC,CAASC,EAAaC,GAEb,OADPA,EAAc,IAAID,KAAgBC,EAEnC,CAED,eAAAC,CAA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UG,SAAW,mBAElD0B,KAAKjB,YAAcc,EAAQhB,SAASmB,KAAKlB,YAAakB,KAAKjB,mBAE9CiB,KAAK+F,kBACnB,GElCDG,aDVF,cAA8BpG,EAC5B,eAAA2F,CAAgBxG,GACd,IAAIyG,EAAU,CAAE,EAEhB,IAAA,MAAWhD,KAAOzD,EACZC,EAAUhB,oBAAoByC,QAAQ+B,KAAY,IAC5CgD,EAAAhD,GAAOzD,EAAKyD,IAGjB,OAAAgD,CACR,CAED,yBAAMS,GACJnG,KAAKC,UAAYJ,EAAQb,gBAAgBgB,KAAKjB,aAE9C,MAAM2G,EAAU1F,KAAKyF,gBAAgBzF,KAAKjB,aAEnC,aAAMiB,KAAKoB,cAAcsE,EACjC,CAED,cAAMU,CAAShE,GAUN,OATPpC,KAAKjB,YAAcqD,EAEnBpC,KAAKO,eAEAP,KAAKlB,YAAYI,EAAUf,UAAUG,UAAa8D,EAAQlD,EAAUf,UAAUG,WACzEY,EAAAA,EAAUf,UAAUG,SAAW,gBAEzC0B,KAAKjB,YAAcc,EAAQhB,SAASmB,KAAKlB,YAAakB,KAAKjB,mBAE9CiB,KAAKmG,qBACnB,GCpBDE,KIdF,cAAsBvG,EAClB,WAAAC,CAAYd,GACRuD,MAAMvD,GACDe,KAAKlB,YAAYI,EAAUf,UAAUG,UAAa0B,KAAKjB,YAAYG,EAAUf,UAAUG,WACxF0B,KAAKlB,YAAYI,EAAUf,UAAUG,SAAW,QAE/CW,EAAKC,EAAUf,UAAUI,cACrByB,KAAAlB,YAAYK,YAAcD,EAAUnB,kBAEhD,IJSiB,iBAAXuI,QAAiD,iBAAnBA,OAAOC,QAC9CD,OAAOC,QAAUjE,EAGU,mBAAXkE,QAAyBA,OAAOC,KAEhDD,OAAOlE,GAGa,oBAAXoE,SACTA,OAAOpE,iBAAmBA"} \ No newline at end of file diff --git a/dist/ors-js-client.js b/dist/ors-js-client.js index 499ae27..88f828f 100644 --- a/dist/ors-js-client.js +++ b/dist/ors-js-client.js @@ -41,6 +41,11 @@ class OrsUtil { delete args[constants.propNames.timeout]; return { ...args }; } + /** + * Prepare the request url based on url constituents + * @param {Object} args + * @return {string} url + */ prepareUrl(args) { let url = args[constants.propNames.host]; let urlPathParts = [ @@ -71,6 +76,10 @@ class OrsBase { this.customHeaders = {}; this._setRequestDefaults(args); } + /** + * Set defaults for a request comparing with and overwriting default class arguments + * @param {Object} args - constructor input + */ _setRequestDefaults(args) { this.defaultArgs[constants.propNames.host] = constants.defaultHost; if (args[constants.propNames.host]) { @@ -81,7 +90,7 @@ class OrsBase { } if (constants.propNames.apiKey in args) { this.defaultArgs[constants.propNames.apiKey] = args[constants.propNames.apiKey]; - } else { + } else if (!args[constants.propNames.host]) { console.error(constants.missingAPIKeyMsg); throw new Error(constants.missingAPIKeyMsg); } @@ -125,6 +134,7 @@ class OrsBase { clearTimeout(timeout); } } + // is overridden in Directions and Isochrones class getBody() { return this.httpArgs; } @@ -476,31 +486,13 @@ class OrsOptimization extends OrsBase { class OrsSnap extends OrsBase { constructor(args) { super(args); - if (!this.defaultArgs[constants.propNames.service]) { + if (!this.defaultArgs[constants.propNames.service] && !this.requestArgs[constants.propNames.service]) { this.defaultArgs[constants.propNames.service] = "snap"; } if (!args[constants.propNames.apiVersion]) { this.defaultArgs.api_version = constants.defaultAPIVersion; } } - getBody(args) { - if (args.options && typeof args.options !== "object") { - args.options = JSON.parse(args.options); - } - if (args.restrictions) { - args.options = args.options || {}; - args.options.profile_params = { - restrictions: { ...args.restrictions } - }; - delete args.restrictions; - } - if (args.avoidables) { - args.options = args.options || {}; - args.options.avoid_features = [...args.avoidables]; - delete args.avoidables; - } - return args; - } } const Openrouteservice = { Geocode: OrsGeocode, diff --git a/dist/ors-js-client.js.map b/dist/ors-js-client.js.map index b9d8bfd..33b5b57 100644 --- a/dist/ors-js-client.js.map +++ b/dist/ors-js-client.js.map @@ -1 +1 @@ -{"version":3,"file":"ors-js-client.js","sources":["../src/constants.js","../src/OrsUtil.js","../src/OrsBase.js","../src/OrsGeocode.js","../src/OrsIsochrones.js","../src/OrsMatrix.js","../src/OrsDirections.js","../src/OrsPois.js","../src/OrsElevation.js","../src/OrsOptimization.js","../src/OrsSnap.js","../src/index.js"],"sourcesContent":["const constants = {\n defaultAPIVersion: 'v2',\n defaultHost: 'https://api.openrouteservice.org',\n missingAPIKeyMsg: 'Please add your openrouteservice api_key..',\n baseUrlConstituents: ['host', 'service', 'api_version', 'mime_type'],\n propNames: {\n apiKey: 'api_key',\n host: 'host',\n service: 'service',\n apiVersion: 'api_version',\n mimeType: 'mime_type',\n profile: 'profile',\n format: 'format',\n timeout: 'timeout'\n }\n}\n\nexport default constants\n","import Constants from './constants.js'\nclass OrsUtil {\n fillArgs(defaultArgs, requestArgs) {\n requestArgs = {...defaultArgs, ...requestArgs}\n return requestArgs\n }\n\n saveArgsToCache(args) {\n return {\n host: args[Constants.propNames.host],\n api_version: args[Constants.propNames.apiVersion],\n profile: args[Constants.propNames.profile],\n format: args[Constants.propNames.format],\n service: args[Constants.propNames.service],\n api_key: args[Constants.propNames.apiKey],\n mime_type: args[Constants.propNames.mimeType]\n }\n }\n\n prepareRequest(args) {\n delete args[Constants.propNames.mimeType]\n delete args[Constants.propNames.host]\n delete args[Constants.propNames.apiVersion]\n delete args[Constants.propNames.service]\n delete args[Constants.propNames.apiKey]\n delete args[Constants.propNames.profile]\n delete args[Constants.propNames.format]\n delete args[Constants.propNames.timeout]\n return { ...args }\n }\n\n /**\n * Prepare the request url based on url constituents\n * @param {Object} args\n * @return {string} url\n */\n prepareUrl(args) {\n let url = args[Constants.propNames.host]\n let urlPathParts = [\n args[Constants.propNames.apiVersion],\n args[Constants.propNames.service],\n args[Constants.propNames.profile],\n args[Constants.propNames.format]\n ]\n\n urlPathParts = urlPathParts.join('/')\n urlPathParts = urlPathParts.replace(/\\/(\\/)+/g, '/')\n\n // The beginning and end of urlPathParts can not be a slash\n if (urlPathParts[0] === '/') {\n urlPathParts = urlPathParts.slice(1)\n }\n let end = urlPathParts.slice(-1)\n if (end[0] === '/') {\n urlPathParts = urlPathParts.slice(0, -1)\n }\n\n url = url + '/' + urlPathParts\n\n return url\n }\n}\n\nexport default OrsUtil\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsBase {\n constructor(args) {\n this.defaultArgs = {}\n this.requestArgs = {}\n this.argsCache = null\n this.customHeaders = {}\n\n this._setRequestDefaults(args)\n }\n\n /**\n * Set defaults for a request comparing with and overwriting default class arguments\n * @param {Object} args - constructor input\n */\n _setRequestDefaults(args) {\n this.defaultArgs[Constants.propNames.host] = Constants.defaultHost\n if (args[Constants.propNames.host]) {\n this.defaultArgs[Constants.propNames.host] = args[Constants.propNames.host]\n }\n if (args[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]\n }\n if (Constants.propNames.apiKey in args) {\n this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]\n } else {\n // eslint-disable-next-line no-console\n console.error(Constants.missingAPIKeyMsg)\n throw new Error(Constants.missingAPIKeyMsg)\n }\n\n }\n\n checkHeaders() {\n // Get custom header and remove from args\n if (this.requestArgs.customHeaders) {\n this.customHeaders = this.requestArgs.customHeaders\n delete this.requestArgs.customHeaders\n }\n // set default Content-type, since Postman sets Content-type to text/plain if not specified\n if (!('Content-type' in this.customHeaders)) {\n this.customHeaders = {...this.customHeaders, 'Content-type': 'application/json'}\n }\n }\n\n async fetchRequest(body, controller) {\n let url = orsUtil.prepareUrl(this.argsCache)\n if (this.argsCache[Constants.propNames.service] === 'pois') {\n url += url.indexOf('?') > -1 ? '&' : '?'\n }\n\n const authorization = {'Authorization': this.argsCache[Constants.propNames.apiKey]}\n\n return await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: {...authorization, ...this.customHeaders},\n signal: controller.signal\n })\n }\n\n async createRequest(body) {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchRequest(body, controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return this.argsCache?.format === 'gpx' ? await orsResponse.text() : await orsResponse.json()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n // is overidden in Directions and Isochrones class\n getBody() {\n return this.httpArgs;\n }\n\n async calculate(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n this.httpArgs = orsUtil.prepareRequest(this.requestArgs)\n const postBody = this.getBody(this.httpArgs)\n\n return await this.createRequest(postBody)\n }\n}\n\nexport default OrsBase\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsGeocode extends OrsBase {\n constructor(args) {\n super(args)\n\n this.lookupParameter = {\n api_key: function(key, val) {\n return key + '=' + val\n },\n text: function(key, val) {\n return '&' + key + '=' + encodeURIComponent(val)\n },\n focus_point: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'focus.point.lon' + '=' + val[1]\n urlParams += '&' + 'focus.point.lat' + '=' + val[0]\n return urlParams\n },\n boundary_bbox: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.rect.min_lon' + '=' + val[0][1]\n urlParams += '&' + 'boundary.rect.min_lat' + '=' + val[0][0]\n urlParams += '&' + 'boundary.rect.max_lon' + '=' + val[1][1]\n urlParams += '&' + 'boundary.rect.max_lat' + '=' + val[1][0]\n\n return urlParams\n },\n point: function(key, val) {\n if (val && Array.isArray(val.lat_lng)) {\n let urlParams = ''\n urlParams += '&' + 'point.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'point.lat' + '=' + val.lat_lng[0]\n return urlParams\n }\n },\n boundary_circle: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.circle.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'boundary.circle.lat' + '=' + val.lat_lng[0]\n urlParams += '&' + 'boundary.circle.radius' + '=' + val.radius\n\n return urlParams\n },\n sources: function(key, val) {\n let urlParams = '&sources='\n if (val) {\n for (const key in val) {\n if (Number(key) > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n }\n return urlParams\n }\n },\n layers: function(key, val) {\n let urlParams = '&layers='\n let counter = 0\n for (key in val) {\n if (counter > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n counter++\n }\n return urlParams\n },\n boundary_country: function(key, val) {\n return '&' + 'boundary.country' + '=' + val\n },\n size: function(key, val) {\n return '&' + key + '=' + val\n },\n address: function(key, val) {\n return '&' + key + '=' + val\n },\n neighbourhood: function(key, val) {\n return '&' + key + '=' + val\n },\n borough: function(key, val) {\n return '&' + key + '=' + val\n },\n locality: function(key, val) {\n return '&' + key + '=' + val\n },\n county: function(key, val) {\n return '&' + key + '=' + val\n },\n region: function(key, val) {\n return '&' + key + '=' + val\n },\n postalcode: function(key, val) {\n return '&' + key + '=' + val\n },\n country: function(key, val) {\n return '&' + key + '=' + val\n }\n }\n }\n\n getParametersAsQueryString(args) {\n let queryString = ''\n for (const key in args) {\n const val = args[key]\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n queryString += this.lookupParameter[key](key, val)\n }\n }\n return queryString\n }\n\n async fetchGetRequest(controller) {\n let url = orsUtil.prepareUrl(this.requestArgs)\n // Add url query string from args\n url += '?' + this.getParametersAsQueryString(this.requestArgs)\n\n // createRequest function from base class is not applicable: GET instead of POST request\n return await fetch(url, {\n method: 'GET',\n headers: this.customHeaders,\n signal: controller.signal\n })\n }\n\n async geocodePromise() {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchGetRequest(controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return await orsResponse.json() || orsResponse.text()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n async geocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async reverseGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/reverse'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async structuredGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search/structured'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n}\n\nexport default OrsGeocode\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsIsochrones extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs.service = 'isochrones'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n const options = {}\n\n if (args.restrictions) {\n options.profile_params = {\n restrictions: {\n ...args.restrictions\n }\n }\n delete args.restrictions\n }\n if (args.avoidables) {\n options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n\n if (args.avoid_polygons) {\n options.avoid_polygons = {\n ...args.avoid_polygons\n }\n delete args.avoid_polygons\n }\n\n if (Object.keys(options).length > 0) {\n return {\n ...args,\n options: options\n }\n } else {\n return {\n ...args\n }\n }\n }\n}\n\nexport default OrsIsochrones\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsMatrix extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'matrix'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsMatrix\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsDirections extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'directions'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsDirections\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsPois extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'pois'\n }\n }\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (\n !(\n Constants.baseUrlConstituents.indexOf(key) > -1 ||\n key === Constants.propNames.apiKey ||\n key === Constants.propNames.timeout\n )\n ) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async poisPromise() {\n // the request arg is required by the API as part of the body\n this.requestArgs.request = this.requestArgs.request || 'pois'\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n if (this.requestArgs[Constants.propNames.service]) {\n delete this.requestArgs[Constants.propNames.service]\n }\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async pois(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.poisPromise()\n }\n}\n\nexport default OrsPois\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\nclass OrsElevation extends OrsBase {\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async elevationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async lineElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/line'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n\n async pointElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/point'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n}\n\nexport default OrsElevation\n","import OrsUtil from \"./OrsUtil.js\"\nimport Constants from \"./constants.js\"\nimport OrsBase from \"./OrsBase.js\"\n\nconst orsUtil = new OrsUtil()\n\nclass OrsOptimization extends OrsBase {\n generatePayload(args) {\n let payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async optimizationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async optimize(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !reqArgs[Constants.propNames.service]) {\n reqArgs[Constants.propNames.service] = 'optimization'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.optimizationPromise()\n }\n}\n\nexport default OrsOptimization\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsSnap extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'snap'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsSnap\n","import OrsGeocode from './OrsGeocode.js'\nimport OrsIsochrones from './OrsIsochrones.js'\nimport OrsMatrix from './OrsMatrix.js'\nimport OrsDirections from './OrsDirections.js'\nimport OrsPois from './OrsPois.js'\nimport OrsElevation from './OrsElevation.js'\nimport OrsOptimization from './OrsOptimization.js'\nimport OrsSnap from './OrsSnap.js';\n\nconst Openrouteservice = {\n Geocode: OrsGeocode,\n Isochrones: OrsIsochrones,\n Directions: OrsDirections,\n Matrix: OrsMatrix,\n Pois: OrsPois,\n Elevation: OrsElevation,\n Optimization: OrsOptimization,\n Snap: OrsSnap\n}\n\n// Define Openrouteservice for Node module pattern loaders, including Browserify\nif (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = Openrouteservice\n // define Openrouteservice as an AMD module\n // eslint-disable-next-line no-undef\n} else if (typeof define === 'function' && define.amd) {\n // eslint-disable-next-line no-undef\n define(Openrouteservice)\n}\n\nif (typeof window !== 'undefined') {\n window.Openrouteservice = Openrouteservice\n}\n\nexport default Openrouteservice\n"],"names":["Constants","orsUtil","key"],"mappings":"AAAA,MAAM,YAAY;AAAA,EAChB,mBAAmB;AAAA,EACnB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,qBAAqB,CAAC,QAAQ,WAAW,eAAe,WAAW;AAAA,EACnE,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,EACV;AACH;ACdA,MAAM,QAAQ;AAAA,EACZ,SAAS,aAAa,aAAa;AACjC,kBAAc,EAAC,GAAG,aAAa,GAAG,YAAW;AAC7C,WAAO;AAAA,EACR;AAAA,EAED,gBAAgB,MAAM;AACpB,WAAO;AAAA,MACL,MAAM,KAAKA,UAAU,UAAU;AAAA,MAC/B,aAAa,KAAKA,UAAU,UAAU;AAAA,MACtC,SAAS,KAAKA,UAAU,UAAU;AAAA,MAClC,QAAQ,KAAKA,UAAU,UAAU;AAAA,MACjC,SAAS,KAAKA,UAAU,UAAU;AAAA,MAClC,SAAS,KAAKA,UAAU,UAAU;AAAA,MAClC,WAAW,KAAKA,UAAU,UAAU;AAAA,IACrC;AAAA,EACF;AAAA,EAED,eAAe,MAAM;AACnB,WAAO,KAAKA,UAAU,UAAU;AAChC,WAAO,KAAKA,UAAU,UAAU;AAChC,WAAO,KAAKA,UAAU,UAAU;AAChC,WAAO,KAAKA,UAAU,UAAU;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;AAAA,IACf;AACD,WAAO;AAAA,EACV;AACL;ACzBK,MAAC,mBAAmB;AAAA,EACvB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AAAA,EACX,cAAc;AAAA,EACd,MAAM;AACR;AAGA,IAAI,OAAO,WAAW,YAAY,OAAO,OAAO,YAAY,UAAU;AACpE,SAAO,UAAU;AAGnB,WAAW,OAAO,WAAW,cAAc,OAAO,KAAK;AAErD,SAAO,gBAAgB;AACzB;AAEA,IAAI,OAAO,WAAW,aAAa;AACjC,SAAO,mBAAmB;AAC5B;"} \ No newline at end of file +{"version":3,"file":"ors-js-client.js","sources":["../src/constants.js","../src/OrsUtil.js","../src/OrsBase.js","../src/OrsGeocode.js","../src/OrsIsochrones.js","../src/OrsMatrix.js","../src/OrsDirections.js","../src/OrsPois.js","../src/OrsElevation.js","../src/OrsOptimization.js","../src/OrsSnap.js","../src/index.js"],"sourcesContent":["const constants = {\n defaultAPIVersion: 'v2',\n defaultHost: 'https://api.openrouteservice.org',\n missingAPIKeyMsg: 'Please add your openrouteservice api_key..',\n baseUrlConstituents: ['host', 'service', 'api_version', 'mime_type'],\n propNames: {\n apiKey: 'api_key',\n host: 'host',\n service: 'service',\n apiVersion: 'api_version',\n mimeType: 'mime_type',\n profile: 'profile',\n format: 'format',\n timeout: 'timeout'\n }\n}\n\nexport default constants\n","import Constants from './constants.js'\nclass OrsUtil {\n fillArgs(defaultArgs, requestArgs) {\n requestArgs = {...defaultArgs, ...requestArgs}\n return requestArgs\n }\n\n saveArgsToCache(args) {\n return {\n host: args[Constants.propNames.host],\n api_version: args[Constants.propNames.apiVersion],\n profile: args[Constants.propNames.profile],\n format: args[Constants.propNames.format],\n service: args[Constants.propNames.service],\n api_key: args[Constants.propNames.apiKey],\n mime_type: args[Constants.propNames.mimeType]\n }\n }\n\n prepareRequest(args) {\n delete args[Constants.propNames.mimeType]\n delete args[Constants.propNames.host]\n delete args[Constants.propNames.apiVersion]\n delete args[Constants.propNames.service]\n delete args[Constants.propNames.apiKey]\n delete args[Constants.propNames.profile]\n delete args[Constants.propNames.format]\n delete args[Constants.propNames.timeout]\n return { ...args }\n }\n\n /**\n * Prepare the request url based on url constituents\n * @param {Object} args\n * @return {string} url\n */\n prepareUrl(args) {\n let url = args[Constants.propNames.host]\n let urlPathParts = [\n args[Constants.propNames.apiVersion],\n args[Constants.propNames.service],\n args[Constants.propNames.profile],\n args[Constants.propNames.format]\n ]\n\n urlPathParts = urlPathParts.join('/')\n urlPathParts = urlPathParts.replace(/\\/(\\/)+/g, '/')\n\n // The beginning and end of urlPathParts can not be a slash\n if (urlPathParts[0] === '/') {\n urlPathParts = urlPathParts.slice(1)\n }\n let end = urlPathParts.slice(-1)\n if (end[0] === '/') {\n urlPathParts = urlPathParts.slice(0, -1)\n }\n\n url = url + '/' + urlPathParts\n\n return url\n }\n}\n\nexport default OrsUtil\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsBase {\n constructor(args) {\n this.defaultArgs = {}\n this.requestArgs = {}\n this.argsCache = null\n this.customHeaders = {}\n\n this._setRequestDefaults(args)\n }\n\n /**\n * Set defaults for a request comparing with and overwriting default class arguments\n * @param {Object} args - constructor input\n */\n _setRequestDefaults(args) {\n this.defaultArgs[Constants.propNames.host] = Constants.defaultHost\n if (args[Constants.propNames.host]) {\n this.defaultArgs[Constants.propNames.host] = args[Constants.propNames.host]\n }\n if (args[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]\n }\n if (Constants.propNames.apiKey in args) {\n this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]\n } else if (!args[Constants.propNames.host]) {\n // Do not error if a host is specified; useful for locally-run instances of ORS\n console.error(Constants.missingAPIKeyMsg)\n throw new Error(Constants.missingAPIKeyMsg)\n }\n\n }\n\n checkHeaders() {\n // Get custom header and remove from args\n if (this.requestArgs.customHeaders) {\n this.customHeaders = this.requestArgs.customHeaders\n delete this.requestArgs.customHeaders\n }\n // set default Content-type, since Postman sets Content-type to text/plain if not specified\n if (!('Content-type' in this.customHeaders)) {\n this.customHeaders = {...this.customHeaders, 'Content-type': 'application/json'}\n }\n }\n\n async fetchRequest(body, controller) {\n let url = orsUtil.prepareUrl(this.argsCache)\n if (this.argsCache[Constants.propNames.service] === 'pois') {\n url += url.indexOf('?') > -1 ? '&' : '?'\n }\n\n const authorization = {'Authorization': this.argsCache[Constants.propNames.apiKey]}\n\n return await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: {...authorization, ...this.customHeaders},\n signal: controller.signal\n })\n }\n\n async createRequest(body) {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchRequest(body, controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return this.argsCache?.format === 'gpx' ? await orsResponse.text() : await orsResponse.json()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n // is overridden in Directions and Isochrones class\n getBody() {\n return this.httpArgs;\n }\n\n async calculate(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n this.httpArgs = orsUtil.prepareRequest(this.requestArgs)\n const postBody = this.getBody(this.httpArgs)\n\n return await this.createRequest(postBody)\n }\n}\n\nexport default OrsBase\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsGeocode extends OrsBase {\n constructor(args) {\n super(args)\n\n this.lookupParameter = {\n api_key: function(key, val) {\n return key + '=' + val\n },\n text: function(key, val) {\n return '&' + key + '=' + encodeURIComponent(val)\n },\n focus_point: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'focus.point.lon' + '=' + val[1]\n urlParams += '&' + 'focus.point.lat' + '=' + val[0]\n return urlParams\n },\n boundary_bbox: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.rect.min_lon' + '=' + val[0][1]\n urlParams += '&' + 'boundary.rect.min_lat' + '=' + val[0][0]\n urlParams += '&' + 'boundary.rect.max_lon' + '=' + val[1][1]\n urlParams += '&' + 'boundary.rect.max_lat' + '=' + val[1][0]\n\n return urlParams\n },\n point: function(key, val) {\n if (val && Array.isArray(val.lat_lng)) {\n let urlParams = ''\n urlParams += '&' + 'point.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'point.lat' + '=' + val.lat_lng[0]\n return urlParams\n }\n },\n boundary_circle: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.circle.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'boundary.circle.lat' + '=' + val.lat_lng[0]\n urlParams += '&' + 'boundary.circle.radius' + '=' + val.radius\n\n return urlParams\n },\n sources: function(key, val) {\n let urlParams = '&sources='\n if (val) {\n for (const key in val) {\n if (Number(key) > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n }\n return urlParams\n }\n },\n layers: function(key, val) {\n let urlParams = '&layers='\n let counter = 0\n for (key in val) {\n if (counter > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n counter++\n }\n return urlParams\n },\n boundary_country: function(key, val) {\n return '&' + 'boundary.country' + '=' + val\n },\n size: function(key, val) {\n return '&' + key + '=' + val\n },\n address: function(key, val) {\n return '&' + key + '=' + val\n },\n neighbourhood: function(key, val) {\n return '&' + key + '=' + val\n },\n borough: function(key, val) {\n return '&' + key + '=' + val\n },\n locality: function(key, val) {\n return '&' + key + '=' + val\n },\n county: function(key, val) {\n return '&' + key + '=' + val\n },\n region: function(key, val) {\n return '&' + key + '=' + val\n },\n postalcode: function(key, val) {\n return '&' + key + '=' + val\n },\n country: function(key, val) {\n return '&' + key + '=' + val\n }\n }\n }\n\n getParametersAsQueryString(args) {\n let queryString = ''\n for (const key in args) {\n const val = args[key]\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n queryString += this.lookupParameter[key](key, val)\n }\n }\n return queryString\n }\n\n async fetchGetRequest(controller) {\n let url = orsUtil.prepareUrl(this.requestArgs)\n // Add url query string from args\n url += '?' + this.getParametersAsQueryString(this.requestArgs)\n\n // createRequest function from base class is not applicable: GET instead of POST request\n return await fetch(url, {\n method: 'GET',\n headers: this.customHeaders,\n signal: controller.signal\n })\n }\n\n async geocodePromise() {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchGetRequest(controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return await orsResponse.json() || orsResponse.text()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n async geocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async reverseGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/reverse'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async structuredGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search/structured'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n}\n\nexport default OrsGeocode\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsIsochrones extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs.service = 'isochrones'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n const options = {}\n\n if (args.restrictions) {\n options.profile_params = {\n restrictions: {\n ...args.restrictions\n }\n }\n delete args.restrictions\n }\n if (args.avoidables) {\n options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n\n if (args.avoid_polygons) {\n options.avoid_polygons = {\n ...args.avoid_polygons\n }\n delete args.avoid_polygons\n }\n\n if (Object.keys(options).length > 0) {\n return {\n ...args,\n options: options\n }\n } else {\n return {\n ...args\n }\n }\n }\n}\n\nexport default OrsIsochrones\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsMatrix extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'matrix'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsMatrix\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsDirections extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'directions'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsDirections\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsPois extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'pois'\n }\n }\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (\n !(\n Constants.baseUrlConstituents.indexOf(key) > -1 ||\n key === Constants.propNames.apiKey ||\n key === Constants.propNames.timeout\n )\n ) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async poisPromise() {\n // the request arg is required by the API as part of the body\n this.requestArgs.request = this.requestArgs.request || 'pois'\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n if (this.requestArgs[Constants.propNames.service]) {\n delete this.requestArgs[Constants.propNames.service]\n }\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async pois(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.poisPromise()\n }\n}\n\nexport default OrsPois\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\nclass OrsElevation extends OrsBase {\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async elevationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async lineElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/line'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n\n async pointElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/point'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n}\n\nexport default OrsElevation\n","import OrsUtil from \"./OrsUtil.js\"\nimport Constants from \"./constants.js\"\nimport OrsBase from \"./OrsBase.js\"\n\nconst orsUtil = new OrsUtil()\n\nclass OrsOptimization extends OrsBase {\n generatePayload(args) {\n let payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async optimizationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async optimize(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !reqArgs[Constants.propNames.service]) {\n reqArgs[Constants.propNames.service] = 'optimization'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.optimizationPromise()\n }\n}\n\nexport default OrsOptimization\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsSnap extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'snap'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsSnap\n","import OrsGeocode from './OrsGeocode.js'\nimport OrsIsochrones from './OrsIsochrones.js'\nimport OrsMatrix from './OrsMatrix.js'\nimport OrsDirections from './OrsDirections.js'\nimport OrsPois from './OrsPois.js'\nimport OrsElevation from './OrsElevation.js'\nimport OrsOptimization from './OrsOptimization.js'\nimport OrsSnap from './OrsSnap.js';\n\nconst Openrouteservice = {\n Geocode: OrsGeocode,\n Isochrones: OrsIsochrones,\n Directions: OrsDirections,\n Matrix: OrsMatrix,\n Pois: OrsPois,\n Elevation: OrsElevation,\n Optimization: OrsOptimization,\n Snap: OrsSnap\n}\n\n// Define Openrouteservice for Node module pattern loaders, including Browserify\nif (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = Openrouteservice\n // define Openrouteservice as an AMD module\n // eslint-disable-next-line no-undef\n} else if (typeof define === 'function' && define.amd) {\n // eslint-disable-next-line no-undef\n define(Openrouteservice)\n}\n\nif (typeof window !== 'undefined') {\n window.Openrouteservice = Openrouteservice\n}\n\nexport default Openrouteservice\n"],"names":["Constants","orsUtil","key"],"mappings":"AAAA,MAAM,YAAY;AAAA,EAChB,mBAAmB;AAAA,EACnB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,qBAAqB,CAAC,QAAQ,WAAW,eAAe,WAAW;AAAA,EACnE,WAAW;AAAA,IACT,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,SAAS;AAAA,EACV;AACH;ACdA,MAAM,QAAQ;AAAA,EACZ,SAAS,aAAa,aAAa;AACjC,kBAAc,EAAC,GAAG,aAAa,GAAG,YAAW;AAC7C,WAAO;AAAA,EACR;AAAA,EAED,gBAAgB,MAAM;AACpB,WAAO;AAAA,MACL,MAAM,KAAKA,UAAU,UAAU,IAAI;AAAA,MACnC,aAAa,KAAKA,UAAU,UAAU,UAAU;AAAA,MAChD,SAAS,KAAKA,UAAU,UAA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c;AAEnB,QAAI,CAAC,KAAK,YAAYA,UAAU,UAAU,OAAO,KAAK,CAAC,QAAQA,UAAU,UAAU,OAAO,GAAG;AAC3F,cAAQA,UAAU,UAAU,OAAO,IAAI;AAAA,IACxC;AACD,SAAK,cAAc,QAAQ,SAAS,KAAK,aAAa,KAAK,WAAW;AAEtE,WAAO,MAAM,KAAK,oBAAqB;AAAA,EACxC;AACH;ACnCA,MAAM,gBAAgB,QAAQ;AAAA,EAC1B,YAAY,MAAM;AACd,UAAM,IAAI;AACV,QAAI,CAAC,KAAK,YAAYA,UAAU,UAAU,OAAO,KAAK,CAAC,KAAK,YAAYA,UAAU,UAAU,OAAO,GAAG;AAClG,WAAK,YAAYA,UAAU,UAAU,OAAO,IAAI;AAAA,IACnD;AACD,QAAI,CAAC,KAAKA,UAAU,UAAU,UAAU,GAAG;AACvC,WAAK,YAAY,cAAcA,UAAU;AAAA,IAC5C;AAAA,EACJ;AACL;ACJK,MAAC,mBAAmB;AAAA,EACvB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,WAAW;AAAA,EACX,cAAc;AAAA,EACd,MAAM;AACR;AAGA,IAAI,OAAO,WAAW,YAAY,OAAO,OAAO,YAAY,UAAU;AACpE,SAAO,UAAU;AAGnB,WAAW,OAAO,WAAW,cAAc,OAAO,KAAK;AAErD,SAAO,gBAAgB;AACzB;AAEA,IAAI,OAAO,WAAW,aAAa;AACjC,SAAO,mBAAmB;AAC5B;"} \ No newline at end of file diff --git a/dist/ors-js-client.umd.cjs b/dist/ors-js-client.umd.cjs index 55bc635..6b541e5 100644 --- a/dist/ors-js-client.umd.cjs +++ b/dist/ors-js-client.umd.cjs @@ -1,2 +1,2 @@ -!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(e="undefined"!=typeof globalThis?globalThis:e||self).OrsJsClient=s()}(this,(function(){"use strict";const e={defaultAPIVersion:"v2",defaultHost:"https://api.openrouteservice.org",missingAPIKeyMsg:"Please add your openrouteservice api_key..",baseUrlConstituents:["host","service","api_version","mime_type"],propNames:{apiKey:"api_key",host:"host",service:"service",apiVersion:"api_version",mimeType:"mime_type",profile:"profile",format:"format",timeout:"timeout"}};class s{fillArgs(e,s){return s={...e,...s}}saveArgsToCache(s){return{host:s[e.propNames.host],api_version:s[e.propNames.apiVersion],profile:s[e.propNames.profile],format:s[e.propNames.format],service:s[e.propNames.service],api_key:s[e.propNames.apiKey],mime_type:s[e.propNames.mimeType]}}prepareRequest(s){return delete s[e.propNames.mimeType],delete s[e.propNames.host],delete s[e.propNames.apiVersion],delete s[e.propNames.service],delete s[e.propNames.apiKey],delete s[e.propNames.profile],delete s[e.propNames.format],delete s[e.propNames.timeout],{...s}}prepareUrl(s){let t=s[e.propNames.host],r=[s[e.propNames.apiVersion],s[e.propNames.service],s[e.propNames.profile],s[e.propNames.format]];return r=r.join("/"),r=r.replace(/\/(\/)+/g,"/"),"/"===r[0]&&(r=r.slice(1)),"/"===r.slice(-1)[0]&&(r=r.slice(0,-1)),t=t+"/"+r,t}}const t=new s;class r{constructor(e){this.defaultArgs={},this.requestArgs={},this.argsCache=null,this.customHeaders={},this._setRequestDefaults(e)}_setRequestDefaults(s){if(this.defaultArgs[e.propNames.host]=e.defaultHost,s[e.propNames.host]&&(this.defaultArgs[e.propNames.host]=s[e.propNames.host]),s[e.propNames.service]&&(this.defaultArgs[e.propNames.service]=s[e.propNames.service]),!(e.propNames.apiKey in s))throw console.error(e.missingAPIKeyMsg),new Error(e.missingAPIKeyMsg);this.defaultArgs[e.propNames.apiKey]=s[e.propNames.apiKey]}checkHeaders(){this.requestArgs.customHeaders&&(this.customHeaders=this.requestArgs.customHeaders,delete this.requestArgs.customHeaders),"Content-type"in this.customHeaders||(this.customHeaders={...this.customHeaders,"Content-type":"application/json"})}async fetchRequest(s,r){let i=t.prepareUrl(this.argsCache);"pois"===this.argsCache[e.propNames.service]&&(i+=i.indexOf("?")>-1?"&":"?");const o={Authorization:this.argsCache[e.propNames.apiKey]};return await fetch(i,{method:"POST",body:JSON.stringify(s),headers:{...o,...this.customHeaders},signal:r.signal})}async createRequest(s){var t;const r=new AbortController,i=setTimeout((()=>r.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchRequest(s,r);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return"gpx"===(null==(t=this.argsCache)?void 0:t.format)?await e.text():await e.json()}finally{clearTimeout(i)}}getBody(){return this.httpArgs}async calculate(e){this.requestArgs=e,this.checkHeaders(),this.requestArgs=t.fillArgs(this.defaultArgs,this.requestArgs),this.argsCache=t.saveArgsToCache(this.requestArgs),this.httpArgs=t.prepareRequest(this.requestArgs);const s=this.getBody(this.httpArgs);return await this.createRequest(s)}}const i=new s;const o=new s;const a=new s;const n=new s;const p={Geocode:class extends r{constructor(e){super(e),this.lookupParameter={api_key:function(e,s){return e+"="+s},text:function(e,s){return"&"+e+"="+encodeURIComponent(s)},focus_point:function(e,s){let t="";return t+="&focus.point.lon="+s[1],t+="&focus.point.lat="+s[0],t},boundary_bbox:function(e,s){let t="";return t+="&boundary.rect.min_lon="+s[0][1],t+="&boundary.rect.min_lat="+s[0][0],t+="&boundary.rect.max_lon="+s[1][1],t+="&boundary.rect.max_lat="+s[1][0],t},point:function(e,s){if(s&&Array.isArray(s.lat_lng)){let e="";return e+="&point.lon="+s.lat_lng[1],e+="&point.lat="+s.lat_lng[0],e}},boundary_circle:function(e,s){let t="";return t+="&boundary.circle.lon="+s.lat_lng[1],t+="&boundary.circle.lat="+s.lat_lng[0],t+="&boundary.circle.radius="+s.radius,t},sources:function(e,s){let t="&sources=";if(s){for(const e in s)Number(e)>0&&(t+=","),t+=s[e];return t}},layers:function(e,s){let t="&layers=",r=0;for(e in s)r>0&&(t+=","),t+=s[e],r++;return t},boundary_country:function(e,s){return"&boundary.country="+s},size:function(e,s){return"&"+e+"="+s},address:function(e,s){return"&"+e+"="+s},neighbourhood:function(e,s){return"&"+e+"="+s},borough:function(e,s){return"&"+e+"="+s},locality:function(e,s){return"&"+e+"="+s},county:function(e,s){return"&"+e+"="+s},region:function(e,s){return"&"+e+"="+s},postalcode:function(e,s){return"&"+e+"="+s},country:function(e,s){return"&"+e+"="+s}}}getParametersAsQueryString(s){let t="";for(const r in s){const i=s[r];e.baseUrlConstituents.indexOf(r)<=-1&&(t+=this.lookupParameter[r](r,i))}return t}async fetchGetRequest(e){let s=i.prepareUrl(this.requestArgs);return s+="?"+this.getParametersAsQueryString(this.requestArgs),await fetch(s,{method:"GET",headers:this.customHeaders,signal:e.signal})}async geocodePromise(){const s=new AbortController,t=setTimeout((()=>s.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchGetRequest(s);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return await e.json()||e.text()}finally{clearTimeout(t)}}async geocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async reverseGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/reverse"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async structuredGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search/structured"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}},Isochrones:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs.service="isochrones"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){const s={};return e.restrictions&&(s.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(s.avoid_features=[...e.avoidables],delete e.avoidables),e.avoid_polygons&&(s.avoid_polygons={...e.avoid_polygons},delete e.avoid_polygons),Object.keys(s).length>0?{...e,options:s}:{...e}}},Directions:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="directions"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){return e.options&&"object"!=typeof e.options&&(e.options=JSON.parse(e.options)),e.restrictions&&(e.options=e.options||{},e.options.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(e.options=e.options||{},e.options.avoid_features=[...e.avoidables],delete e.avoidables),e}},Matrix:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="matrix"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}},Pois:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="pois")}generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)>-1||r===e.propNames.apiKey||r===e.propNames.timeout||(t[r]=s[r]);return t}async poisPromise(){this.requestArgs.request=this.requestArgs.request||"pois",this.argsCache=o.saveArgsToCache(this.requestArgs),this.requestArgs[e.propNames.service]&&delete this.requestArgs[e.propNames.service];const s=this.generatePayload(this.requestArgs);return await this.createRequest(s)}async pois(e){return this.requestArgs=e,this.checkHeaders(),this.requestArgs=o.fillArgs(this.defaultArgs,this.requestArgs),await this.poisPromise()}},Elevation:class extends r{generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async elevationPromise(){this.argsCache=a.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async lineElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/line"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}async pointElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/point"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}},Optimization:class extends r{generatePayload(s){let t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async optimizationPromise(){this.argsCache=n.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async optimize(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||s[e.propNames.service]||(s[e.propNames.service]="optimization"),this.requestArgs=n.fillArgs(this.defaultArgs,this.requestArgs),await this.optimizationPromise()}},Snap:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="snap"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){return e.options&&"object"!=typeof e.options&&(e.options=JSON.parse(e.options)),e.restrictions&&(e.options=e.options||{},e.options.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(e.options=e.options||{},e.options.avoid_features=[...e.avoidables],delete e.avoidables),e}}};return"object"==typeof module&&"object"==typeof module.exports?module.exports=p:"function"==typeof define&&define.amd&&define(p),"undefined"!=typeof window&&(window.Openrouteservice=p),p})); +!function(e,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):(e="undefined"!=typeof globalThis?globalThis:e||self).OrsJsClient=s()}(this,(function(){"use strict";const e={defaultAPIVersion:"v2",defaultHost:"https://api.openrouteservice.org",missingAPIKeyMsg:"Please add your openrouteservice api_key..",baseUrlConstituents:["host","service","api_version","mime_type"],propNames:{apiKey:"api_key",host:"host",service:"service",apiVersion:"api_version",mimeType:"mime_type",profile:"profile",format:"format",timeout:"timeout"}};class s{fillArgs(e,s){return s={...e,...s}}saveArgsToCache(s){return{host:s[e.propNames.host],api_version:s[e.propNames.apiVersion],profile:s[e.propNames.profile],format:s[e.propNames.format],service:s[e.propNames.service],api_key:s[e.propNames.apiKey],mime_type:s[e.propNames.mimeType]}}prepareRequest(s){return delete s[e.propNames.mimeType],delete s[e.propNames.host],delete s[e.propNames.apiVersion],delete s[e.propNames.service],delete s[e.propNames.apiKey],delete s[e.propNames.profile],delete s[e.propNames.format],delete s[e.propNames.timeout],{...s}}prepareUrl(s){let t=s[e.propNames.host],r=[s[e.propNames.apiVersion],s[e.propNames.service],s[e.propNames.profile],s[e.propNames.format]];return r=r.join("/"),r=r.replace(/\/(\/)+/g,"/"),"/"===r[0]&&(r=r.slice(1)),"/"===r.slice(-1)[0]&&(r=r.slice(0,-1)),t=t+"/"+r,t}}const t=new s;class r{constructor(e){this.defaultArgs={},this.requestArgs={},this.argsCache=null,this.customHeaders={},this._setRequestDefaults(e)}_setRequestDefaults(s){if(this.defaultArgs[e.propNames.host]=e.defaultHost,s[e.propNames.host]&&(this.defaultArgs[e.propNames.host]=s[e.propNames.host]),s[e.propNames.service]&&(this.defaultArgs[e.propNames.service]=s[e.propNames.service]),e.propNames.apiKey in s)this.defaultArgs[e.propNames.apiKey]=s[e.propNames.apiKey];else if(!s[e.propNames.host])throw console.error(e.missingAPIKeyMsg),new Error(e.missingAPIKeyMsg)}checkHeaders(){this.requestArgs.customHeaders&&(this.customHeaders=this.requestArgs.customHeaders,delete this.requestArgs.customHeaders),"Content-type"in this.customHeaders||(this.customHeaders={...this.customHeaders,"Content-type":"application/json"})}async fetchRequest(s,r){let i=t.prepareUrl(this.argsCache);"pois"===this.argsCache[e.propNames.service]&&(i+=i.indexOf("?")>-1?"&":"?");const o={Authorization:this.argsCache[e.propNames.apiKey]};return await fetch(i,{method:"POST",body:JSON.stringify(s),headers:{...o,...this.customHeaders},signal:r.signal})}async createRequest(s){var t;const r=new AbortController,i=setTimeout((()=>r.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchRequest(s,r);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return"gpx"===(null==(t=this.argsCache)?void 0:t.format)?await e.text():await e.json()}finally{clearTimeout(i)}}getBody(){return this.httpArgs}async calculate(e){this.requestArgs=e,this.checkHeaders(),this.requestArgs=t.fillArgs(this.defaultArgs,this.requestArgs),this.argsCache=t.saveArgsToCache(this.requestArgs),this.httpArgs=t.prepareRequest(this.requestArgs);const s=this.getBody(this.httpArgs);return await this.createRequest(s)}}const i=new s;const o=new s;const a=new s;const n=new s;const u={Geocode:class extends r{constructor(e){super(e),this.lookupParameter={api_key:function(e,s){return e+"="+s},text:function(e,s){return"&"+e+"="+encodeURIComponent(s)},focus_point:function(e,s){let t="";return t+="&focus.point.lon="+s[1],t+="&focus.point.lat="+s[0],t},boundary_bbox:function(e,s){let t="";return t+="&boundary.rect.min_lon="+s[0][1],t+="&boundary.rect.min_lat="+s[0][0],t+="&boundary.rect.max_lon="+s[1][1],t+="&boundary.rect.max_lat="+s[1][0],t},point:function(e,s){if(s&&Array.isArray(s.lat_lng)){let e="";return e+="&point.lon="+s.lat_lng[1],e+="&point.lat="+s.lat_lng[0],e}},boundary_circle:function(e,s){let t="";return t+="&boundary.circle.lon="+s.lat_lng[1],t+="&boundary.circle.lat="+s.lat_lng[0],t+="&boundary.circle.radius="+s.radius,t},sources:function(e,s){let t="&sources=";if(s){for(const e in s)Number(e)>0&&(t+=","),t+=s[e];return t}},layers:function(e,s){let t="&layers=",r=0;for(e in s)r>0&&(t+=","),t+=s[e],r++;return t},boundary_country:function(e,s){return"&boundary.country="+s},size:function(e,s){return"&"+e+"="+s},address:function(e,s){return"&"+e+"="+s},neighbourhood:function(e,s){return"&"+e+"="+s},borough:function(e,s){return"&"+e+"="+s},locality:function(e,s){return"&"+e+"="+s},county:function(e,s){return"&"+e+"="+s},region:function(e,s){return"&"+e+"="+s},postalcode:function(e,s){return"&"+e+"="+s},country:function(e,s){return"&"+e+"="+s}}}getParametersAsQueryString(s){let t="";for(const r in s){const i=s[r];e.baseUrlConstituents.indexOf(r)<=-1&&(t+=this.lookupParameter[r](r,i))}return t}async fetchGetRequest(e){let s=i.prepareUrl(this.requestArgs);return s+="?"+this.getParametersAsQueryString(this.requestArgs),await fetch(s,{method:"GET",headers:this.customHeaders,signal:e.signal})}async geocodePromise(){const s=new AbortController,t=setTimeout((()=>s.abort("timed out")),this.defaultArgs[e.propNames.timeout]||5e3);try{const e=await this.fetchGetRequest(s);if(!e.ok){const s=new Error(e.statusText);throw s.status=e.status,s.response=e,s}return await e.json()||e.text()}finally{clearTimeout(t)}}async geocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async reverseGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/reverse"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}async structuredGeocode(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs.service="geocode/search/structured"),this.requestArgs=i.fillArgs(this.defaultArgs,this.requestArgs),await this.geocodePromise()}},Isochrones:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs.service="isochrones"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){const s={};return e.restrictions&&(s.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(s.avoid_features=[...e.avoidables],delete e.avoidables),e.avoid_polygons&&(s.avoid_polygons={...e.avoid_polygons},delete e.avoid_polygons),Object.keys(s).length>0?{...e,options:s}:{...e}}},Directions:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="directions"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}getBody(e){return e.options&&"object"!=typeof e.options&&(e.options=JSON.parse(e.options)),e.restrictions&&(e.options=e.options||{},e.options.profile_params={restrictions:{...e.restrictions}},delete e.restrictions),e.avoidables&&(e.options=e.options||{},e.options.avoid_features=[...e.avoidables],delete e.avoidables),e}},Matrix:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="matrix"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}},Pois:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="pois")}generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)>-1||r===e.propNames.apiKey||r===e.propNames.timeout||(t[r]=s[r]);return t}async poisPromise(){this.requestArgs.request=this.requestArgs.request||"pois",this.argsCache=o.saveArgsToCache(this.requestArgs),this.requestArgs[e.propNames.service]&&delete this.requestArgs[e.propNames.service];const s=this.generatePayload(this.requestArgs);return await this.createRequest(s)}async pois(e){return this.requestArgs=e,this.checkHeaders(),this.requestArgs=o.fillArgs(this.defaultArgs,this.requestArgs),await this.poisPromise()}},Elevation:class extends r{generatePayload(s){const t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async elevationPromise(){this.argsCache=a.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async lineElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/line"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}async pointElevation(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.requestArgs[e.propNames.service]="elevation/point"),this.requestArgs=a.fillArgs(this.defaultArgs,this.requestArgs),await this.elevationPromise()}},Optimization:class extends r{generatePayload(s){let t={};for(const r in s)e.baseUrlConstituents.indexOf(r)<=-1&&(t[r]=s[r]);return t}async optimizationPromise(){this.argsCache=n.saveArgsToCache(this.requestArgs);const e=this.generatePayload(this.requestArgs);return await this.createRequest(e)}async optimize(s){return this.requestArgs=s,this.checkHeaders(),this.defaultArgs[e.propNames.service]||s[e.propNames.service]||(s[e.propNames.service]="optimization"),this.requestArgs=n.fillArgs(this.defaultArgs,this.requestArgs),await this.optimizationPromise()}},Snap:class extends r{constructor(s){super(s),this.defaultArgs[e.propNames.service]||this.requestArgs[e.propNames.service]||(this.defaultArgs[e.propNames.service]="snap"),s[e.propNames.apiVersion]||(this.defaultArgs.api_version=e.defaultAPIVersion)}}};return"object"==typeof module&&"object"==typeof module.exports?module.exports=u:"function"==typeof define&&define.amd&&define(u),"undefined"!=typeof window&&(window.Openrouteservice=u),u})); //# sourceMappingURL=ors-js-client.umd.cjs.map diff --git a/dist/ors-js-client.umd.cjs.map b/dist/ors-js-client.umd.cjs.map index beed2e6..fc55c6e 100644 --- a/dist/ors-js-client.umd.cjs.map +++ b/dist/ors-js-client.umd.cjs.map @@ -1 +1 @@ -{"version":3,"file":"ors-js-client.umd.cjs","sources":["../src/constants.js","../src/OrsUtil.js","../src/OrsBase.js","../src/OrsGeocode.js","../src/OrsPois.js","../src/OrsElevation.js","../src/OrsOptimization.js","../src/index.js","../src/OrsIsochrones.js","../src/OrsDirections.js","../src/OrsMatrix.js","../src/OrsSnap.js"],"sourcesContent":["const constants = {\n defaultAPIVersion: 'v2',\n defaultHost: 'https://api.openrouteservice.org',\n missingAPIKeyMsg: 'Please add your openrouteservice api_key..',\n baseUrlConstituents: ['host', 'service', 'api_version', 'mime_type'],\n propNames: {\n apiKey: 'api_key',\n host: 'host',\n service: 'service',\n apiVersion: 'api_version',\n mimeType: 'mime_type',\n profile: 'profile',\n format: 'format',\n timeout: 'timeout'\n }\n}\n\nexport default constants\n","import Constants from './constants.js'\nclass OrsUtil {\n fillArgs(defaultArgs, requestArgs) {\n requestArgs = {...defaultArgs, ...requestArgs}\n return requestArgs\n }\n\n saveArgsToCache(args) {\n return {\n host: args[Constants.propNames.host],\n api_version: args[Constants.propNames.apiVersion],\n profile: args[Constants.propNames.profile],\n format: args[Constants.propNames.format],\n service: args[Constants.propNames.service],\n api_key: args[Constants.propNames.apiKey],\n mime_type: args[Constants.propNames.mimeType]\n }\n }\n\n prepareRequest(args) {\n delete args[Constants.propNames.mimeType]\n delete args[Constants.propNames.host]\n delete args[Constants.propNames.apiVersion]\n delete args[Constants.propNames.service]\n delete args[Constants.propNames.apiKey]\n delete args[Constants.propNames.profile]\n delete args[Constants.propNames.format]\n delete args[Constants.propNames.timeout]\n return { ...args }\n }\n\n /**\n * Prepare the request url based on url constituents\n * @param {Object} args\n * @return {string} url\n */\n prepareUrl(args) {\n let url = args[Constants.propNames.host]\n let urlPathParts = [\n args[Constants.propNames.apiVersion],\n args[Constants.propNames.service],\n args[Constants.propNames.profile],\n args[Constants.propNames.format]\n ]\n\n urlPathParts = urlPathParts.join('/')\n urlPathParts = urlPathParts.replace(/\\/(\\/)+/g, '/')\n\n // The beginning and end of urlPathParts can not be a slash\n if (urlPathParts[0] === '/') {\n urlPathParts = urlPathParts.slice(1)\n }\n let end = urlPathParts.slice(-1)\n if (end[0] === '/') {\n urlPathParts = urlPathParts.slice(0, -1)\n }\n\n url = url + '/' + urlPathParts\n\n return url\n }\n}\n\nexport default OrsUtil\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsBase {\n constructor(args) {\n this.defaultArgs = {}\n this.requestArgs = {}\n this.argsCache = null\n this.customHeaders = {}\n\n this._setRequestDefaults(args)\n }\n\n /**\n * Set defaults for a request comparing with and overwriting default class arguments\n * @param {Object} args - constructor input\n */\n _setRequestDefaults(args) {\n this.defaultArgs[Constants.propNames.host] = Constants.defaultHost\n if (args[Constants.propNames.host]) {\n this.defaultArgs[Constants.propNames.host] = args[Constants.propNames.host]\n }\n if (args[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]\n }\n if (Constants.propNames.apiKey in args) {\n this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]\n } else {\n // eslint-disable-next-line no-console\n console.error(Constants.missingAPIKeyMsg)\n throw new Error(Constants.missingAPIKeyMsg)\n }\n\n }\n\n checkHeaders() {\n // Get custom header and remove from args\n if (this.requestArgs.customHeaders) {\n this.customHeaders = this.requestArgs.customHeaders\n delete this.requestArgs.customHeaders\n }\n // set default Content-type, since Postman sets Content-type to text/plain if not specified\n if (!('Content-type' in this.customHeaders)) {\n this.customHeaders = {...this.customHeaders, 'Content-type': 'application/json'}\n }\n }\n\n async fetchRequest(body, controller) {\n let url = orsUtil.prepareUrl(this.argsCache)\n if (this.argsCache[Constants.propNames.service] === 'pois') {\n url += url.indexOf('?') > -1 ? '&' : '?'\n }\n\n const authorization = {'Authorization': this.argsCache[Constants.propNames.apiKey]}\n\n return await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: {...authorization, ...this.customHeaders},\n signal: controller.signal\n })\n }\n\n async createRequest(body) {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchRequest(body, controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return this.argsCache?.format === 'gpx' ? await orsResponse.text() : await orsResponse.json()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n // is overidden in Directions and Isochrones class\n getBody() {\n return this.httpArgs;\n }\n\n async calculate(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n this.httpArgs = orsUtil.prepareRequest(this.requestArgs)\n const postBody = this.getBody(this.httpArgs)\n\n return await this.createRequest(postBody)\n }\n}\n\nexport default OrsBase\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsGeocode extends OrsBase {\n constructor(args) {\n super(args)\n\n this.lookupParameter = {\n api_key: function(key, val) {\n return key + '=' + val\n },\n text: function(key, val) {\n return '&' + key + '=' + encodeURIComponent(val)\n },\n focus_point: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'focus.point.lon' + '=' + val[1]\n urlParams += '&' + 'focus.point.lat' + '=' + val[0]\n return urlParams\n },\n boundary_bbox: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.rect.min_lon' + '=' + val[0][1]\n urlParams += '&' + 'boundary.rect.min_lat' + '=' + val[0][0]\n urlParams += '&' + 'boundary.rect.max_lon' + '=' + val[1][1]\n urlParams += '&' + 'boundary.rect.max_lat' + '=' + val[1][0]\n\n return urlParams\n },\n point: function(key, val) {\n if (val && Array.isArray(val.lat_lng)) {\n let urlParams = ''\n urlParams += '&' + 'point.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'point.lat' + '=' + val.lat_lng[0]\n return urlParams\n }\n },\n boundary_circle: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.circle.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'boundary.circle.lat' + '=' + val.lat_lng[0]\n urlParams += '&' + 'boundary.circle.radius' + '=' + val.radius\n\n return urlParams\n },\n sources: function(key, val) {\n let urlParams = '&sources='\n if (val) {\n for (const key in val) {\n if (Number(key) > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n }\n return urlParams\n }\n },\n layers: function(key, val) {\n let urlParams = '&layers='\n let counter = 0\n for (key in val) {\n if (counter > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n counter++\n }\n return urlParams\n },\n boundary_country: function(key, val) {\n return '&' + 'boundary.country' + '=' + val\n },\n size: function(key, val) {\n return '&' + key + '=' + val\n },\n address: function(key, val) {\n return '&' + key + '=' + val\n },\n neighbourhood: function(key, val) {\n return '&' + key + '=' + val\n },\n borough: function(key, val) {\n return '&' + key + '=' + val\n },\n locality: function(key, val) {\n return '&' + key + '=' + val\n },\n county: function(key, val) {\n return '&' + key + '=' + val\n },\n region: function(key, val) {\n return '&' + key + '=' + val\n },\n postalcode: function(key, val) {\n return '&' + key + '=' + val\n },\n country: function(key, val) {\n return '&' + key + '=' + val\n }\n }\n }\n\n getParametersAsQueryString(args) {\n let queryString = ''\n for (const key in args) {\n const val = args[key]\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n queryString += this.lookupParameter[key](key, val)\n }\n }\n return queryString\n }\n\n async fetchGetRequest(controller) {\n let url = orsUtil.prepareUrl(this.requestArgs)\n // Add url query string from args\n url += '?' + this.getParametersAsQueryString(this.requestArgs)\n\n // createRequest function from base class is not applicable: GET instead of POST request\n return await fetch(url, {\n method: 'GET',\n headers: this.customHeaders,\n signal: controller.signal\n })\n }\n\n async geocodePromise() {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchGetRequest(controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return await orsResponse.json() || orsResponse.text()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n async geocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async reverseGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/reverse'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async structuredGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search/structured'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n}\n\nexport default OrsGeocode\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsPois extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'pois'\n }\n }\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (\n !(\n Constants.baseUrlConstituents.indexOf(key) > -1 ||\n key === Constants.propNames.apiKey ||\n key === Constants.propNames.timeout\n )\n ) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async poisPromise() {\n // the request arg is required by the API as part of the body\n this.requestArgs.request = this.requestArgs.request || 'pois'\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n if (this.requestArgs[Constants.propNames.service]) {\n delete this.requestArgs[Constants.propNames.service]\n }\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async pois(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.poisPromise()\n }\n}\n\nexport default OrsPois\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\nclass OrsElevation extends OrsBase {\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async elevationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async lineElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/line'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n\n async pointElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/point'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n}\n\nexport default OrsElevation\n","import OrsUtil from \"./OrsUtil.js\"\nimport Constants from \"./constants.js\"\nimport OrsBase from \"./OrsBase.js\"\n\nconst orsUtil = new OrsUtil()\n\nclass OrsOptimization extends OrsBase {\n generatePayload(args) {\n let payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async optimizationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async optimize(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !reqArgs[Constants.propNames.service]) {\n reqArgs[Constants.propNames.service] = 'optimization'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.optimizationPromise()\n }\n}\n\nexport default OrsOptimization\n","import OrsGeocode from './OrsGeocode.js'\nimport OrsIsochrones from './OrsIsochrones.js'\nimport OrsMatrix from './OrsMatrix.js'\nimport OrsDirections from './OrsDirections.js'\nimport OrsPois from './OrsPois.js'\nimport OrsElevation from './OrsElevation.js'\nimport OrsOptimization from './OrsOptimization.js'\nimport OrsSnap from './OrsSnap.js';\n\nconst Openrouteservice = {\n Geocode: OrsGeocode,\n Isochrones: OrsIsochrones,\n Directions: OrsDirections,\n Matrix: OrsMatrix,\n Pois: OrsPois,\n Elevation: OrsElevation,\n Optimization: OrsOptimization,\n Snap: OrsSnap\n}\n\n// Define Openrouteservice for Node module pattern loaders, including Browserify\nif (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = Openrouteservice\n // define Openrouteservice as an AMD module\n // eslint-disable-next-line no-undef\n} else if (typeof define === 'function' && define.amd) {\n // eslint-disable-next-line no-undef\n define(Openrouteservice)\n}\n\nif (typeof window !== 'undefined') {\n window.Openrouteservice = Openrouteservice\n}\n\nexport default Openrouteservice\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsIsochrones extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs.service = 'isochrones'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n const options = {}\n\n if (args.restrictions) {\n options.profile_params = {\n restrictions: {\n ...args.restrictions\n }\n }\n delete args.restrictions\n }\n if (args.avoidables) {\n options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n\n if (args.avoid_polygons) {\n options.avoid_polygons = {\n ...args.avoid_polygons\n }\n delete args.avoid_polygons\n }\n\n if (Object.keys(options).length > 0) {\n return {\n ...args,\n options: options\n }\n } else {\n return {\n ...args\n }\n }\n }\n}\n\nexport default OrsIsochrones\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsDirections extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'directions'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsDirections\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsMatrix extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'matrix'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsMatrix\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsSnap extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'snap'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsSnap\n"],"names":["constants","defaultAPIVersion","defaultHost","missingAPIKeyMsg","baseUrlConstituents","propNames","apiKey","host","service","apiVersion","mimeType","profile","format","timeout","OrsUtil","fillArgs","defaultArgs","requestArgs","saveArgsToCache","args","Constants","api_version","api_key","mime_type","prepareRequest","prepareUrl","url","urlPathParts","join","replace","slice","orsUtil","OrsBase","constructor","this","argsCache","customHeaders","_setRequestDefaults","console","error","Error","checkHeaders","async","body","controller","indexOf","authorization","Authorization","fetch","method","JSON","stringify","headers","signal","AbortController","setTimeout","abort","orsResponse","fetchRequest","ok","statusText","status","response","_a","text","json","clearTimeout","getBody","httpArgs","reqArgs","postBody","createRequest","Openrouteservice","Geocode","super","lookupParameter","key","val","encodeURIComponent","focus_point","urlParams","boundary_bbox","point","Array","isArray","lat_lng","boundary_circle","radius","sources","Number","layers","counter","boundary_country","size","address","neighbourhood","borough","locality","county","region","postalcode","country","getParametersAsQueryString","queryString","fetchGetRequest","geocodePromise","Isochrones","options","restrictions","profile_params","avoidables","avoid_features","avoid_polygons","Object","keys","length","Directions","parse","Matrix","Pois","generatePayload","payload","request","poisPromise","Elevation","elevationPromise","Optimization","optimizationPromise","Snap","module","exports","define","amd","window"],"mappings":"4OAAA,MAAMA,EAAY,CAChBC,kBAAmB,KACnBC,YAAa,mCACbC,iBAAkB,6CAClBC,oBAAqB,CAAC,OAAQ,UAAW,cAAe,aACxDC,UAAW,CACTC,OAAQ,UACRC,KAAM,OACNC,QAAS,UACTC,WAAY,cACZC,SAAU,YACVC,QAAS,UACTC,OAAQ,SACRC,QAAS,YCZb,MAAMC,EACJC,SAASC,EAAaC,GAEb,OADPA,EAAc,IAAID,KAAgBC,EAEnC,CAEDC,gBAAgBC,GACP,MAAA,CACLZ,KAAMY,EAAKC,EAAUf,UAAUE,MAC/Bc,YAAaF,EAAKC,EAAUf,UAAUI,YACtCE,QAASQ,EAAKC,EAAUf,UAAUM,SAClCC,OAAQO,EAAKC,EAAUf,UAAUO,QACjCJ,QAASW,EA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AAMwG,EAAUvF,KAAKsF,gBAAgBtF,KAAKjB,aAEnC,aAAMiB,KAAKqC,cAAckD,EACjC,CAED/E,eAAe2B,GAUN,OATPnC,KAAKjB,YAAcoD,EAEnBnC,KAAKO,eAEAP,KAAKlB,YAAYI,EAAUf,UAAUG,UAAa6D,EAAQjD,EAAUf,UAAUG,WACzEY,EAAAA,EAAUf,UAAUG,SAAW,gBAEzC0B,KAAKjB,YAAcc,EAAQhB,SAASmB,KAAKlB,YAAakB,KAAKjB,mBAE9CiB,KAAK6F,qBACnB,GCpBDC,KIdF,cAAsBhG,EAClBC,YAAYd,GACRuD,MAAMvD,GACDe,KAAKlB,YAAYI,EAAUf,UAAUG,WACjC0B,KAAAlB,YAAYI,EAAUf,UAAUG,SAAW,QAE/CW,EAAKC,EAAUf,UAAUI,cACrByB,KAAAlB,YAAYK,YAAcD,EAAUnB,kBAEhD,CAEDkE,QAAQhD,GAkBG,OAjBHA,EAAKwF,SAAmC,iBAAjBxF,EAAKwF,UAC5BxF,EAAKwF,QAAUzD,KAAKmE,MAAMlG,EAAKwF,UAG/BxF,EAAKyF,eACAzF,EAAAwF,QAAUxF,EAAKwF,SAAW,CAAE,EACjCxF,EAAKwF,QAAQE,eAAiB,CAC1BD,aAAc,IAAKzF,EAAKyF,sBAErBzF,EAAKyF,cAGZzF,EAAK2F,aACA3F,EAAAwF,QAAUxF,EAAKwF,SAAW,CAAE,EACjCxF,EAAKwF,QAAQI,eAAiB,IAAI5F,EAAK2F,mBAChC3F,EAAK2F,YAET3F,CACV,UJZiB,iBAAX8G,QAAiD,iBAAnBA,OAAOC,QAC9CD,OAAOC,QAAU1D,EAGU,mBAAX2D,QAAyBA,OAAOC,KAEhDD,OAAO3D,GAGa,oBAAX6D,SACTA,OAAO7D,iBAAmBA"} \ No newline at end of file +{"version":3,"file":"ors-js-client.umd.cjs","sources":["../src/constants.js","../src/OrsUtil.js","../src/OrsBase.js","../src/OrsGeocode.js","../src/OrsPois.js","../src/OrsElevation.js","../src/OrsOptimization.js","../src/index.js","../src/OrsIsochrones.js","../src/OrsDirections.js","../src/OrsMatrix.js","../src/OrsSnap.js"],"sourcesContent":["const constants = {\n defaultAPIVersion: 'v2',\n defaultHost: 'https://api.openrouteservice.org',\n missingAPIKeyMsg: 'Please add your openrouteservice api_key..',\n baseUrlConstituents: ['host', 'service', 'api_version', 'mime_type'],\n propNames: {\n apiKey: 'api_key',\n host: 'host',\n service: 'service',\n apiVersion: 'api_version',\n mimeType: 'mime_type',\n profile: 'profile',\n format: 'format',\n timeout: 'timeout'\n }\n}\n\nexport default constants\n","import Constants from './constants.js'\nclass OrsUtil {\n fillArgs(defaultArgs, requestArgs) {\n requestArgs = {...defaultArgs, ...requestArgs}\n return requestArgs\n }\n\n saveArgsToCache(args) {\n return {\n host: args[Constants.propNames.host],\n api_version: args[Constants.propNames.apiVersion],\n profile: args[Constants.propNames.profile],\n format: args[Constants.propNames.format],\n service: args[Constants.propNames.service],\n api_key: args[Constants.propNames.apiKey],\n mime_type: args[Constants.propNames.mimeType]\n }\n }\n\n prepareRequest(args) {\n delete args[Constants.propNames.mimeType]\n delete args[Constants.propNames.host]\n delete args[Constants.propNames.apiVersion]\n delete args[Constants.propNames.service]\n delete args[Constants.propNames.apiKey]\n delete args[Constants.propNames.profile]\n delete args[Constants.propNames.format]\n delete args[Constants.propNames.timeout]\n return { ...args }\n }\n\n /**\n * Prepare the request url based on url constituents\n * @param {Object} args\n * @return {string} url\n */\n prepareUrl(args) {\n let url = args[Constants.propNames.host]\n let urlPathParts = [\n args[Constants.propNames.apiVersion],\n args[Constants.propNames.service],\n args[Constants.propNames.profile],\n args[Constants.propNames.format]\n ]\n\n urlPathParts = urlPathParts.join('/')\n urlPathParts = urlPathParts.replace(/\\/(\\/)+/g, '/')\n\n // The beginning and end of urlPathParts can not be a slash\n if (urlPathParts[0] === '/') {\n urlPathParts = urlPathParts.slice(1)\n }\n let end = urlPathParts.slice(-1)\n if (end[0] === '/') {\n urlPathParts = urlPathParts.slice(0, -1)\n }\n\n url = url + '/' + urlPathParts\n\n return url\n }\n}\n\nexport default OrsUtil\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsBase {\n constructor(args) {\n this.defaultArgs = {}\n this.requestArgs = {}\n this.argsCache = null\n this.customHeaders = {}\n\n this._setRequestDefaults(args)\n }\n\n /**\n * Set defaults for a request comparing with and overwriting default class arguments\n * @param {Object} args - constructor input\n */\n _setRequestDefaults(args) {\n this.defaultArgs[Constants.propNames.host] = Constants.defaultHost\n if (args[Constants.propNames.host]) {\n this.defaultArgs[Constants.propNames.host] = args[Constants.propNames.host]\n }\n if (args[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service]\n }\n if (Constants.propNames.apiKey in args) {\n this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey]\n } else if (!args[Constants.propNames.host]) {\n // Do not error if a host is specified; useful for locally-run instances of ORS\n console.error(Constants.missingAPIKeyMsg)\n throw new Error(Constants.missingAPIKeyMsg)\n }\n\n }\n\n checkHeaders() {\n // Get custom header and remove from args\n if (this.requestArgs.customHeaders) {\n this.customHeaders = this.requestArgs.customHeaders\n delete this.requestArgs.customHeaders\n }\n // set default Content-type, since Postman sets Content-type to text/plain if not specified\n if (!('Content-type' in this.customHeaders)) {\n this.customHeaders = {...this.customHeaders, 'Content-type': 'application/json'}\n }\n }\n\n async fetchRequest(body, controller) {\n let url = orsUtil.prepareUrl(this.argsCache)\n if (this.argsCache[Constants.propNames.service] === 'pois') {\n url += url.indexOf('?') > -1 ? '&' : '?'\n }\n\n const authorization = {'Authorization': this.argsCache[Constants.propNames.apiKey]}\n\n return await fetch(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: {...authorization, ...this.customHeaders},\n signal: controller.signal\n })\n }\n\n async createRequest(body) {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchRequest(body, controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return this.argsCache?.format === 'gpx' ? await orsResponse.text() : await orsResponse.json()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n // is overridden in Directions and Isochrones class\n getBody() {\n return this.httpArgs;\n }\n\n async calculate(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n this.httpArgs = orsUtil.prepareRequest(this.requestArgs)\n const postBody = this.getBody(this.httpArgs)\n\n return await this.createRequest(postBody)\n }\n}\n\nexport default OrsBase\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsGeocode extends OrsBase {\n constructor(args) {\n super(args)\n\n this.lookupParameter = {\n api_key: function(key, val) {\n return key + '=' + val\n },\n text: function(key, val) {\n return '&' + key + '=' + encodeURIComponent(val)\n },\n focus_point: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'focus.point.lon' + '=' + val[1]\n urlParams += '&' + 'focus.point.lat' + '=' + val[0]\n return urlParams\n },\n boundary_bbox: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.rect.min_lon' + '=' + val[0][1]\n urlParams += '&' + 'boundary.rect.min_lat' + '=' + val[0][0]\n urlParams += '&' + 'boundary.rect.max_lon' + '=' + val[1][1]\n urlParams += '&' + 'boundary.rect.max_lat' + '=' + val[1][0]\n\n return urlParams\n },\n point: function(key, val) {\n if (val && Array.isArray(val.lat_lng)) {\n let urlParams = ''\n urlParams += '&' + 'point.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'point.lat' + '=' + val.lat_lng[0]\n return urlParams\n }\n },\n boundary_circle: function(key, val) {\n let urlParams = ''\n urlParams += '&' + 'boundary.circle.lon' + '=' + val.lat_lng[1]\n urlParams += '&' + 'boundary.circle.lat' + '=' + val.lat_lng[0]\n urlParams += '&' + 'boundary.circle.radius' + '=' + val.radius\n\n return urlParams\n },\n sources: function(key, val) {\n let urlParams = '&sources='\n if (val) {\n for (const key in val) {\n if (Number(key) > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n }\n return urlParams\n }\n },\n layers: function(key, val) {\n let urlParams = '&layers='\n let counter = 0\n for (key in val) {\n if (counter > 0) {\n urlParams += ','\n }\n urlParams += val[key]\n counter++\n }\n return urlParams\n },\n boundary_country: function(key, val) {\n return '&' + 'boundary.country' + '=' + val\n },\n size: function(key, val) {\n return '&' + key + '=' + val\n },\n address: function(key, val) {\n return '&' + key + '=' + val\n },\n neighbourhood: function(key, val) {\n return '&' + key + '=' + val\n },\n borough: function(key, val) {\n return '&' + key + '=' + val\n },\n locality: function(key, val) {\n return '&' + key + '=' + val\n },\n county: function(key, val) {\n return '&' + key + '=' + val\n },\n region: function(key, val) {\n return '&' + key + '=' + val\n },\n postalcode: function(key, val) {\n return '&' + key + '=' + val\n },\n country: function(key, val) {\n return '&' + key + '=' + val\n }\n }\n }\n\n getParametersAsQueryString(args) {\n let queryString = ''\n for (const key in args) {\n const val = args[key]\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n queryString += this.lookupParameter[key](key, val)\n }\n }\n return queryString\n }\n\n async fetchGetRequest(controller) {\n let url = orsUtil.prepareUrl(this.requestArgs)\n // Add url query string from args\n url += '?' + this.getParametersAsQueryString(this.requestArgs)\n\n // createRequest function from base class is not applicable: GET instead of POST request\n return await fetch(url, {\n method: 'GET',\n headers: this.customHeaders,\n signal: controller.signal\n })\n }\n\n async geocodePromise() {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000)\n\n try {\n const orsResponse = await this.fetchGetRequest(controller)\n\n if (!orsResponse.ok) {\n const error = new Error(orsResponse.statusText)\n error.status = orsResponse.status\n error.response = orsResponse\n throw error\n }\n\n return await orsResponse.json() || orsResponse.text()\n } finally {\n clearTimeout(timeout)\n }\n }\n\n async geocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async reverseGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/reverse'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n\n async structuredGeocode(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs.service = 'geocode/search/structured'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.geocodePromise()\n }\n}\n\nexport default OrsGeocode\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\n\nclass OrsPois extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'pois'\n }\n }\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (\n !(\n Constants.baseUrlConstituents.indexOf(key) > -1 ||\n key === Constants.propNames.apiKey ||\n key === Constants.propNames.timeout\n )\n ) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async poisPromise() {\n // the request arg is required by the API as part of the body\n this.requestArgs.request = this.requestArgs.request || 'pois'\n\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n if (this.requestArgs[Constants.propNames.service]) {\n delete this.requestArgs[Constants.propNames.service]\n }\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async pois(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.poisPromise()\n }\n}\n\nexport default OrsPois\n","import OrsUtil from './OrsUtil.js'\nimport Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nconst orsUtil = new OrsUtil()\nclass OrsElevation extends OrsBase {\n\n generatePayload(args) {\n const payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async elevationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async lineElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/line'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n\n async pointElevation(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.requestArgs[Constants.propNames.service] = 'elevation/point'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.elevationPromise()\n }\n}\n\nexport default OrsElevation\n","import OrsUtil from \"./OrsUtil.js\"\nimport Constants from \"./constants.js\"\nimport OrsBase from \"./OrsBase.js\"\n\nconst orsUtil = new OrsUtil()\n\nclass OrsOptimization extends OrsBase {\n generatePayload(args) {\n let payload = {}\n\n for (const key in args) {\n if (Constants.baseUrlConstituents.indexOf(key) <= -1) {\n payload[key] = args[key]\n }\n }\n return payload\n }\n\n async optimizationPromise() {\n this.argsCache = orsUtil.saveArgsToCache(this.requestArgs)\n\n const payload = this.generatePayload(this.requestArgs)\n\n return await this.createRequest(payload)\n }\n\n async optimize(reqArgs) {\n this.requestArgs = reqArgs\n\n this.checkHeaders()\n\n if (!this.defaultArgs[Constants.propNames.service] && !reqArgs[Constants.propNames.service]) {\n reqArgs[Constants.propNames.service] = 'optimization'\n }\n this.requestArgs = orsUtil.fillArgs(this.defaultArgs, this.requestArgs)\n\n return await this.optimizationPromise()\n }\n}\n\nexport default OrsOptimization\n","import OrsGeocode from './OrsGeocode.js'\nimport OrsIsochrones from './OrsIsochrones.js'\nimport OrsMatrix from './OrsMatrix.js'\nimport OrsDirections from './OrsDirections.js'\nimport OrsPois from './OrsPois.js'\nimport OrsElevation from './OrsElevation.js'\nimport OrsOptimization from './OrsOptimization.js'\nimport OrsSnap from './OrsSnap.js';\n\nconst Openrouteservice = {\n Geocode: OrsGeocode,\n Isochrones: OrsIsochrones,\n Directions: OrsDirections,\n Matrix: OrsMatrix,\n Pois: OrsPois,\n Elevation: OrsElevation,\n Optimization: OrsOptimization,\n Snap: OrsSnap\n}\n\n// Define Openrouteservice for Node module pattern loaders, including Browserify\nif (typeof module === 'object' && typeof module.exports === 'object') {\n module.exports = Openrouteservice\n // define Openrouteservice as an AMD module\n // eslint-disable-next-line no-undef\n} else if (typeof define === 'function' && define.amd) {\n // eslint-disable-next-line no-undef\n define(Openrouteservice)\n}\n\nif (typeof window !== 'undefined') {\n window.Openrouteservice = Openrouteservice\n}\n\nexport default Openrouteservice\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsIsochrones extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs.service = 'isochrones'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n const options = {}\n\n if (args.restrictions) {\n options.profile_params = {\n restrictions: {\n ...args.restrictions\n }\n }\n delete args.restrictions\n }\n if (args.avoidables) {\n options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n\n if (args.avoid_polygons) {\n options.avoid_polygons = {\n ...args.avoid_polygons\n }\n delete args.avoid_polygons\n }\n\n if (Object.keys(options).length > 0) {\n return {\n ...args,\n options: options\n }\n } else {\n return {\n ...args\n }\n }\n }\n}\n\nexport default OrsIsochrones\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsDirections extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'directions'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n\n getBody(args) {\n if (args.options && typeof args.options !== 'object') {\n args.options = JSON.parse(args.options)\n }\n\n if (args.restrictions) {\n args.options = args.options || {}\n args.options.profile_params = {\n restrictions: { ...args.restrictions }\n }\n delete args.restrictions\n }\n\n if (args.avoidables) {\n args.options = args.options || {}\n args.options.avoid_features = [...args.avoidables]\n delete args.avoidables\n }\n return args\n }\n}\n\nexport default OrsDirections\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsMatrix extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'matrix'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsMatrix\n","import Constants from './constants.js'\nimport OrsBase from './OrsBase.js'\n\nclass OrsSnap extends OrsBase {\n constructor(args) {\n super(args);\n if (!this.defaultArgs[Constants.propNames.service] && !this.requestArgs[Constants.propNames.service]) {\n this.defaultArgs[Constants.propNames.service] = 'snap'\n }\n if (!args[Constants.propNames.apiVersion]) {\n this.defaultArgs.api_version = Constants.defaultAPIVersion\n }\n }\n}\n\nexport default OrsSnap\n"],"names":["constants","defaultAPIVersion","defaultHost","missingAPIKeyMsg","baseUrlConstituents","propNames","apiKey","host","service","apiVersion","mimeType","profile","format","timeout","OrsUtil","fillArgs","defaultArgs","requestArgs","saveArgsToCache","args","Constants","api_version","api_key","mime_type","prepareRequest","prepareUrl","url","urlPathParts","join","replace","slice","orsUtil","OrsBase","constructor","this","argsCache","customHeaders","_setRequestDefaults","console","error","Error","checkHeaders","fetchRequest","body","controller","indexOf","authorization","Authorization","fetch","method","JSON","stringify","headers","signal","createRequest","AbortController","setTimeout","abort","orsResponse","ok","statusText","status","response","_a","text","json","clearTimeout","getBody","httpArgs","calculate","reqArgs","postBody","Openrouteservice","Geocode","super","lookupParameter","key","val","encodeURIComponent","focus_point","urlParams","boundary_bbox","point","Array","isArray","lat_lng","boundary_circle","radius","sources","Number","layers","counter","boundary_country","size","address","neighbourhood","borough","locality","county","region","postalcode","country","getParametersAsQueryString","queryString","fetchGetRequest","geocodePromise","geocode","reverseGeocode","structuredGeocode","Isochrones","options","restrictions","profile_params","avoidables","avoid_features","avoid_polygons","Object","keys","length","Directions","parse","Matrix","Pois","generatePayload","payload","poisPromise","request","pois","Elevation","elevationPromise","lineElevation","pointElevation","Optimization","optimizationPromise","optimize","Snap","module","exports","define","amd","window"],"mappings":"4OAAA,MAAMA,EAAY,CAChBC,kBAAmB,KACnBC,YAAa,mCACbC,iBAAkB,6CAClBC,oBAAqB,CAAC,OAAQ,UAAW,cAAe,aACxDC,UAAW,CACTC,OAAQ,UACRC,KAAM,OACNC,QAAS,UACTC,WAAY,cACZC,SAAU,YACVC,QAAS,UACTC,OAAQ,SACRC,QAAS,YCZb,MAAMC,EACJ,QAAAC,CAASC,EAAaC,GAEb,OADPA,EAAc,IAAID,KAAgBC,EAEnC,CAED,eAAAC,CAAgBC,GACP,MAAA,CACLZ,K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KAAKjB,YAAcc,EAAQhB,SAASmB,KAAKlB,YAAakB,KAAKjB,mBAE9CiB,KAAK+F,kBACnB,GElCDG,aDVF,cAA8BpG,EAC5B,eAAA2F,CAAgBxG,GACd,IAAIyG,EAAU,CAAE,EAEhB,IAAA,MAAWhD,KAAOzD,EACZC,EAAUhB,oBAAoByC,QAAQ+B,KAAY,IAC5CgD,EAAAhD,GAAOzD,EAAKyD,IAGjB,OAAAgD,CACR,CAED,yBAAMS,GACJnG,KAAKC,UAAYJ,EAAQb,gBAAgBgB,KAAKjB,aAE9C,MAAM2G,EAAU1F,KAAKyF,gBAAgBzF,KAAKjB,aAEnC,aAAMiB,KAAKoB,cAAcsE,EACjC,CAED,cAAMU,CAAShE,GAUN,OATPpC,KAAKjB,YAAcqD,EAEnBpC,KAAKO,eAEAP,KAAKlB,YAAYI,EAAUf,UAAUG,UAAa8D,EAAQlD,EAAUf,UAAUG,WACzEY,EAAAA,EAAUf,UAAUG,SAAW,gBAEzC0B,KAAKjB,YAAcc,EAAQhB,SAASmB,KAAKlB,YAAakB,KAAKjB,mBAE9CiB,KAAKmG,qBACnB,GCpBDE,KIdF,cAAsBvG,EAClB,WAAAC,CAAYd,GACRuD,MAAMvD,GACDe,KAAKlB,YAAYI,EAAUf,UAAUG,UAAa0B,KAAKjB,YAAYG,EAAUf,UAAUG,WACxF0B,KAAKlB,YAAYI,EAAUf,UAAUG,SAAW,QAE/CW,EAAKC,EAAUf,UAAUI,cACrByB,KAAAlB,YAAYK,YAAcD,EAAUnB,kBAEhD,UJSiB,iBAAXuI,QAAiD,iBAAnBA,OAAOC,QAC9CD,OAAOC,QAAUjE,EAGU,mBAAXkE,QAAyBA,OAAOC,KAEhDD,OAAOlE,GAGa,oBAAXoE,SACTA,OAAOpE,iBAAmBA"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bd7e022..c1a8df3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "openrouteservice-js", - "version": "0.3.2", + "version": "0.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "openrouteservice-js", - "version": "0.3.2", + "version": "0.4.0", "license": "Apache-2.0", "devDependencies": { "@cypress/code-coverage": "^3.12.40", diff --git a/package.json b/package.json index 332b9d9..8fb92ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openrouteservice-js", - "version": "0.3.2", + "version": "0.4.0", "description": "A Javascript client for openrouteservice services.", "author": "Openrouteservice Community", "license": "Apache-2.0",