-function getWordSets($aWords, $iDepth)
-{
- $aResult = array(array(join(' ', $aWords)));
- $sFirstToken = '';
- if ($iDepth < 7) {
- while (sizeof($aWords) > 1) {
- $sWord = array_shift($aWords);
- $sFirstToken .= ($sFirstToken?' ':'').$sWord;
- $aRest = getWordSets($aWords, $iDepth+1);
- foreach ($aRest as $aSet) {
- $aResult[] = array_merge(array($sFirstToken), $aSet);
- }
- }
- }
- return $aResult;
-}
-
-function getInverseWordSets($aWords, $iDepth)
-{
- $aResult = array(array(join(' ', $aWords)));
- $sFirstToken = '';
- if ($iDepth < 8) {
- while (sizeof($aWords) > 1) {
- $sWord = array_pop($aWords);
- $sFirstToken = $sWord.($sFirstToken?' ':'').$sFirstToken;
- $aRest = getInverseWordSets($aWords, $iDepth+1);
- foreach ($aRest as $aSet) {
- $aResult[] = array_merge(array($sFirstToken), $aSet);
- }
- }
- }
- return $aResult;
-}
-
-
-function getTokensFromSets($aSets)
-{
- $aTokens = array();
- foreach ($aSets as $aSet) {
- foreach ($aSet as $sWord) {
- $aTokens[' '.$sWord] = ' '.$sWord;
- $aTokens[$sWord] = $sWord;
- }
- }
- return $aTokens;
-}
-
-
-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;
-}
-
-