mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
include GB CodePoint data into location_postcode table
This commit is contained in:
@@ -1134,21 +1134,9 @@ class Geocode
|
||||
}
|
||||
if (CONST_Debug) var_Dump($aPhrases, $aValidTokens);
|
||||
|
||||
// Try and calculate GB postcodes we might be missing
|
||||
// US ZIP+4 codes - if there is no token, merge in the 5-digit ZIP code
|
||||
foreach ($aTokens as $sToken) {
|
||||
// Source of gb postcodes is now definitive - always use
|
||||
if (preg_match('/^([A-Z][A-Z]?[0-9][0-9A-Z]? ?[0-9])([A-Z][A-Z])$/', strtoupper(trim($sToken)), $aData)) {
|
||||
if (substr($aData[1], -2, 1) != ' ') {
|
||||
$aData[0] = substr($aData[0], 0, strlen($aData[1])-1).' '.substr($aData[0], strlen($aData[1])-1);
|
||||
$aData[1] = substr($aData[1], 0, -1).' '.substr($aData[1], -1, 1);
|
||||
}
|
||||
$aGBPostcodeLocation = gbPostcodeCalculate($aData[0], $aData[1], $aData[2], $this->oDB);
|
||||
if ($aGBPostcodeLocation) {
|
||||
$aValidTokens[$sToken] = $aGBPostcodeLocation;
|
||||
}
|
||||
} elseif (!isset($aValidTokens[$sToken]) && preg_match('/^([0-9]{5}) [0-9]{4}$/', $sToken, $aData)) {
|
||||
// US ZIP+4 codes - if there is no token,
|
||||
// merge in the 5-digit ZIP code
|
||||
if (!isset($aValidTokens[$sToken]) && preg_match('/^([0-9]{5}) [0-9]{4}$/', $sToken, $aData)) {
|
||||
if (isset($aValidTokens[$aData[1]])) {
|
||||
foreach ($aValidTokens[$aData[1]] as $aToken) {
|
||||
if (!$aToken['class']) {
|
||||
|
||||
19
lib/lib.php
19
lib/lib.php
@@ -116,25 +116,6 @@ function getTokensFromSets($aSets)
|
||||
}
|
||||
|
||||
|
||||
function gbPostcodeCalculate($sPostcode, $sPostcodeSector, $sPostcodeEnd, &$oDB)
|
||||
{
|
||||
// Try an exact match on the gb_postcode table
|
||||
$sSQL = 'select \'AA\', ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from gb_postcode where postcode = \''.$sPostcode.'\'';
|
||||
$aNearPostcodes = chksql($oDB->getAll($sSQL));
|
||||
|
||||
if (sizeof($aNearPostcodes)) {
|
||||
$aPostcodes = array();
|
||||
foreach ($aNearPostcodes as $aPostcode) {
|
||||
$aPostcodes[] = array('lat' => $aPostcode['lat'], 'lon' => $aPostcode['lon'], 'radius' => 0.005);
|
||||
}
|
||||
|
||||
return $aPostcodes;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getClassTypes()
|
||||
{
|
||||
return array(
|
||||
|
||||
Reference in New Issue
Block a user