From e081983bcd36e396cebfe2259815a2358741d60a Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 11 Feb 2012 09:19:42 +0000 Subject: [PATCH] enable exact search of GB postcodes in aux postcode data, partial search still disabled due to performance problems --- lib/lib.php | 6 +++++- website/search.php | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/lib.php b/lib/lib.php index 20b1f8ce..d04c191b 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -179,6 +179,10 @@ return array(array('lat' => $aNearPostcodes[0]['lat'], 'lon' => $aNearPostcodes[0]['lon'], 'radius' => 0.005)); } + return false; + + /* partial search disabled because it sequentially scans placex + $sSQL = 'select substring(upper(postcode) from \'^[A-Z][A-Z]?[0-9][0-9A-Z]? [0-9]([A-Z][A-Z])$\'),ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from placex where country_code::text = \'gb\'::text AND substring(postcode from \'^([A-Z][A-Z]?[0-9][0-9A-Z]? [0-9])[A-Z][A-Z]$\') = \''.$sPostcodeSector.'\' and class=\'place\' and type=\'postcode\' '; $sSQL .= ' union '; $sSQL .= 'select substring(upper(postcode) from \'^[A-Z][A-Z]?[0-9][0-9A-Z]? [0-9]([A-Z][A-Z])$\'),ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from gb_postcode where substring(postcode from \'^([A-Z][A-Z]?[0-9][0-9A-Z]? [0-9])[A-Z][A-Z]$\') = \''.$sPostcodeSector.'\''; @@ -217,7 +221,7 @@ return array(array('lat' => $fLat, 'lon' => $fLon, 'radius' => $fRadius)); } return false; - + */ /* $fTotalFac is a suprisingly good indicator of accuracy $iZoom = 18 + round(log($fTotalFac,32)); diff --git a/website/search.php b/website/search.php index 7169c829..37ddd23c 100755 --- a/website/search.php +++ b/website/search.php @@ -354,7 +354,7 @@ } } if ($bSuggestion) $sSuggestion = join(', ',$aSuggestion); -/* + // Try and calculate GB postcodes we might be missing foreach($aTokens as $sToken) { @@ -372,7 +372,6 @@ } } } -*/ foreach($aTokens as $sToken) { -- 2.45.2