From f67095710d08e150af6f4ac568784e4bfc469945 Mon Sep 17 00:00:00 2001 From: speckmaier Date: Mon, 15 Nov 2021 13:40:27 +0100 Subject: [PATCH 1/6] geocode - allow osm_tag entries in tags --- src/GraphHopperGeocoding.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/GraphHopperGeocoding.js b/src/GraphHopperGeocoding.js index 605a32c..a3423e7 100644 --- a/src/GraphHopperGeocoding.js +++ b/src/GraphHopperGeocoding.js @@ -43,6 +43,20 @@ GraphHopperGeocoding.prototype.getParametersAsQueryString = function (args) { if (args.limit) qString += "&limit=" + args.limit; + if (args.osm_tag) { + + if(args.osm_tag.length) { + + for(var j=0; j < args.osm_tag.length;++j) { + qString += "&osm_tag=" + args.osm_tag[j]; + } + + } else { + qString += "&osm_tag=" + args.osm_tag; + } + + } + return qString; }; From 839ad496e32df68117b6313bd8edbb250dc80737 Mon Sep 17 00:00:00 2001 From: speckmaier Date: Tue, 18 Jan 2022 14:32:46 +0100 Subject: [PATCH 2/6] unset vehicle on GraphHopperRouting if profile is used --- src/GraphHopperRouting.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/GraphHopperRouting.js b/src/GraphHopperRouting.js index e95b374..15caa1e 100644 --- a/src/GraphHopperRouting.js +++ b/src/GraphHopperRouting.js @@ -7,7 +7,9 @@ var ghUtil = new GHUtil(); GraphHopperRouting = function (args) { this.points = []; this.host = "https://graphhopper.com/api/1"; - this.vehicle = "car"; + if(args.profile === undefined) { + this.vehicle = "car"; + } this.debug = false; this.data_type = 'application/json'; this.locale = 'en'; From 2845c1b72ee56a53a2cee0201b5bc56a8af38681 Mon Sep 17 00:00:00 2001 From: speckmaier Date: Fri, 28 Jan 2022 16:16:45 +0100 Subject: [PATCH 3/6] remove 'for url' from errors as it exposes the api key used in the request --- src/GHUtil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GHUtil.js b/src/GHUtil.js index c3bef82..c6e964b 100644 --- a/src/GHUtil.js +++ b/src/GHUtil.js @@ -87,7 +87,7 @@ GHUtil.prototype.extractError = function (res, url) { msg = res; } - return new Error(msg + " - for url " + url); + return new Error(msg); }; GHUtil.prototype.isArray = function (value) { From 1f5024c4c1d1ca37cd8a6d3040286a0bd8cc12ad Mon Sep 17 00:00:00 2001 From: speckmaier Date: Mon, 30 May 2022 15:53:54 +0200 Subject: [PATCH 4/6] allow details parameter in graphopper map matching --- src/GraphHopperMapMatching.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/GraphHopperMapMatching.js b/src/GraphHopperMapMatching.js index 76a4b17..70d0e65 100644 --- a/src/GraphHopperMapMatching.js +++ b/src/GraphHopperMapMatching.js @@ -42,10 +42,37 @@ GraphHopperMapMatching.prototype.getParametersAsQueryString = function (args) { if (args.vehicle) qString += "&vehicle=" + args.vehicle; + + if (args.details) + qString += "&details=" + this.flatParameter('details', args.details); return qString; }; +GraphHopperMapMatching.prototype.flatParameter = function (key, val) { + var url = ""; + var arr; + var keyIndex; + + if (ghUtil.isObject(val)) { + arr = Object.keys(val); + for (keyIndex in arr) { + var objKey = arr[keyIndex]; + url += this.flatParameter(key + "." + objKey, val[objKey]); + } + return url; + + } else if (ghUtil.isArray(val)) { + arr = val; + for (keyIndex in arr) { + url += this.flatParameter(key, arr[keyIndex]); + } + return url; + } + + return "&" + encodeURIComponent(key) + "=" + encodeURIComponent(val); +}; + GraphHopperMapMatching.prototype.doRequest = function (content, reqArgs) { var that = this; From 1e12dc1446a4dee8b15c77c52bc0da22c63494da Mon Sep 17 00:00:00 2001 From: speckmaier Date: Mon, 30 May 2022 15:55:39 +0200 Subject: [PATCH 5/6] details parameter --- src/GraphHopperMapMatching.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GraphHopperMapMatching.js b/src/GraphHopperMapMatching.js index 70d0e65..221f6c1 100644 --- a/src/GraphHopperMapMatching.js +++ b/src/GraphHopperMapMatching.js @@ -44,7 +44,7 @@ GraphHopperMapMatching.prototype.getParametersAsQueryString = function (args) { qString += "&vehicle=" + args.vehicle; if (args.details) - qString += "&details=" + this.flatParameter('details', args.details); + qString += this.flatParameter('details', args.details); return qString; }; From f3d5201421b13b061f91f5e347c320440590d3a8 Mon Sep 17 00:00:00 2001 From: speckmaier Date: Wed, 31 Aug 2022 09:41:46 +0200 Subject: [PATCH 6/6] actually pass graphhopper hints to thrown exceptions --- src/GHUtil.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/GHUtil.js b/src/GHUtil.js index c6e964b..8da73a4 100644 --- a/src/GHUtil.js +++ b/src/GHUtil.js @@ -87,7 +87,13 @@ GHUtil.prototype.extractError = function (res, url) { msg = res; } - return new Error(msg); + const error = new Error(msg); + + if(res && res.body && res.body.hints) { + error.hints = res?.body?.hints; + } + + return error; }; GHUtil.prototype.isArray = function (value) {