Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added electoral district data to XML, JSON, RDF and CSV versions

  • Loading branch information...
commit e023913f75034c937124d8c6a3ea78d9e9da8069 1 parent a385ccb
pezholio authored
Showing with 13 additions and 5 deletions.
  1. +1 −1  csv.php
  2. +2 −0  json.php
  3. +3 −1 rdf.php
  4. +7 −3 xml.php
2  csv.php
View
@@ -1,7 +1,7 @@
<?php
if ($single) {
header("Content-Disposition: attachment; filename=\"". $postcode .".csv\"");
-echo $postcode .",". $lat .",". $lng. ",". $easting .",". $northing .",". $geohash .",". $row['county'] . ",". $countytitle .",". $row['district'] .",". $districttitle .",". $row['ward'].",".$wardtitle;
+echo $postcode .",". $lat .",". $lng. ",". $easting .",". $northing .",". $geohash .",". $row['county'] . ",". $countytitle . ",".$edistrict['name'].",".$edistrict['code'].",".$row['district'] .",". $districttitle .",". $row['ward'].",".$wardtitle;
} elseif ($distance) {
header("Content-Disposition: attachment; filename=\"".$distance." miles of ". $title .".csv\"");
while ($row = mysql_fetch_array($result)) {
2  json.php
View
@@ -10,6 +10,8 @@
if ($row['county'] != "00") {
$result['administrative']['county']['title'] = $countytitle;
$result['administrative']['county']['uri'] = "http://statistics.data.gov.uk/id/local-authority/". $row['county'];
+$result['administrative']['countyelectoral']['title'] = $edistrict['name'];
+$result['administrative']['countyelectoral']['uri'] = $edistrict['uri'];
}
$result['administrative']['district']['title'] = $districttitle;
$result['administrative']['district']['uri'] = "http://statistics.data.gov.uk/id/local-authority/". $row['county'] . $row['district'];
4 rdf.php
View
@@ -2,7 +2,7 @@
if ($single) {
$row['postcode'] = str_replace(" ", "", $row['postcode']);
?>
-<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:spatialrelations="http://data.ordnancesurvey.co.uk/ontology/spatialrelations/" xmlns:admingeo="http://statistics.data.gov.uk/def/administrative-geography/" xmlns:elecgeo="http://statistics.data.gov.uk/def/electoral-geography/" >
+<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:spatialrelations="http://data.ordnancesurvey.co.uk/ontology/spatialrelations/" xmlns:admingeo="http://statistics.data.gov.uk/def/administrative-geography/" xmlns:elecgeo="http://statistics.data.gov.uk/def/electoral-geography/" xmlns:osadmingeo="http://data.ordnancesurvey.co.uk/ontology/admingeo/" >
<rdf:Description rdf:about="http://www.uk-postcodes.com/postcode/<?php echo strtoupper($row['postcode']); ?>">
<geo:lat rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal"><?php echo $lat; ?></geo:lat>
<geo:long rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal"><?php echo $lng; ?></geo:long>
@@ -10,11 +10,13 @@
<spatialrelations:northing rdf:datatype="http://www.w3.org/2001/XMLSchema#float"><?php echo $northing; ?></spatialrelations:northing>
<?php if ($row['county'] != "00") { ?>
<spatialrelations:t_spatiallyInside rdf:resource="http://statistics.data.gov.uk/id/local-authority/<?php echo $row['county']; ?>" />
+ <spatialrelations:t_spatiallyInside rdf:resource="<?php echo $edistrict['uri']; ?>" />
<?php } ?>
<spatialrelations:t_spatiallyInside rdf:resource="http://statistics.data.gov.uk/id/local-authority/<?php echo $row['county']; ?><?php echo $row['district']; ?>" />
<spatialrelations:t_spatiallyInside rdf:resource="http://statistics.data.gov.uk/id/electoral-ward/<?php echo $row['county']; ?><?php echo $row['district']; ?><?php echo $row['ward']; ?>" />
<?php if ($row['county'] != "00") { ?>
<admingeo:localAuthority rdf:resource="http://statistics.data.gov.uk/id/local-authority/<?php echo $row['county']; ?>" />
+ <osadmingeo:CountyElectoralDivision rdf:resource="<?php echo $edistrict['uri']; ?>" />
<?php } ?>
<admingeo:localAuthority rdf:resource="http://statistics.data.gov.uk/id/local-authority/<?php echo $row['county']; ?><?php echo $row['district']; ?>" />
<elecgeo:ward rdf:resource="http://statistics.data.gov.uk/id/electoral-ward/<?php echo $row['county']; ?><?php echo $row['district']; ?><?php echo $row['ward']; ?>" />
10 xml.php
View
@@ -15,16 +15,20 @@
if ($row['county'] != "00") {
?>
<county>
- <title><?php echo $countytitle; ?></title>
+ <title><?php echo htmlentities($countytitle); ?></title>
<uri>http://statistics.data.gov.uk/id/local-authority/<?php echo $row['county']; ?></uri>
</county>
+ <electoral-district>
+ <title><?php echo htmlentities($edistrict['name']); ?></title>
+ <uri><?php echo $edistrict['uri']; ?></uri>
+ </electoral-district>
<?php } ?>
<district>
- <title><?php echo $districttitle; ?></title>
+ <title><?php echo htmlentities($districttitle); ?></title>
<uri>http://statistics.data.gov.uk/id/local-authority/<?php echo $row['county'] . $row['district']; ?></uri>
</district>
<ward>
- <title><?php echo $wardtitle; ?></title>
+ <title><?php echo htmlentities($wardtitle); ?></title>
<uri>http://statistics.data.gov.uk/id/electoral-ward/<?php echo $row['county'] . $row['district'] . $row['ward']; ?></uri>
</ward>
</administrative>
Please sign in to comment.
Something went wrong with that request. Please try again.