From 0f940fa6417b1de1387502e14dc689f02a7fa7d3 Mon Sep 17 00:00:00 2001 From: Neil Rotstan Date: Fri, 16 Oct 2020 11:38:08 -0700 Subject: [PATCH] Include bbox from Nominatim response, fixes #224 - Set `bbox` field appropriately when processing Nominatim response - Fix bbox transformation to account for Nominatim's formatting - Include original `place` in addresschosen event --- src/nominatim.js | 8 +++++++- src/providers/osm.js | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nominatim.js b/src/nominatim.js index d8910fd..16b94dd 100644 --- a/src/nominatim.js +++ b/src/nominatim.js @@ -213,7 +213,11 @@ export class Nominatim { let { bbox } = place; if (bbox) { - bbox = proj.transformExtent(bbox, 'EPSG:4326', projection); + bbox = proj.transformExtent( + [bbox[2], bbox[1], bbox[3], bbox[0]], // NSWE -> WSEN + 'EPSG:4326', + projection + ); } const address = { @@ -230,6 +234,7 @@ export class Nominatim { address, coordinate: coord, bbox, + place, }); } else { if (bbox) { @@ -246,6 +251,7 @@ export class Nominatim { feature, coordinate: coord, bbox, + place, }); } } diff --git a/src/providers/osm.js b/src/providers/osm.js index f49ce53..457b4d7 100644 --- a/src/providers/osm.js +++ b/src/providers/osm.js @@ -41,6 +41,7 @@ export class OpenStreet { return results.map((result) => ({ lon: result.lon, lat: result.lat, + bbox: result.boundingbox, address: { name: result.display_name,