-
Notifications
You must be signed in to change notification settings - Fork 1
/
sites.php
64 lines (63 loc) · 1.92 KB
/
sites.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<title>Paragliding Sites</title>
<link rel="stylesheet" type="text/css" href="style.css">
<?php include 'header.html'; ?>
</head>
<body>
<div class="container">
<?php
$iso_code = $_GET['country'];
$country_names = file_get_contents('https://restcountries.com/v3.1/all');
$country_names = json_decode($country_names, true);
foreach ($country_names as $country) {
if (strtolower($country['cca2']) == $iso_code) {
$country_name = $country['name']['common'];
break;
}
}
echo "<h1>Paragliding Sites in $country_name</h1>";
?>
<a href="generate_kml.php?country=<?php echo $iso_code; ?>" class="button">Download KML</a><br>
<table>
<tr>
<th>#</th>
<th>Name</th>
<th>Description</th>
<th>Altitude</th>
<th>Google Map</th>
<th>Paragliding Earth</th>
</tr>
<?php
$url = "http://www.paraglidingearth.com/api/geojson/getCountrySites.php?iso=$iso_code";
$data = file_get_contents($url);
$data = json_decode($data, true);
$sites = $data['features'];
usort($sites, function($a, $b) {
return strcmp($a['properties']['name'], $b['properties']['name']);
});
$count = 1;
foreach ($sites as $site) {
$name = $site['properties']['name'];
$description = $site['properties']['takeoff_description'];
$altitude = $site['properties']['takeoff_altitude'];
$latitude = $site['geometry']['coordinates'][1];
$longitude = $site['geometry']['coordinates'][0];
$link = $site['properties']['pge_link'];
echo "<tr>";
echo "<td>$count</td>";
echo "<td>$name</td>";
echo "<td>$description</td>";
echo "<td>$altitude</td>";
echo "<td><a href=https://www.google.com/maps/place/$latitude,$longitude>$latitude,$longitude</a></td>";
echo "<td><a href=\"$link\">PE Link</a></td>";
echo "</tr>";
$count++;
}
?>
</table>
</div>
</body>
</html>
<?php include 'footer.html'; ?>