]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/ReverseGeocode.php
UI: minimap causes main map not to initialize
[nominatim.git] / lib / ReverseGeocode.php
index 31ebe7174fa66e0ab76730c7d81fd2bb779c48bd..0bcd3d3313f71e87c381558d1bc674607daed462 100644 (file)
@@ -65,7 +65,7 @@ class ReverseGeocode
 
         return chksql(
             $this->oDB->getRow($sSQL),
-            "Could not determine closest housenumber on an osm interpolation line."
+            'Could not determine closest housenumber on an osm interpolation line.'
         );
     }
 
@@ -121,9 +121,17 @@ class ReverseGeocode
 
             $sSQL = 'select place_id,parent_place_id,rank_search,country_code,';
             $sSQL .= '  ST_distance('.$sPointSQL.', geometry) as distance';
-            $sSQL .= ' FROM placex';
-            $sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', geometry, '.$fSearchDiam.')';
-            $sSQL .= ' and rank_search != 28 and rank_search >= '.$iMaxRank;
+            $sSQL .= ' FROM ';
+            if ($fSearchDiam < 0.01) {
+                $sSQL .= ' placex';
+                $sSQL .= '   WHERE ST_DWithin('.$sPointSQL.', geometry, '.$fSearchDiam.')';
+                $sSQL .= '   AND';
+            } else {
+                $sSQL .= ' (SELECT * FROM placex ';
+                $sSQL .= '   WHERE ST_DWithin('.$sPointSQL.', geometry, '.$fSearchDiam.')';
+                $sSQL .= '   LIMIT 1000) as p WHERE';
+            }
+            $sSQL .= ' rank_search != 28 and rank_search >= '.$iMaxRank;
             $sSQL .= ' and (name is not null or housenumber is not null)';
             $sSQL .= ' and class not in (\'waterway\',\'railway\',\'tunnel\',\'bridge\',\'man_made\')';
             $sSQL .= ' and indexed_status = 0 ';
@@ -133,7 +141,7 @@ class ReverseGeocode
             if (CONST_Debug) var_dump($sSQL);
             $aPlace = chksql(
                 $this->oDB->getRow($sSQL),
-                "Could not determine closest place."
+                'Could not determine closest place.'
             );
             if ($aPlace) {
                 $oResult = new Result($aPlace['place_id']);
@@ -178,7 +186,7 @@ class ReverseGeocode
 
             $aPlaceTiger = chksql(
                 $this->oDB->getRow($sSQL),
-                "Could not determine closest Tiger place."
+                'Could not determine closest Tiger place.'
             );
             if ($aPlaceTiger) {
                 if (CONST_Debug) var_dump('found Tiger housenumber', $aPlaceTiger);
@@ -202,7 +210,7 @@ class ReverseGeocode
             $sSQL .= " WHERE place_id = $iPlaceID";
             $sSQL .= " ORDER BY abs(cached_rank_address - $iMaxRank) asc,cached_rank_address desc,isaddress desc,distance desc";
             $sSQL .= ' LIMIT 1';
-            $iPlaceID = chksql($this->oDB->getOne($sSQL), "Could not get parent for place.");
+            $iPlaceID = chksql($this->oDB->getOne($sSQL), 'Could not get parent for place.');
             if ($iPlaceID) {
                 $oResult = new Result($iPlaceID);
             }