]> git.openstreetmap.org Git - nominatim.git/commitdiff
adapt frontend to new interpolation table layout
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 26 Jan 2022 20:24:24 +0000 (21:24 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 27 Jan 2022 10:14:55 +0000 (11:14 +0100)
lib-php/PlaceLookup.php
lib-php/ReverseGeocode.php
lib-php/SearchDescription.php
test/bdd/db/import/interpolation.feature

index 09acb54444c86872fe1cd6682a15d7f2b0664c35..0e4b63bc6ba81335b2c7ec78f3f9fa17363adcdd 100644 (file)
@@ -405,7 +405,7 @@ class PlaceLookup
                 $sSQL .= '         CASE ';             // interpolate the housenumbers here
                 $sSQL .= '           WHEN startnumber != endnumber ';
                 $sSQL .= '           THEN ST_LineInterpolatePoint(linegeo, (housenumber_for_place-startnumber::float)/(endnumber-startnumber)::float) ';
-                $sSQL .= '           ELSE ST_LineInterpolatePoint(linegeo, 0.5) ';
+                $sSQL .= '           ELSE linegeo ';
                 $sSQL .= '         END as centroid, ';
                 $sSQL .= '         parent_place_id, ';
                 $sSQL .= '         housenumber_for_place ';
index 5a8528891b195399dd513424350a35d98638f04f..cccd5b35c97e5e6a37c14163d7a27b6048c28a86 100644 (file)
@@ -64,8 +64,8 @@ class ReverseGeocode
     {
         Debug::newFunction('lookupInterpolation');
         $sSQL = 'SELECT place_id, parent_place_id, 30 as rank_search,';
-        $sSQL .= '  ST_LineLocatePoint(linegeo,'.$sPointSQL.') as fraction,';
-        $sSQL .= '  startnumber, endnumber, interpolationtype,';
+        $sSQL .= '  (endnumber - startnumber) * ST_LineLocatePoint(linegeo,'.$sPointSQL.') as fhnr,';
+        $sSQL .= '  startnumber, endnumber, step,';
         $sSQL .= '  ST_Distance(linegeo,'.$sPointSQL.') as distance';
         $sSQL .= ' FROM location_property_osmline';
         $sSQL .= ' WHERE ST_DWithin('.$sPointSQL.', linegeo, '.$fSearchDiam.')';
@@ -363,7 +363,11 @@ class ReverseGeocode
 
                 if ($aHouse) {
                     $oResult = new Result($aHouse['place_id'], Result::TABLE_OSMLINE);
-                    $oResult->iHouseNumber = closestHouseNumber($aHouse);
+                    $iRndNum = max(0, round($aHouse['fhnr'] / $aHouse['step']) * $aHouse['step']);
+                    $oResult->iHouseNumber = $aHouse['startnumber'] + $iRndNum;
+                    if ($oResult->iHouseNumber > $aHouse['endnumber']) {
+                        $oResult->iHouseNumber = $aHouse['endnumber'];
+                    }
                     $aPlace = $aHouse;
                 }
             }
index 089f09c0d258d954701abcb4424604f489d79964..d6fa704fd2347b3ccc31fe7b954755f09d4ba95b 100644 (file)
@@ -769,18 +769,9 @@ class SearchDescription
             // if nothing found, search in the interpolation line table
             $sSQL = 'SELECT distinct place_id FROM location_property_osmline';
             $sSQL .= ' WHERE startnumber is not NULL';
-            $sSQL .= '  AND parent_place_id in ('.$sRoadPlaceIDs.') AND (';
-            if ($iHousenumber % 2 == 0) {
-                // If housenumber is even, look for housenumber in streets
-                // with interpolationtype even or all.
-                $sSQL .= "interpolationtype='even'";
-            } else {
-                // Else look for housenumber with interpolationtype odd or all.
-                $sSQL .= "interpolationtype='odd'";
-            }
-            $sSQL .= " or interpolationtype='all') and ";
-            $sSQL .= $iHousenumber.'>=startnumber and ';
-            $sSQL .= $iHousenumber.'<=endnumber';
+            $sSQL .= '  and parent_place_id in ('.$sRoadPlaceIDs.')';
+            $sSQL .= '  and ('.$iHousenumber.' - startnumber) % step = 0';
+            $sSQL .= '  and '.$iHousenumber.' between startnumber and endnumber';
             $sSQL .= $this->oContext->excludeSQL(' AND place_id');
 
             Debug::printSQL($sSQL);
index 4624705e848e5d4ae0c5bac76670b88d8f43a8d7..54d22962c5373cde05aad755c91d2c1fadc485cb 100644 (file)
@@ -347,7 +347,7 @@ Feature: Import of address interpolations
         Given the places
           | osm | class | type   | housenr | geometry |
           | N1  | place | house  | 0       | 1 1 |
-          | N2  | place | house  |       | 1 1.001 |
+          | N2  | place | house  | 10      | 1 1.001 |
         And the places
           | osm | class | type   | addr+interpolation | geometry |
           | W1  | place | houses | even     | 1 1, 1 1.001 |
@@ -357,8 +357,8 @@ Feature: Import of address interpolations
         When importing
         Then W1 expands to interpolation
           | start | end | geometry |
-          | 2     | 6   | 1 0002, 1 1.0008 |
+          | 2     | 8   | 1 1.0002, 1 1.0008 |
         When sending jsonv2 reverse coordinates 1,1
         Then results contain
           | ID | osm_type | osm_id | type  | display_name |
-          | 0  | way      | 1      | house | 0 |
+          | 0  | node     | 1      | house | 0 |