forked from Ysurac/FlightAirMap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
airport-geojson.php
66 lines (63 loc) · 2.54 KB
/
airport-geojson.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
64
65
66
<?php
require_once('require/class.Connection.php');
require_once('require/class.Spotter.php');
require_once('require/class.Language.php');
$Spotter = new Spotter();
if (isset($_GET['download']))
{
header('Content-disposition: attachment; filename="airports.geojson"');
}
header('Content-Type: text/javascript');
if (isset($_GET['coord']))
{
$coords = explode(',',$_GET['coord']);
$spotter_array = $Spotter->getAllAirportInfobyCoord($coords);
} else {
$spotter_array = $Spotter->getAllAirportInfo();
//$spotter_array = $Spotter->getAllAirportInfobyCountry(array('France','Switzerland'));
}
$output = '{"type": "FeatureCollection","features": [';
if (!empty($spotter_array))
{
foreach($spotter_array as $spotter_item)
{
date_default_timezone_set('UTC');
//waypoint plotting
$output .= '{"type": "Feature",';
$output .= '"properties": {';
$output .= '"name": '.json_encode(str_replace('"',"'",$spotter_item['name'])).',';
$output .= '"city": '.json_encode(str_replace('"',"'",$spotter_item['city'])).',';
$output .= '"country": "'.$spotter_item['country'].'",';
$output .= '"altitude": "'.$spotter_item['altitude'].'",';
$output .= '"popupContent": '.json_encode(str_replace('"',"'",$spotter_item['name']).' : '.str_replace('"',"'",$spotter_item['city']).', '.$spotter_item['country']).',';
if ($spotter_item['type'] == 'large_airport') {
$output .= '"icon": "'.$globalURL.'/images/airport.png",';
} elseif ($spotter_item['type'] == 'heliport') {
$output .= '"icon": "'.$globalURL.'/images/heliport.png",';
} elseif ($spotter_item['type'] == 'military') {
$output .= '"icon": "'.$globalURL.'/images/military.png",';
} elseif ($spotter_item['type'] == 'medium_airport') {
$output .= '"icon": "'.$globalURL.'/images/medium_airport.png",';
} else {
$output .= '"icon": "'.$globalURL.'/images/small_airport.png",';
}
$output .= '"type": "'.$spotter_item['type'].'",';
$output .= '"icao": "'.$spotter_item['icao'].'",';
$output .= '"iata": "'.$spotter_item['iata'].'",';
$output .= '"homepage": "'.$spotter_item['home_link'].'",';
$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
// $output .= '"photo": "'.$spotter_item['image_thumbnail'].'",';
$output .= '},';
$output .= '"geometry": {';
$output .= '"type": "Point",';
$output .= '"coordinates": [';
$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
$output .= ']';
$output .= '}';
$output .= '},';
}
$output = substr($output, 0, -1);
}
$output .= ']}';
print $output;
?>