From b61ad88fecc6392deffbe589d5d524c497c059f5 Mon Sep 17 00:00:00 2001 From: memespring Date: Mon, 5 Oct 2009 12:52:26 +0000 Subject: [PATCH] fixes --- data/%%45^45E^45E480CD%%index.tpl.php | 2 +- data/%%F7^F7F^F7F34188%%header.tpl.php | 2 +- docs/include/scraper_support.php | 17 +++++++++++------ docs/preview.php | 23 ++++++++++++++++------- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/data/%%45^45E^45E480CD%%index.tpl.php b/data/%%45^45E^45E480CD%%index.tpl.php index 330f45d..cf97fc7 100644 --- a/data/%%45^45E^45E480CD%%index.tpl.php +++ b/data/%%45^45E^45E480CD%%index.tpl.php @@ -1,4 +1,4 @@ - _tpl_vars; $this->_smarty_include(array('smarty_include_tpl_file' => "header.tpl", 'smarty_include_vars' => array())); diff --git a/data/%%F7^F7F^F7F34188%%header.tpl.php b/data/%%F7^F7F^F7F34188%%header.tpl.php index 6c22f35..ccffb36 100644 --- a/data/%%F7^F7F^F7F34188%%header.tpl.php +++ b/data/%%F7^F7F^F7F34188%%header.tpl.php @@ -1,4 +1,4 @@ - diff --git a/docs/include/scraper_support.php b/docs/include/scraper_support.php index 8583c49..6eade40 100644 --- a/docs/include/scraper_support.php +++ b/docs/include/scraper_support.php @@ -297,15 +297,20 @@ function scrape_applications_islington ($search_url, $info_url_base, $comment_ur $clean_postcode = strtolower($postcode); $clean_postcode = str_replace(" ","+", $clean_postcode); - $url = "http://www.streetmap.co.uk/newsearch.srf?type=Postcode&name=" . $clean_postcode; + $url = "http://ernestmarples.com/?p=sw98jx&f=csv"; + $result = file_get_contents($url); + $result = split(",", $result); + if(count($result) != 2){ + trigger_error("No lat/long could be found"); + } + $lat = $result[0]; + $lng = $result[1]; - $headers = get_headers($url, 1); - $location = $headers["Location"]; - $location_regex = "/x=(\d*)&y=(\d*)&/"; + $LatLng = new LatLng($lat, $lng); + $OSBG = $LatLng->toOSRef(); - preg_match ($location_regex, $location, $matches); + $return = array($OSBG->easting, $OSBG->northing); - return array_slice ($matches, 1); } function location_to_postcode($easting, $northing) { diff --git a/docs/preview.php b/docs/preview.php index 7386df2..5e8cd9e 100644 --- a/docs/preview.php +++ b/docs/preview.php @@ -32,17 +32,26 @@ class preview_page { if (!isset($_GET['area_size'])){ $this->warnings .= "No area size specified "; } - - if ($this->warnings == ""){ - + + if ($this->warnings == ""){ + + $url = "http://ernestmarples.com/?p=sw98jx&f=csv"; + $result = file_get_contents($url); + $result = split(",", $result); + if(count($result) != 2){ + trigger_error("No lat/long could be found"); + } + $lat = $result[0]; + $lng = $result[1]; + //Get OS ref from postcode $xy = postcode_to_location($_GET['postcode']); //Get the centroid long / lat (google maps doesnt handle grid refs) - $os_ref = new OSRef($xy[0], $xy[1]); - $long_lat = $os_ref->toLatLng(); - $this->center_long = $long_lat->lng; - $this->center_lat = $long_lat->lat; + //$os_ref = new OSRef($xy[0], $xy[1]); + //$long_lat = $os_ref->toLatLng(); + $this->center_long = $lng; //$long_lat->lng; + $this->center_lat = $lat; //$long_lat->lat; //get long lat for the bounding box (OS grid refs are in meters in case you were wondering)