From 0b9618e3490bea5f18073cd84de1c21400dca48d Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 13 Mar 2014 20:34:31 +0100 Subject: [PATCH] prefer street results when doing house number search This is an experimental fix for #119. --- lib/Geocode.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index f87748c3..c6febe73 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -1266,7 +1266,14 @@ if ($bBoundingBoxSearch) $aTerms[] = "centroid && $sViewboxSmallSQL"; if ($sNearPointSQL) $aOrder[] = "ST_Distance($sNearPointSQL, centroid) asc"; - $sImportanceSQL = '(case when importance = 0 OR importance IS NULL then 0.75-(search_rank::float/40) else importance end)'; + if ($aSearch['sHouseNumber']) + { + $sImportanceSQL = '- abs(26 - address_rank) + 3'; + } + else + { + $sImportanceSQL = '(case when importance = 0 OR importance IS NULL then 0.75-(search_rank::float/40) else importance end)'; + } if ($sViewboxSmallSQL) $sImportanceSQL .= " * case when ST_Contains($sViewboxSmallSQL, centroid) THEN 1 ELSE 0.5 END"; if ($sViewboxLargeSQL) $sImportanceSQL .= " * case when ST_Contains($sViewboxLargeSQL, centroid) THEN 1 ELSE 0.5 END"; $aOrder[] = "$sImportanceSQL DESC"; -- 2.45.2