Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
647 additions
and
30 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
// Author: Joshua Melville | ||
// | ||
// Take the post code shapefile geojson and the csv twitter data the merge the two, so that | ||
// each geojson feature contains the twitter numbers for every team | ||
// | ||
|
||
// ini_set("precision", "50"); | ||
header('Content-Type: application/json'); | ||
|
||
function csvtogeojson($file) { | ||
|
||
$row = 1; | ||
$array = array(); | ||
$feature = array(); | ||
if (($handle = fopen($file, "r")) !== FALSE) { | ||
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | ||
if ($row == 1) { | ||
$fields = $data; | ||
} else { | ||
foreach ($fields as $key => $value) { | ||
if (is_numeric($data[$key])) { $data[$key] = $data[$key]* 10000; } | ||
$feature['properties'][$value] = $data[$key]; | ||
// echo "key =".$key." value not found: ".$value." for data point: ".$data[2]."<br>"; | ||
|
||
} | ||
|
||
|
||
} | ||
$feature['shortcode'] = $data[2]; | ||
$array[] = $feature; | ||
$row++; | ||
|
||
unset($feature); | ||
|
||
} | ||
fclose($handle); | ||
} | ||
|
||
return $array; | ||
} | ||
|
||
$area_codes = json_decode(file_get_contents("data/uk_post_areas.geojson"), true); | ||
|
||
// $fields = array("id","OBJECTID","post_2","Shape_Leng","Shape_Area","arsenal","astonvilla","chelsea","everton","fulham","liverpool","manchestercity","manchesterunited","newcastleunited","norwichcity","queensparkrangers","random","reading","southampton","stokecity","sunderland","swanseacity","tottenhamhotspur","westbromwichalbion","westhamunited","wiganathletic","arsenal_lq","arsenal_norm","astonvilla_lq","astonvilla_norm","chelsea_lq","chelsea_norm","everton_lq","everton_norm","fulham_lq","fulham_norm","liverpool_lq","liverpool_norm","manchestercity_lq","manchestercity_norm","manchesterunited_lq","manchesterunited_norm","newcastleunited_lq","newcastleunited_norm","norwichcity_lq","norwichcity_norm","queensparkrangers_lq","queensparkrangers_norm","random_lq","random_norm","reading_lq","reading_norm","southampton_lq","southampton_norm","stokecity_lq","stokecity_norm","sunderland_lq","sunderland_norm","swanseacity_lq","swanseacity_norm","tottenhamhotspur_lq","tottenhamhotspur_norm","westbromwichalbion_lq","westbromwichalbion_norm","westhamunited_lq","westhamunited_norm","wiganathletic_lq","wiganathletic_norm"); | ||
$twitter_data = csvtogeojson('data/areas_user.csv'); | ||
|
||
foreach ($area_codes['features'] as $key => $value) { | ||
|
||
$current_code = $area_codes['features'][$key]['properties']['post_2']; | ||
|
||
foreach($twitter_data as $data_key => $data_value) { | ||
if ($twitter_data[$data_key]['shortcode'] == $current_code) { | ||
$area_codes['features'][$key]['twitter_data'] = $twitter_data[$data_key]['properties']; | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
echo "var area_codes = ".json_encode($area_codes); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
rivalries=[ | ||
{ | ||
"team1": "Manchester United", | ||
"team1_crest": "img/crests/Manchester_United_FC.png", | ||
"team2": "Manchester City", | ||
"team2_crest": "img/crests/Manchester_City.png", | ||
"rivalry_info": "The Manchester derby." | ||
}, | ||
{ | ||
"team1": "Arsenal", | ||
"team1_crest": "img/crests/Arsenal_FC.png", | ||
"team2": "Tottenham Hotspur", | ||
"team2_crest": "img/crests/Tottenham_Hotspur.png", | ||
"rivalry_info": "The north London derby." | ||
"teams": [{ | ||
"name": "Manchester United", | ||
"crest": "img/crests/Manchester_United_FC.png", | ||
"color": "#d02d3e", | ||
"variable": "manchesterunited" | ||
}, | ||
{ | ||
"name": "Manchester City", | ||
"crest": "img/crests/Manchester_City.png", | ||
"color": "#8CBED6", | ||
"variable": "manchestercity" | ||
}], | ||
"rivalry_info": "The Manchester derby.", | ||
"centre_map": [54.2323,-01,2345] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
// $number = filter_var("4.39239E-05", FILTER_VALIDATE_FLOAT); | ||
$num = 4.39239E-05; | ||
// $n = 4.39518e+7; | ||
$num = $num*100000; //YOUR NUMBER | ||
printf("SCINO = '%e'\n", $num); | ||
//%e specifies sci-notation | ||
|
||
|
||
printf("FLOAT = '%d'\n", $num); | ||
// %d specifies decimal | ||
|
||
|
||
?> |