Przeglądaj źródła

Allow <easting> / <northing> as an alternative to <postcode> in scraper xml response.

master
andy 15 lat temu
rodzic
commit
5e60d9288b
3 zmienionych plików z 32 dodań i 8 usunięć
  1. +12
    -0
      docs/include/scraper_support.php
  2. +1
    -1
      docs/templates/about.tpl
  3. +19
    -7
      tools/application_parser.php

+ 12
- 0
docs/include/scraper_support.php Wyświetl plik

@@ -308,6 +308,18 @@ function scrape_applications_islington ($search_url, $info_url_base, $comment_ur
return array_slice ($matches, 1);
}
function location_to_postcode($easting, $northing) {
$url = sprintf(
"http://streetmap.co.uk/streetmap.dll?GridConvert?name=%d,%d&type=OSGrid",
$easting, $northing);
$resp = @file($url);
if (is_array($resp)) $resp = join("\n", $resp);
$resp = strip_tags($resp);
// Kinda ghetto. Would be nice to have a nicer regex for postcodes.
if (preg_match('/Nearest\s+Post\s+Code\s+(\S+\s+\S+)/i', $resp, $mat))
return $mat[1];
return NULL;
}
function valid_email ($string) {
$valid = false;


+ 1
- 1
docs/templates/about.tpl Wyświetl plik

@@ -2,7 +2,7 @@

<p>You'd probably know if your next door neighbour was going to knock their house down (you'd get a letter through the door telling you they had applied for planning permission and asking you what you thought about it). But you probably never find out if the old cinema or pub 5 streets away is going to be converted into luxury flats until <a href="http://www.bbc.co.uk/cult/hitchhikers/gallery/tv/fordprosser.shtml">the bulldozers turned up</a>.</p>
<p>
PlanningAlerts.com is a free service built by <a href="http://www.memespring.co.uk">Richard Pope</a>, <a href="http://brainoff.com">Mikel Maron</a>, Sam Smith, Duncan Parkes and Tom Hughes. The site is kindly hosted by <a href="http://www.mysociety.org">mySociety.org</a>. It searches as many local authority planning websites as it can find and emails you details of applications near you. The aim of this to enable shared scrutiny of what is being built (and <a href="http://www.urban75.net/vbulletin/showthread.php?t=154006" title="Death of the Queen">knocked down</a>) in peoples communities.
PlanningAlerts.com is a free service built by <a href="http://www.memespring.co.uk">Richard Pope</a>, <a href="http://brainoff.com">Mikel Maron</a>, Sam Smith, Duncan Parkes, Tom Hughes and Andy Armstrong. The site is kindly hosted by <a href="http://www.mysociety.org">mySociety.org</a>. It searches as many local authority planning websites as it can find and emails you details of applications near you. The aim of this to enable shared scrutiny of what is being built (and <a href="http://www.urban75.net/vbulletin/showthread.php?t=154006" title="Death of the Queen">knocked down</a>) in peoples communities.
</p>

<h3 id="authorities">Planning authorities currently covered by the service</h3>


+ 19
- 7
tools/application_parser.php Wyświetl plik

@@ -148,7 +148,6 @@
}

$application->address = $parsed_application->address;
$application->postcode = $parsed_application->postcode;
$application->description = $parsed_application->description;
$application->info_url = $parsed_application->info_url;
$application->comment_url = $parsed_application->comment_url;
@@ -164,14 +163,27 @@
$this->store_log("ERROR: Created blank comment tiny url");
}

if (isset($parsed_application->postcode)) {
//Workout the XY location from postcode
$xy = postcode_to_location($parsed_application->postcode);
$application->postcode = $parsed_application->postcode;
$application->x = $xy[0];
$application->y = $xy[1];
}
else if (isset($parsed_application->easting) &&
isset($parsed_application->northing)) {
$postcode = location_to_postcode(
$parsed_application->easting,
$parsed_application->northing
);
$application->postcode = $postcode;
$application->x = $parsed_application->easting;
$application->y = $parsed_application->northing;
}

$application->info_tinyurl =$info_tiny_url;
$application->comment_tinyurl = $comment_tiny_url;
$application->map_url = googlemap_url_from_postcode($application->postcode);

//Workout the XY location from postcode
$xy = postcode_to_location($application->postcode);
$application->x = $xy[0];
$application->y = $xy[1];
//Add to array
array_push($return_applications, $application);
@@ -195,4 +207,4 @@
}

?>
?>

Ładowanie…
Anuluj
Zapisz