X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/fcf7fcee03c8d9a67e1ecace61df81aa81201936..f78d094483da1c54ff51177cafa378406636b433:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index 76775d6c..afcc3c7f 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -615,3 +615,23 @@ function createPointsAroundCenter($fLon, $fLat, $fRadius) } return $aPolyPoints; } + +function closestHouseNumber($aRow) +{ + $fHouse = $aRow['startnumber'] + + ($aRow['endnumber'] - $aRow['startnumber']) * $aRow['fraction']; + + switch ($aRow['interpolationtype']) { + case 'odd': + $iHn = (int)($fHouse/2) * 2 + 1; + break; + case 'even': + $iHn = (int)(round($fHouse/2)) * 2; + break; + default: + $iHn = (int)(round($fHouse)); + break; + } + + return max(min($aRow['endnumber'], $iHn), $aRow['startnumber']); +}