X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/42f079c35582f95381eee8f7406d3b2054204c51..1424e8e29bd54d3f713a38a834ff0c8ff5f463fb:/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']); +}