mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-12 05:44:06 +00:00
@@ -78,12 +78,15 @@ class ReverseGeocode
|
|||||||
// starts the nopolygonFound function if no polygon is found with the lookupPolygon function
|
// starts the nopolygonFound function if no polygon is found with the lookupPolygon function
|
||||||
$oResult = null;
|
$oResult = null;
|
||||||
|
|
||||||
|
if ($iMaxRank > 4) {
|
||||||
$aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank);
|
$aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank);
|
||||||
if ($aPlace) {
|
if ($aPlace) {
|
||||||
$oResult = new Result($aPlace['place_id']);
|
$oResult = new Result($aPlace['place_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
// if no polygon which contains the searchpoint is found,
|
// if no polygon which contains the searchpoint is found,
|
||||||
// the noPolygonFound function searches in the country_osm_grid table for a polygon
|
// the noPolygonFound function searches in the country_osm_grid table for a polygon
|
||||||
} elseif (!$aPlace && $iMaxRank > 4) {
|
if (!$oResult) {
|
||||||
$aPlace = $this->noPolygonFound($sPointSQL, $iMaxRank);
|
$aPlace = $this->noPolygonFound($sPointSQL, $iMaxRank);
|
||||||
if ($aPlace) {
|
if ($aPlace) {
|
||||||
$oResult = new Result($aPlace['place_id']);
|
$oResult = new Result($aPlace['place_id']);
|
||||||
@@ -101,11 +104,12 @@ class ReverseGeocode
|
|||||||
|
|
||||||
$aPoly = chksql(
|
$aPoly = chksql(
|
||||||
$this->oDB->getRow($sSQL),
|
$this->oDB->getRow($sSQL),
|
||||||
'Could not determine polygon containing the point.'
|
'Could not determine country polygon containing the point.'
|
||||||
);
|
);
|
||||||
if ($aPoly) {
|
if ($aPoly) {
|
||||||
$sCountryCode = $aPoly['country_code'];
|
$sCountryCode = $aPoly['country_code'];
|
||||||
|
|
||||||
|
if ($iMaxRank > 4) {
|
||||||
// look for place nodes with the given country code
|
// look for place nodes with the given country code
|
||||||
$sSQL = 'SELECT place_id FROM';
|
$sSQL = 'SELECT place_id FROM';
|
||||||
$sSQL .= ' (SELECT place_id, rank_search,';
|
$sSQL .= ' (SELECT place_id, rank_search,';
|
||||||
@@ -130,6 +134,7 @@ class ReverseGeocode
|
|||||||
if ($aPlacNode) {
|
if ($aPlacNode) {
|
||||||
return $aPlacNode;
|
return $aPlacNode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// still nothing, then return the country object
|
// still nothing, then return the country object
|
||||||
$sSQL = 'SELECT place_id, ST_distance('.$sPointSQL.', centroid) as distance';
|
$sSQL = 'SELECT place_id, ST_distance('.$sPointSQL.', centroid) as distance';
|
||||||
|
|||||||
@@ -59,3 +59,19 @@ Feature: Reverse geocoding
|
|||||||
Then results contain
|
Then results contain
|
||||||
| display_name |
|
| display_name |
|
||||||
| Tacuarembó, Uruguay |
|
| Tacuarembó, Uruguay |
|
||||||
|
|
||||||
|
Scenario Outline: Zoom levels below 5 result in country
|
||||||
|
When sending jsonv2 reverse coordinates -33.28,-56.29
|
||||||
|
| zoom |
|
||||||
|
| <zoom> |
|
||||||
|
Then results contain
|
||||||
|
| display_name |
|
||||||
|
| Uruguay |
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| zoom |
|
||||||
|
| 0 |
|
||||||
|
| 1 |
|
||||||
|
| 2 |
|
||||||
|
| 3 |
|
||||||
|
| 4 |
|
||||||
|
|||||||
Reference in New Issue
Block a user