From c9a63508943d92cfe2a1f5d2c12454662bb46770 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Tue, 2 Apr 2019 14:49:31 +0200 Subject: [PATCH] On postcode searches observe given bounded viewbox --- lib/SearchDescription.php | 3 +++ test/bdd/api/search/postcode.feature | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php index 358e6969..506d4202 100644 --- a/lib/SearchDescription.php +++ b/lib/SearchDescription.php @@ -588,6 +588,9 @@ class SearchDescription $sSQL .= "p.postcode = '".reset($this->aName)."'"; $sSQL .= $this->countryCodeSQL(' AND p.country_code'); + if ($this->oContext->bViewboxBounded) { + $sSQL .= ' AND ST_Intersects('.$this->oContext->sqlViewboxSmall.', geometry)'; + } $sSQL .= $this->oContext->excludeSQL(' AND p.place_id'); $sSQL .= " LIMIT $iLimit"; diff --git a/test/bdd/api/search/postcode.feature b/test/bdd/api/search/postcode.feature index 63c86469..e70495f6 100644 --- a/test/bdd/api/search/postcode.feature +++ b/test/bdd/api/search/postcode.feature @@ -26,6 +26,18 @@ Feature: Searches with postcodes | country_code | | li | + Scenario: Postcode search with bounded viewbox restriction + When sending json search query "9486" with address + | bounded | viewbox | + | 1 | 9.55,47.20,9.58,47.22 | + Then result addresses contain + | postcode | + | 9486 | + When sending json search query "9486" with address + | bounded | viewbox | + | 1 | 5.00,20.00,6.00,21.00 | + Then exactly 0 results are returned + Scenario: Postcode search with structured query When sending json search query "" with address | postalcode | country | -- 2.39.5