-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathwaypoints-geojson.php
164 lines (157 loc) · 6.64 KB
/
waypoints-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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
require_once('require/class.Connection.php');
require_once('require/class.Spotter.php');
$Spotter = new Spotter();
if (isset($_GET['download']))
{
header('Content-disposition: attachment; filename="waypoints.geojson"');
}
header('Content-Type: text/javascript');
if (isset($_GET['coord']))
{
$coords = explode(',',$_GET['coord']);
$spotter_array = $Spotter->getAllWaypointsInfobyCoord($coords);
} else {
die;
}
$output = '{"type": "FeatureCollection","features": [';
if (!empty($spotter_array))
{
// print_r($spotter_array);
foreach($spotter_array as $spotter_item)
{
date_default_timezone_set('UTC');
//waypoint plotting
$output .= '{"type": "Feature",';
$output .= '"properties": {';
$output .= '"segment_name": "'.$spotter_item['segment_name'].'",';
$output .= '"base": "'.$spotter_item['base'].'",';
$output .= '"top": "'.$spotter_item['top'].'",';
$output .= '"name_begin": "'.$spotter_item['name_begin'].'",';
$output .= '"name_end": "'.$spotter_item['name_end'].'",';
// $output .= '"ident": "'.$spotter_item['name_begin'].'",';
// $output .= '"popupContent": "'.$spotter_item['name_begin'].'",';
/* if ($spotter_item['usage'] == 'RNAV') {
$output .= '"icon": "images/flag_green.png"';
} elseif ($spotter_item['usage'] == 'High Level') {
$output .= '"icon": "images/flag_red.png"';
} elseif ($spotter_item['usage'] == 'Low Level') {
$output .= '"icon": "images/flag_yellow.png"';
} elseif ($spotter_item['usage'] == 'High and Low Level') {
$output .= '"icon": "images/flag_orange.png"';
} elseif ($spotter_item['usage'] == 'Terminal') {
$output .= '"icon": "images/flag_finish.png"';
} else {*/
$output .= '"icon": "images/flag_blue.png",';
$output .= '"stroke": "#f0f0f0",';
$output .= '"stroke-width": 2';
// }
$output .= '},';
$output .= '"geometry": {';
$output .= '"type": "LineString",';
$output .= '"coordinates": [';
//$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].'], ['.$spotter_item['longitude_end_seg2'].', '.$spotter_item['latitude_end_seg2'].']';
$output .= '['.$spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].','.round($spotter_item['base']*100*0.3048).'], ['.$spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].','.round($spotter_item['base']*100*0.3048).']';
// $output .= '['.$spotter_item['latitude_begin'].', '.$spotter_item['longitude_begin'].'], ['.$spotter_item['latitude_end'].', '.$spotter_item['longitude_end'].']';
$output .= ']';
$output .= '}';
/* $output .= '"geometry": {';
$output .= '"type": "Point",';
$output .= '"coordinates": [';
$output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'];
$output .= ']';
$output .= '}';
*/
$output .= '},';
//waypoint plotting
$output .= '{"type": "Feature",';
$output .= '"properties": {';
$output .= '"ident": "'.$spotter_item['name_begin'].'",';
$output .= '"high": "'.$spotter_item['high'].'",';
$output .= '"alt": "'.$spotter_item['base'].'",';
// $output .= '"popupContent": "'.$spotter_item['name_begin'].'",';
if ($spotter_item['high'] == '') {
$output .= '"icon": "images/flag_green.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#00aa00"';
} elseif ($spotter_item['high'] == '2') {
$output .= '"icon": "images/flag_red.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#ff0000"';
} elseif ($spotter_item['high'] == '1') {
$output .= '"icon": "images/flag_yellow.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#ffff00"';
// } elseif ($spotter_item['usage'] == 'High and Low Level') {
// $output .= '"icon": "images/flag_orange.png"';
// } elseif ($spotter_item['usage'] == 'Terminal') {
// $output .= '"icon": "images/flag_finish.png"';
} else {
$output .= '"icon": "images/flag_blue.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#0000ff"';
}
$output .= '},';
$output .= '"geometry": {';
$output .= '"type": "Point",';
$output .= '"coordinates": [';
$output .= $spotter_item['longitude_begin'].', '.$spotter_item['latitude_begin'].', '.round($spotter_item['base']*100*0.3048);;
$output .= ']';
$output .= '}';
$output .= '},';
$output .= '{"type": "Feature",';
$output .= '"properties": {';
$output .= '"ident": "'.$spotter_item['name_end'].'",';
$output .= '"high": "'.$spotter_item['high'].'",';
$output .= '"alt": "'.$spotter_item['top'].'",';
// $output .= '"popupContent": "'.$spotter_item['name_begin'].'",';
if ($spotter_item['high'] == '') {
$output .= '"icon": "images/flag_green.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#00aa00"';
} elseif ($spotter_item['high'] == '2') {
$output .= '"icon": "images/flag_red.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#ff0000"';
} elseif ($spotter_item['high'] == '1') {
$output .= '"icon": "images/flag_yellow.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#ffff00"';
/* if ($spotter_item['usage'] == 'RNAV') {
$output .= '"icon": "images/flag_green.png"';
} elseif ($spotter_item['usage'] == 'High Level') {
$output .= '"icon": "images/flag_red.png"';
} elseif ($spotter_item['usage'] == 'Low Level') {
$output .= '"icon": "images/flag_yellow.png"';
} elseif ($spotter_item['usage'] == 'High and Low Level') {
$output .= '"icon": "images/flag_orange.png"';
} elseif ($spotter_item['usage'] == 'Terminal') {
$output .= '"icon": "images/flag_finish.png"';
*/
} else {
$output .= '"icon": "images/flag_blue.png",';
$output .= '"marker-symbol": "marker",';
$output .= '"marker-size": "small",';
$output .= '"marker-color": "#0000ff"';
}
$output .= '},';
$output .= '"geometry": {';
$output .= '"type": "Point",';
$output .= '"coordinates": [';
$output .= $spotter_item['longitude_end'].', '.$spotter_item['latitude_end'].', '.round($spotter_item['base']*100*0.3048);
$output .= ']';
$output .= '}';
$output .= '},';
}
}
$output = substr($output, 0, -1);
$output .= ']}';
print $output;
?>