if (!empty($_GET['east']) && !empty($_GET['north'])) {
            $osRef = new OSRef((int) $_GET['east'], (int) $_GET['north']);
            $latLng = $osRef->toLatLng();
            $latLng->OSGB36ToWGS84();
            $wp->latLng = $latLng;
        } else {
            if (!empty($_GET['gridref'])) {
                $osRef = getOSRefFromSixFigureReference($_GET['gridref']);
                $latLng = $osRef->toLatLng();
                $latLng->OSGB36ToWGS84();
                $wp->latLng = $latLng;
            }
        }
    }
    // Now do a reverse geocode & return the result
    $placeName = $wp->reverseGeocode();
    echo json_encode($placeName);
} else {
    if (!empty($_GET['postcode']) || !empty($_GET['search'])) {
        $options = array("format=json", "accept-language=en-gb,en", "countrycodes=gb");
        // 	if (!empty($_GET['scope']))
        // 	{
        // 		if ($_GET['scope'] == $scopeSheffield)
        // 			$viewbox = array('l'=>-1.6, 't'=>53.45, 'r'=>-1.3, 'b'=>53.3);
        // 		else if ($_GET['scope'] == $scopeGeneralArea)
        // 			$viewbox = array('l'=>-2.1, 't'=>53.6, 'r'=>-1.2, 'b'=>53.0);
        //
        // 		$options[] = "viewbox=".implode(",", $viewbox);
        // 	}
        if (!empty($_GET['postcode'])) {
            // Strip spaces and validate