]> git.openstreetmap.org Git - nominatim.git/commitdiff
use the linked_place_id for adress search if a place node is found with a linked_place_id
authorgemo1011 <moritzgeiger91@web.de>
Fri, 20 Apr 2018 12:35:24 +0000 (14:35 +0200)
committergemo1011 <moritzgeiger91@web.de>
Tue, 5 Jun 2018 09:54:12 +0000 (11:54 +0200)
lib/ReverseGeocode.php

index a241692938fedfe9c9fd298ae58367318edb49a0..ae7c852766781019a2c149f1ca3ff7e9bf379f0e 100644 (file)
@@ -89,7 +89,7 @@ class ReverseGeocode
             $iRankSearch = $aPoly['rank_search'];
             $iGeometry = $aPoly['geometry'];
             
-            $sSQL = 'select place_id,parent_place_id,rank_search,country_code,';
+            $sSQL = 'select place_id,parent_place_id,rank_search,country_code, linked_place_id,';
             $sSQL .='  ST_distance('.$sPointSQL.', geometry) as distance';
             $sSQL .= ' FROM placex';
             $sSQL .= ' WHERE osm_type = \'N\'';
@@ -194,17 +194,26 @@ class ReverseGeocode
                 }else{
                     $aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank);
                     if ($aPlace) {
-                        $oResult = new Result($aPlace['place_id']);
+                        // if place node is found adress goes over linked_place_id
+                        if (!empty($aPlace['linked_place_id'])) {
+                            $oResult = new Result($aPlace['linked_place_id']);
+                        }else{
+                            $oResult = new Result($aPlace['place_id']);
+                        }
                     }
                 }
             // lower than street level ($iMaxRank < 26 )
             }else{
                 $aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank);
                 if ($aPlace) {
-                    $oResult = new Result($aPlace['place_id']);
+                // if place node is found adress goes over linked_place_id
+                    if (!empty($aPlace['linked_place_id'])) {
+                        $oResult = new Result($aPlace['linked_place_id']);
+                    }else{
+                        $oResult = new Result($aPlace['place_id']);
+                    }
+                }
             }
-            
-        }  
         return $oResult;
     }