From: Sarah Hoffmann Date: Wed, 4 Jul 2018 18:56:09 +0000 (+0200) Subject: make sure index is used when looking for places in country X-Git-Tag: v3.2.0~58 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/b0e0f7ae7602bea30138c055c8aefdb4f65f78e4 make sure index is used when looking for places in country --- 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';