-
Notifications
You must be signed in to change notification settings - Fork 159
/
notam-geojson.php
94 lines (89 loc) · 3.84 KB
/
notam-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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
require_once('require/class.Connection.php');
require_once('require/class.NOTAM.php');
$NOTAM = new NOTAM();
if (isset($_GET['download']))
{
header('Content-disposition: attachment; filename="notam.geojson"');
}
header('Content-Type: text/javascript');
if (isset($_GET['coord']))
{
$coords = explode(',',$_GET['coord']);
if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] != '' && $_COOKIE['notamscope'] != 'All') {
$scope = filter_var($_COOKIE['notamscope'],FILTER_SANITIZE_STRING);
$spotter_array = $NOTAM->getAllNOTAMbyCoordScope($coords,$scope);
} elseif (isset($_GET['scope']) && $_GET['scope'] != '' && $_GET['scope'] != 'All') {
$scope = filter_input(INPUT_GET,'scope',FILTER_SANITIZE_STRING);
$spotter_array = $NOTAM->getAllNOTAMbyCoordScope($coords,$scope);
} else {
$spotter_array = $NOTAM->getAllNOTAMbyCoord($coords);
}
// $spotter_array = $NOTAM->getAllNOTAM();
} else {
if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] != '' && $_COOKIE['notamscope'] != 'All') {
$scope = filter_var($_COOKIE['notamscope'],FILTER_SANITIZE_STRING);
$spotter_array = $NOTAM->getAllNOTAMbyScope($scope);
} elseif (isset($_GET['scope']) && $_GET['scope'] != '' && $_GET['scope'] != 'All') {
$scope = filter_input(INPUT_GET,'scope',FILTER_SANITIZE_STRING);
$spotter_array = $NOTAM->getAllNOTAMbyCoordScope($coords,$scope);
} else {
$spotter_array = $NOTAM->getAllNOTAM();
}
}
$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 .= '"ref": "'.$spotter_item['ref'].'",';
$output .= '"title": "'.$spotter_item['title'].'",';
$output .= '"fir": "'.$spotter_item['fir'].'",';
$output .= '"text": "'.str_replace(array("\r\n", "\r", "\n"),'<br />',str_replace(array('"',"\t"), '',$spotter_item['notam_text'])).'",';
$output .= '"latitude": '.$spotter_item['center_latitude'].',';
$output .= '"longitude": '.$spotter_item['center_longitude'].',';
$output .= '"lower_limit": '.$spotter_item['lower_limit'].',';
$output .= '"upper_limit": '.$spotter_item['upper_limit'].',';
// $output .= '"altitude": "'.$spotter_item['altitude'].'",';
// $output .= '"popupContent": "'.$spotter_item['ref'].' : '.$spotter_item['title'].'",';
// $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'].'",';
// if ($spotter_item['radius'] > 30) $spotter_item['radius'] = 30;
if ($spotter_item['scope'] == 'Airport warning') {
$output .= '"color": "#EACC04",';
} elseif ($spotter_item['scope'] == 'Airport/Enroute warning') {
$output .= '"color": "#EA7D00",';
} elseif ($spotter_item['scope'] == 'Airport/Navigation warning') {
$output .= '"color": "#DBEA00",';
} elseif ($spotter_item['scope'] == 'Navigation warning') {
$output .= '"color": "#BBEA00",';
} else {
$output .= '"color": "#FF0000",';
}
$radius = $spotter_item['radius']*1852;
$output .= '"radiusm": "'.$radius.'",';
$output .= '"radiusnm": "'.$spotter_item['radius'].'",';
if ($radius > 25000) $radius = 25000;
$output .= '"radius": '.$radius.'';
$output .= '},';
$output .= '"geometry": {';
$output .= '"type": "Point",';
$output .= '"coordinates": [';
$output .= $spotter_item['center_longitude'].', '.$spotter_item['center_latitude'];
$output .= ']';
$output .= '}';
$output .= '},';
}
$output = substr($output, 0, -1);
}
$output .= ']}';
print $output;
?>