From: Sarah Hoffmann Date: Wed, 26 Jan 2022 20:24:24 +0000 (+0100) Subject: adapt frontend to new interpolation table layout X-Git-Tag: v4.1.0~88^2~5 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/6b89624f339dbf36bd668d83b3d0b12edc62f616 adapt frontend to new interpolation table layout --- diff --git a/lib-php/PlaceLookup.php b/lib-php/PlaceLookup.php index 09acb544..0e4b63bc 100644 --- a/lib-php/PlaceLookup.php +++ b/lib-php/PlaceLookup.php @@ -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 '; diff --git a/lib-php/ReverseGeocode.php b/lib-php/ReverseGeocode.php index 5a852889..cccd5b35 100644 --- a/lib-php/ReverseGeocode.php +++ b/lib-php/ReverseGeocode.php @@ -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; } } diff --git a/lib-php/SearchDescription.php b/lib-php/SearchDescription.php index 089f09c0..d6fa704f 100644 --- a/lib-php/SearchDescription.php +++ b/lib-php/SearchDescription.php @@ -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); diff --git a/test/bdd/db/import/interpolation.feature b/test/bdd/db/import/interpolation.feature index 4624705e..54d22962 100644 --- a/test/bdd/db/import/interpolation.feature +++ b/test/bdd/db/import/interpolation.feature @@ -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 | 8 | 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 |