From 6727c36298fe6d5e779498d6c7eb88ce7ffdc2a2 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 3 May 2015 17:31:14 +0200 Subject: [PATCH] places marked as linked should use the address of the link origin fixes #269 --- sql/functions.sql | 8 +++++--- tests/features/api/reverse_by_id.feature | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tests/features/api/reverse_by_id.feature diff --git a/sql/functions.sql b/sql/functions.sql index 658771b7..878c69c9 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -2241,9 +2241,11 @@ BEGIN END IF; IF for_place_id IS NULL THEN - for_place_id := in_place_id; - select calculated_country_code, housenumber, rank_search, postcode, null from placex where place_id = for_place_id - INTO searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode, searchhousename; + select coalesce(linked_place_id, place_id), calculated_country_code, + housenumber, rank_search, postcode, null + from placex where place_id = in_place_id + INTO for_place_id, searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode, searchhousename; + RAISE WARNING '% fffff %', in_place_id, for_place_id; END IF; --RAISE WARNING '% % % %',searchcountrycode, searchhousenumber, searchrankaddress, searchpostcode; diff --git a/tests/features/api/reverse_by_id.feature b/tests/features/api/reverse_by_id.feature new file mode 100644 index 00000000..5f5a8f8d --- /dev/null +++ b/tests/features/api/reverse_by_id.feature @@ -0,0 +1,13 @@ +Feature: Reverse lookup by ID + Testing reverse geocoding via OSM ID + + # see github issue #269 + Scenario: Get address of linked places + Given the request parameters + | osm_type | osm_id + | N | 151421301 + When sending an API call reverse + Then exactly 1 result is returned + And result addresses contain + | county | state + | Pratt County | Kansas