From 75812e95781e132c178f09396f4a66e18761efb0 Mon Sep 17 00:00:00 2001 From: Ahmed Tarek Date: Thu, 10 Mar 2022 06:58:38 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20add=20formattedAddress=20and=20?= =?UTF-8?q?county=20to=20locationiq=20+=20unify=20country=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/geocoder/locationiqgeocoder.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/geocoder/locationiqgeocoder.js b/lib/geocoder/locationiqgeocoder.js index 5afbf6d1..70d4e245 100644 --- a/lib/geocoder/locationiqgeocoder.js +++ b/lib/geocoder/locationiqgeocoder.js @@ -120,25 +120,31 @@ LocationIQGeocoder.prototype._reverse = function(query, callback) { LocationIQGeocoder.prototype._formatResult = function(result) { // transform lat and lon to real floats var transformedResult = { - 'latitude' : result.lat ? parseFloat(result.lat) : undefined, - 'longitude' : result.lon ? parseFloat(result.lon) : undefined + latitude : result.lat ? parseFloat(result.lat) : undefined, + longitude : result.lon ? parseFloat(result.lon) : undefined, }; + if (result.display_name) { + transformedResult.formattedAddress = result.display_name; + } + if (result.address) { - transformedResult.country = result.address.country; - transformedResult.country = result.address.country; + /* make sure country name is unified accross geocoders */ + transformedResult.country = result.address.country === 'United States of America' ? 'United States' : result.address.country; transformedResult.city = result.address.city || result.address.town || result.address.village || result.address.hamlet; transformedResult.state = result.address.state; transformedResult.zipcode = result.address.postcode; transformedResult.streetName = result.address.road || result.address.cycleway; transformedResult.streetNumber = result.address.house_number; + if (transformedResult.county) { + transformedResult.county = result.address.county; + } // make sure countrycode is always uppercase to keep node-geocoder api formats var countryCode = result.address.country_code; if (countryCode) { countryCode = countryCode.toUpperCase(); } - transformedResult.countryCode = countryCode; } return transformedResult; From d921367f1fadbad0dced8900bdbd854a739b6935 Mon Sep 17 00:00:00 2001 From: Ahmed Tarek Date: Sun, 10 Apr 2022 19:03:54 +0200 Subject: [PATCH 2/4] Update lib/geocoder/locationiqgeocoder.js --- lib/geocoder/locationiqgeocoder.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/geocoder/locationiqgeocoder.js b/lib/geocoder/locationiqgeocoder.js index 70d4e245..d2fa133c 100644 --- a/lib/geocoder/locationiqgeocoder.js +++ b/lib/geocoder/locationiqgeocoder.js @@ -136,9 +136,6 @@ LocationIQGeocoder.prototype._formatResult = function(result) { transformedResult.zipcode = result.address.postcode; transformedResult.streetName = result.address.road || result.address.cycleway; transformedResult.streetNumber = result.address.house_number; - if (transformedResult.county) { - transformedResult.county = result.address.county; - } // make sure countrycode is always uppercase to keep node-geocoder api formats var countryCode = result.address.country_code; From 3ccae4b9e53874545ed9492d5e3f25e822db7159 Mon Sep 17 00:00:00 2001 From: Ahmed Tarek Date: Mon, 11 Apr 2022 00:00:01 +0200 Subject: [PATCH 3/4] Update locationiqgeocoder.js --- lib/geocoder/locationiqgeocoder.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/geocoder/locationiqgeocoder.js b/lib/geocoder/locationiqgeocoder.js index d2fa133c..534088a9 100644 --- a/lib/geocoder/locationiqgeocoder.js +++ b/lib/geocoder/locationiqgeocoder.js @@ -137,6 +137,10 @@ LocationIQGeocoder.prototype._formatResult = function(result) { transformedResult.streetName = result.address.road || result.address.cycleway; transformedResult.streetNumber = result.address.house_number; + if (transformedResult.county) { + transformedResult.county = result.address.county; + } + // make sure countrycode is always uppercase to keep node-geocoder api formats var countryCode = result.address.country_code; if (countryCode) { From d96a3f9f3ec576ec91f1170314f6eb8810d8aae1 Mon Sep 17 00:00:00 2001 From: Ahmed Tarek Date: Fri, 15 Apr 2022 02:14:28 +0200 Subject: [PATCH 4/4] Remove hardcoded country --- lib/geocoder/locationiqgeocoder.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/geocoder/locationiqgeocoder.js b/lib/geocoder/locationiqgeocoder.js index 534088a9..11243220 100644 --- a/lib/geocoder/locationiqgeocoder.js +++ b/lib/geocoder/locationiqgeocoder.js @@ -129,8 +129,7 @@ LocationIQGeocoder.prototype._formatResult = function(result) { } if (result.address) { - /* make sure country name is unified accross geocoders */ - transformedResult.country = result.address.country === 'United States of America' ? 'United States' : result.address.country; + transformedResult.country = result.address.country; transformedResult.city = result.address.city || result.address.town || result.address.village || result.address.hamlet; transformedResult.state = result.address.state; transformedResult.zipcode = result.address.postcode;