From b0e0f7ae7602bea30138c055c8aefdb4f65f78e4 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 4 Jul 2018 20:56:09 +0200 Subject: [PATCH] make sure index is used when looking for places in country --- lib/ReverseGeocode.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ReverseGeocode.php b/lib/ReverseGeocode.php index 41da2667..69fef37e 100644 --- a/lib/ReverseGeocode.php +++ b/lib/ReverseGeocode.php @@ -111,10 +111,11 @@ class ReverseGeocode $sSQL .= ' WHERE osm_type = \'N\''; $sSQL .= ' AND country_code = \''.$sCountryCode.'\''; $sSQL .= ' AND rank_address > 0'; - $sSQL .= ' AND rank_address <= ' .$iMaxRank; + $sSQL .= ' AND rank_address <= ' .min(25, $iMaxRank); $sSQL .= ' AND type != \'postcode\''; $sSQL .= ' AND name IS NOT NULL '; $sSQL .= ' and indexed_status = 0 and linked_place_id is null'; + $sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, 1.0)'; $sSQL .= ' ORDER BY distance ASC, rank_address DESC'; $sSQL .= ' LIMIT 1'; -- 2.39.5