X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/4e99f8a3408d59f5c6bf8d934fda7bb3726f2da2..08f77067cb4b32c91f991924ff718a0508f0fbef:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index 3db3a825..9bf15964 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']); +}