$radius = 30000; $places = $square->findNearestPlace($radius); $pid = $places['pid']; } else { $gid = $recordSet->fields['gridsquare_id']; #$from_stratch = 1; if ($from_stratch || $recordSet->fields['reference_index'] == 2) { $square = new GridSquare(); #$square->_initFromArray($recordSet->fields); //store cols as members foreach ($recordSet->fields as $name => $value) { if (!is_numeric($name)) { $square->{$name} = $value; } } $square->_storeGridRef($square->grid_reference); $extra = ""; if (!isset($square->nateastings)) { $square->getNatEastings(); } //to optimise the query, we scan a square centred on the //the required point $radius = 100000; $places = $square->findNearestPlace($radius); $pid = $places['pid']; } else { //to optimise the query, we scan a square centred on the //the required point $radius = 100000; $left = $recordSet->fields['x'] - $radius; $right = $recordSet->fields['x'] + $radius;