X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/8f0b3cb00f0d3f7b101a742e7480903ff0e89a2a..ee3973f507d0090d493ace4e640a5bc98a62475c:/lib/ReverseGeocode.php diff --git a/lib/ReverseGeocode.php b/lib/ReverseGeocode.php index 5648fedf..681403a1 100644 --- a/lib/ReverseGeocode.php +++ b/lib/ReverseGeocode.php @@ -113,12 +113,11 @@ class ReverseGeocode $sSQL .= ' FROM placex'; $sSQL .= ' WHERE osm_type = \'N\''; $sSQL .= ' AND country_code = \''.$sCountryCode.'\''; - $sSQL .= ' AND rank_search > 4'; - $sSQL .= ' AND rank_search <= ' .min(25, $iMaxRank); - $sSQL .= ' AND type != \'postcode\''; + $sSQL .= ' AND rank_search between 5 and ' .min(25, $iMaxRank); + $sSQL .= ' AND class = \'place\' 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, 5.0)) p '; + $sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, 1.8)) p '; $sSQL .= 'WHERE distance <= reverse_place_diameter(rank_search)'; $sSQL .= ' ORDER BY rank_search DESC, distance ASC'; $sSQL .= ' LIMIT 1'; @@ -194,13 +193,12 @@ class ReverseGeocode // using rank_search because of a better differentiation // for place nodes at rank_address 16 $sSQL .= ' AND rank_search > '.$iRankSearch; - $sSQL .= ' AND rank_search <= ' .$iMaxRank; + $sSQL .= ' AND rank_search <= '.$iMaxRank; $sSQL .= ' AND class = \'place\''; $sSQL .= ' AND type != \'postcode\''; $sSQL .= ' AND name IS NOT NULL '; $sSQL .= ' AND indexed_status = 0 AND linked_place_id is null'; - // preselection through bbox - $sSQL .= ' AND (SELECT geometry FROM placex WHERE place_id = '.$iPlaceID.') && geometry'; + $sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, reverse_place_diameter('.$iRankSearch.'::smallint))'; $sSQL .= ' ORDER BY distance ASC,'; $sSQL .= ' rank_address DESC'; $sSQL .= ' limit 500) as a'; @@ -249,9 +247,7 @@ class ReverseGeocode // for POI or street level if ($iMaxRank >= 26) { $sSQL = 'select place_id,parent_place_id,rank_address,country_code,'; - $sSQL .= 'CASE WHEN ST_GeometryType(geometry) in (\'ST_Polygon\',\'ST_MultiPolygon\') THEN ST_distance('.$sPointSQL.', centroid)'; - $sSQL .= ' ELSE ST_distance('.$sPointSQL.', geometry) '; - $sSQL .= ' END as distance'; + $sSQL .= ' ST_distance('.$sPointSQL.', geometry) as distance'; $sSQL .= ' FROM '; $sSQL .= ' placex'; $sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', geometry, '.$fSearchDiam.')';