Completed
Push — master ( 3afeea...5bdcfd )
by Yannick
06:37
created

live-czml.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
require_once('require/class.Connection.php');
3
require_once('require/class.Common.php');
4
$tracker = false;
5
$marine = false;
6
if (isset($_GET['tracker'])) $tracker = true;
7
if (isset($_GET['marine'])) $marine = true;
8
if ($tracker) {
9
	require_once('require/class.Tracker.php');
10
	require_once('require/class.TrackerLive.php');
11
	//require_once('require/class.SpotterArchive.php');
12
	$TrackerLive = new TrackerLive();
13
	$Tracker = new Tracker();
14
//	$TrackerArchive = new TrackerArchive();
15
} elseif ($marine) {
16
	require_once('require/class.Marine.php');
17
	require_once('require/class.MarineLive.php');
18
	//require_once('require/class.MarineArchive.php');
19
	$MarineLive = new MarineLive();
20
	$Marine = new Marine();
21
//	$MarineArchive = new MarineArchive();
22
} else {
23
	require_once('require/class.Spotter.php');
24
	require_once('require/class.SpotterLive.php');
25
	require_once('require/class.SpotterArchive.php');
26
	$SpotterLive = new SpotterLive();
27
	$Spotter = new Spotter();
28
	$SpotterArchive = new SpotterArchive();
29
}
30
31
date_default_timezone_set('UTC');
32
$begintime = microtime(true);
33
$Common = new Common();
34
35
36
function quaternionrotate($heading, $attitude = 0, $bank = 0) {
37
    // Assuming the angles are in radians.
38
    $c1 = cos($heading/2);
39
    $s1 = sin($heading/2);
40
    $c2 = cos($attitude/2);
41
    $s2 = sin($attitude/2);
42
    $c3 = cos($bank/2);
43
    $s3 = sin($bank/2);
44
    $c1c2 = $c1*$c2;
45
    $s1s2 = $s1*$s2;
46
    $w =$c1c2*$c3 - $s1s2*$s3;
47
    $x =$c1c2*$s3 + $s1s2*$c3;
48
    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
49
    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
50
    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
51
//    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
52
53
}
54
55
56
if (isset($_GET['download'])) {
57
    if ($_GET['download'] == "true")
58
    {
59
	header('Content-disposition: attachment; filename="flightairmap.json"');
60
    }
61
}
62
header('Content-Type: text/javascript');
63
64
if (!isset($globalJsonCompress)) $compress = true;
65
else $compress = $globalJsonCompress;
66
67
$from_archive = false;
68
$min = false;
69
$allhistory = false;
70
$filter['source'] = array();
71
if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
72
if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
73
if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
74
if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
75
if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
76
if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
77
if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
78
if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
79
if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
80
if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
81
/*
82
if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
83
	$min = true;
84
}
85
86
if (isset($_GET['ident'])) {
87
	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
88
	$spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
89
	if (empty($spotter_array)) {
90
		$from_archive = true;
91
		$spotter_array = $SpotterArchive->getLastArchiveSpotterDataByIdent($ident);
92
	}
93
	$allhistory = true;
94
} elseif (isset($_GET['flightaware_id'])) {
95
	$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
96
	$spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
97
	if (empty($spotter_array)) {
98
		$from_archive = true;
99
		$spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
100
	}
101
	$allhistory = true;
102
} elseif (isset($_GET['coord'])) {
103
	$coord = explode(',',$_GET['coord']);
104
	$spotter_array = $SpotterLive->getLiveSpotterDatabyCoord($coord,$filter);
105
} elseif (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed'])) {
106
	$from_archive = true;
107
//	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
108
//	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
109
	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
110
	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
111
	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
112
	$begindate = date('Y-m-d H:i:s',$begindate);
113
	$enddate = date('Y-m-d H:i:s',$enddate);
114
	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
115
} elseif ($min) {
116
	//$spotter_array = $SpotterLive->getMinLiveSpotterData($filter);
117
	$spotter_array = $SpotterLive->getMinLastLiveSpotterData($filter);
118
#	$min = true;
119
} else {
120
	$spotter_array = $SpotterLive->getLiveSpotterData('','',$filter);
121
}
122
*/
123
if (isset($_GET['archive']) && isset($_GET['begindate']) && isset($_GET['enddate']) && isset($_GET['speed'])) {
124
	$from_archive = true;
125
//	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
126
//	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
127
	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
128
	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
129
	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
130
	$begindate = date('Y-m-d H:i:s',$begindate);
131
	$enddate = date('Y-m-d H:i:s',$enddate);
132
	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
133
} elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
134
	$from_archive = true;
135
//	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
136
//	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
137
//	$begindate = filter_var($_COOKIE['archive_begin'],FILTER_SANITIZE_NUMBER_INT);
138
//	$enddate = filter_var($_COOKIE['archive_end'],FILTER_SANITIZE_NUMBER_INT);
139
	$begindate = $_COOKIE['archive_begin'];
140
	$enddate = $_COOKIE['archive_end'];
141
142
	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
143
	$begindate = date('Y-m-d H:i:s',$begindate);
144
	$enddate = date('Y-m-d H:i:s',$enddate);
145
//	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
146
	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
147
} elseif ($tracker) {
148
	$spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter);
149
} elseif ($marine) {
150
	$spotter_array = $MarineLive->getMinLastLiveMarineData($filter);
151
} else {
152
	$spotter_array = $SpotterLive->getMinLastLiveSpotterData($filter);
153
}
154
155
if (!empty($spotter_array)) {
156
	if (isset($_GET['archive'])) {
157
		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
158
	} elseif ($tracker) {
159
		$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
160
	} elseif ($marine) {
161
		$flightcnt = $MarineLive->getLiveMarineCount($filter);
162
	} else {
163
		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
164
	}
165
	if ($flightcnt == '') $flightcnt = 0;
166
} else $flightcnt = 0;
167
168
$sqltime = round(microtime(true)-$begintime,2);
169
$minitime = time();
170
$maxitime = 0;
171
172
173
$modelsdb = array();
174
if (file_exists('models/modelsdb')) {
175
	if (($handle = fopen('models/modelsdb','r')) !== FALSE) {
176
		while (($row = fgetcsv($handle,1000)) !== FALSE) {
177
			if (isset($row[1]) ){
178
				$model = $row[0];
179
				$modelsdb[$model] = $row[1];
180
			}
181
		}
182
		fclose($handle);
183
	}
184
}
185
$heightrelative = 'NONE';
186
$j = 0;
187
$prev_flightaware_id = '';
188
$speed = 1;
189
if (isset($archivespeed)) $speed = $archivespeed;
190
$output = '[';
191
if ($tracker) {
192
	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
193
} elseif ($marine) {
194
	$output .= '{"id" : "document", "name" : "marine","version" : "1.0"';
195
} else {
196
	$output .= '{"id" : "document", "name" : "fam","version" : "1.0"';
197
}
198
//	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "LOOP_STOP","step": "SYSTEM_CLOCK_MULTIPLIER"}';
199
200
//	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
201
//$output .= ',"clock": {"currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
202
if ($from_archive === true) {
203
	$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER","interval": "%minitime%/%maxitime%"}';
204
} else {
205
	$output .= ',"clock": {"currentTime" : "%minitime%","multiplier" : '.$speed.',"range" : "UNBOUNDED","step": "SYSTEM_CLOCK_MULTIPLIER"}';
206
}
207
208
//	$output .= ',"clock": {"interval" : "'.date("c",time()-$globalLiveInterval).'/'.date("c").'","currentTime" : "'.date("c",time() - $globalLiveInterval).'","multiplier" : 1,"step": "SYSTEM_CLOCK_MULTIPLIER"}';
209
$output .= '},';
210
if (!empty($spotter_array) && is_array($spotter_array))
211
{
212
	foreach($spotter_array as $spotter_item)
213
	{
214
		$j++;
215
		date_default_timezone_set('UTC');
216
		if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
217
		{
218
			$image = $spotter_item['image_thumbnail'];
219
		} else {
220
			$image = "images/placeholder_thumb.png";
221
		}
222
223
                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
224
                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
225
                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
226
                if ($prev_flightaware_id != $id) {
227
			if ($prev_flightaware_id != '') {
228
				$output .= ']';
229
				$output .= '}';
230
				//$output .= ', '.$orientation.']}';
231
				$output .= '},';
232
			}
233
			$orientation = '';
234
			$prev_flightaware_id = $id;
235
			$output .= '{';
236
			$output .= '"id": "'.$id.'",';
237
			$output .= '"properties": {';
238
			// Not yet supported in CZML with Cesium
239
			$output .= '},';
240
241
			$output .= '"path" : { ';
242
			$output .= '"show" : false, ';
243
			$output .= '"material" : { ';
244
			$output .= '"polylineOutline" : { ';
245
			$output .= '"color" : { "rgba" : [238, 250, 255, 255] }, ';
246
			$output .= '"outlineColor" : { "rgba" : [200, 209, 214, 255] }, ';
247
			$output .= '"outlineWidth" : 5, ';
248
			$output .= '"polylineGlow" : { "color" : { "rgba" : [214, 208, 214, 255] }, "glowPower" : 3 } ';
249
			$output .= '}';
250
			$output .= '}, ';
251
			$output .= '"heightReference": "'.$heightrelative.'",';
252
			$output .= '"width" : 6, "leadTime" : 0, "trailTime" : 1000000, "resolution" : 10 },';
253
			//$output .= ' "billboard" : {"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAfCAYAAACVgY94AAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUh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d6AXgi5+qAn+O5U0PbBVwKtAD3AHuB8f3YGBUdncCGoQ4LE9XtGRqK9LnduVPRIu2BPqwD65IYbS7Qpql7Ql9YoJcy9bwzkgPrfOCj5G33+h54E/g0PAr5thq4ApgyEgNrc27aWwVaPTA1QJ4BjgTGFvhteV40EgPrgvTP7qlmZqFnl9WD+b2posN83E/NrEkOjlI/U1fkfUYa/pe5IE3qZPW8jFOqiyN7p3pAPX04c7AxYSoDDcAjKT2LgLXA6IR2M3Bviv59wDTgQGTPH84Qd8+HXfHcoUws2zM0HMjuUPep+xP2PWpnwtw0GJsldbBpewQwE/gbeDyt7H1gcW53O7AC+A3Yn6+/W+Ld9SnWA15DAVhc8xK2TuA9YHrCuhV4EngFuBx4YagG6qv8cF+T52kB2Zy+e1I8taUacNV+uBdXO7ABmJwJpwx8XQvF9TUCWM64tiQhbq/oMv+7BwFWpQzNT8vbVQul/wwAGzzdmXU1xuUAAAAASUVORK5CYII=","scale" : 1.5},';
254
			if (isset($spotter_item['aircraft_icao'])) {
255
				$aircraft_icao = $spotter_item['aircraft_icao'];
256
				if (isset($modelsdb[$aircraft_icao])) {
257
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_icao].'","scale" : 1.0,"minimumPixelSize": 20';
258
					$output .= ',"heightReference": "'.$heightrelative.'"';
259
					$output .= '},';
260
				} elseif ($aircraft_icao != '') {
261
					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
262
					if (isset($aircraft_info[0]['engine_type'])) {
263
						$aircraft_shadow = $aircraft_info[0]['aircraft_shadow'];
264
						$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
265
						$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
266
						$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
267
					} else $aircraft_shadow = '';
268
					if ($aircraft_shadow != '') {
269
						if (isset($modelsdb[$aircraft_shadow])) {
270
							$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
271
							$output .= ',"heightReference": "'.$heightrelative.'"';
272
							$output .= '},';
273
							$modelsdb[$aircraft_icao] = $modelsdb[$aircraft_shadow];
274
						} elseif ($spotter_item['engine_type'] == 'Jet') {
275
							if ($spotter_item['engine_count'] == '1') {
276
								if ($spotter_item['wake_category'] == 'M') {
277
									$model = 'J1M';
278
								} elseif ($spotter_item['wake_category'] == 'L') {
279
									$model = '';
280
								}
281
							} elseif ($spotter_item['engine_count'] == '2') {
282
								if ($spotter_item['wake_category'] == 'M') {
283
									$model = 'J2M';
284
								} elseif ($spotter_item['wake_category'] == 'H') {
285
									$model = 'J2H';
286
								} elseif ($spotter_item['wake_category'] == 'L') {
287
									$model = 'J2L';
288
								}
289
							} elseif ($spotter_item['engine_count'] == '3') {
290
								if ($spotter_item['wake_category'] == 'M') {
291
									$model = 'J3M';
292
								} elseif ($spotter_item['wake_category'] == 'H') {
293
									$model = 'J3H';
294
								}
295
							} elseif ($spotter_item['engine_count'] == '4') {
296
								if ($spotter_item['wake_category'] == 'M') {
297
									$model = 'J4M';
298
								} elseif ($spotter_item['wake_category'] == 'H') {
299
									$model = 'J4H';
300
								}
301
							}
302
							if (isset($modelsdb[$model])) {
303
								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20';
304
								$output .= ',"heightReference": "'.$heightrelative.'"';
305
								$output .= '},';
306
								$modelsdb[$aircraft_icao] = $modelsdb[$model];
307
							} else {
308
								$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20';
309
								$output .= ',"heightReference": "'.$heightrelative.'"';
310
								$output .= '},';
311
								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
312
							}
313
						} elseif ($spotter_item['engine_type'] == 'Turboprop') {
314
							if ($spotter_item['engine_count'] == '1') {
315
								if ($spotter_item['wake_category'] == 'L') {
316
									$model = 'T1L';
317
								}
318
							} elseif ($spotter_item['engine_count'] == '2') {
319
								if ($spotter_item['wake_category'] == 'M') {
320
									$model = 'T2M';
321
								} elseif ($spotter_item['wake_category'] == 'L') {
322
									$model = 'T2L';
323
								}
324
							} elseif ($spotter_item['engine_count'] == '4') {
325
								if ($spotter_item['wake_category'] == 'M') {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
326
								} elseif ($spotter_item['wake_category'] == 'H') {
327
									$model = 'T4H';
328
								}
329
							}
330
							if (isset($modelsdb[$model])) {
331
								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20';
332
								$output .= ',"heightReference": "'.$heightrelative.'"';
333
								$output .= '},';
334
								$modelsdb[$aircraft_icao] = $modelsdb[$model];
335
							} else {
336
								$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20';
337
								$output .= ',"heightReference": "'.$heightrelative.'"';
338
								$output .= '},';
339
								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
340
							}
341
						} elseif ($spotter_item['engine_type'] == 'Piston') {
342
							if ($spotter_item['engine_count'] == '1') {
343
								if ($spotter_item['wake_category'] == 'L') {
344
									$model = 'P1L';
345
								} elseif ($spotter_item['wake_category'] == 'M') {
346
									$model = 'P1M';
347
								}
348
							} elseif ($spotter_item['engine_count'] == '2') {
349
								if ($spotter_item['wake_category'] == 'M') {
350
									$model = 'P2M';
351
								} elseif ($spotter_item['wake_category'] == 'L') {
352
									$model = 'P2L';
353
								}
354
								// ju52 = P3M
355
							}
356
							if (isset($modelsdb[$model])) {
357
								$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$model].'","scale" : 1.0,"minimumPixelSize": 20';
358
								$output .= ',"heightReference": "'.$heightrelative.'"';
359
								$output .= '},';
360
								$modelsdb[$aircraft_icao] = $modelsdb[$model];
361
							} else {
362
								$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20';
363
								$output .= ',"heightReference": "'.$heightrelative.'"';
364
								$output .= '},';
365
								$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
366
							}
367
						} else {
368
							$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20';
369
							$output .= ',"heightReference": "'.$heightrelative.'"';
370
							$output .= '},';
371
								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
372
							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
373
							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
374
						}
375
					} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
376
						$aircraft_shadow = 'PA18';
377
						$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
378
						$output .= ',"heightReference": "'.$heightrelative.'"';
379
						$output .= '},';
380
						$modelsdb[$aircraft_icao] = $modelsdb[$aircraft_shadow];
381
					} else {
382
						$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20';
383
						$output .= ',"heightReference": "'.$heightrelative.'"';
384
						$output .= '},';
385
						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
386
						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
387
						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
388
					}
389
				} else {
390
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20';
391
					$output .= ',"heightReference": "'.$heightrelative.'"';
392
					$output .= '},';
393
					//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
394
					if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
395
					$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
396
				}
397
			} elseif ($tracker && isset($spotter_item['type'])) {
398
				
399
				if ($spotter_item['type'] == 'Car') {
400
					//$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/car.glb","scale" : 1.0,"minimumPixelSize": 20,';
401
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/car.gltf","scale" : 1.0,"minimumPixelSize": 20';
402
					$output .= ',"heightReference": "'.$heightrelative.'"';
403
					$output .= '},';
404
				} elseif ($spotter_item['type'] == 'Truck' || $spotter_item['type'] == 'Truck (18 Wheeler)') {
405
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/truck.gltf","scale" : 1.0,"minimumPixelSize": 20';
406
					$output .= ',"heightReference": "'.$heightrelative.'"';
407
					$output .= '},';
408
				} elseif ($spotter_item['type'] == 'Firetruck') {
409
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/firetruck.glb","scale" : 1.0,"minimumPixelSize": 20';
410
					$output .= ',"heightReference": "'.$heightrelative.'"';
411
					$output .= '},';
412
				} elseif ($spotter_item['type'] == 'Bike') {
413
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/cycle.glb","scale" : 1.0,"minimumPixelSize": 20';
414
					$output .= ',"heightReference": "'.$heightrelative.'"';
415
					$output .= '},';
416
				} elseif ($spotter_item['type'] == 'Police') {
417
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/police.glb","scale" : 1.0,"minimumPixelSize": 20';
418
					$output .= ',"heightReference": "'.$heightrelative.'"';
419
					$output .= '},';
420
				} elseif ($spotter_item['type'] == 'Balloon') {
421
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/ball.glb","scale" : 1.0,"minimumPixelSize": 20';
422
					$output .= ',"heightReference": "'.$heightrelative.'"';
423
					$output .= '},';
424
				} elseif ($spotter_item['type'] == 'Ship (Power Boat)' || $spotter_item['type'] == 'Yatch (Sail)') {
425
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/boat.glb","scale" : 1.0,"minimumPixelSize": 20';
426
					$output .= ',"heightReference": "'.$heightrelative.'"';
427
					$output .= '},';
428
				} else {
429
					$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/truck.gltf","scale" : 1.0,"minimumPixelSize": 20';
430
					//$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/Cesium_Ground.glb","scale" : 1.0,"minimumPixelSize": 20';
431
					$output .= ',"heightReference": "'.$heightrelative.'"';
432
					$output .= '},';
433
				}
434
			} elseif ($marine) {
435
				$output .= '"model": {"gltf" : "'.$globalURL.'/models/vehicules/boat.glb","scale" : 1.0,"minimumPixelSize": 20';
436
				$output .= ',"heightReference": "'.$heightrelative.'"';
437
				$output .= '},';
438
			}
439
	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
440
			$output .= '"heightReference": "'.$heightrelative.'",';
441
	//		$output .= '"heightReference": "NONE",';
442
			$output .= '"position": {';
443
			$output .= '"interpolationAlgorithm":"HERMITE","interpolationDegree":3,';
444
			$output .= '"type": "Point",';
445
	//		$output .= '"interpolationAlgorithm" : "LAGRANGE",';
446
	//		$output .= '"interpolationDegree" : 5,';
447
	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
448
			$output .= '"cartographicDegrees": [';
449
			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
450
			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
451
			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
452
			$output .= $spotter_item['longitude'].', ';
453
			$output .= $spotter_item['latitude'];
454
			$prevlong = $spotter_item['longitude'];
455
			$prevlat = $spotter_item['latitude'];
456
			if (!$tracker && !$marine) {
457
				$output .= ', '.round($spotter_item['altitude']*30.48);
458
				$prevalt = round($spotter_item['altitude']*30.48);
459
			} else $output .= ', 0';
460
			//$orientation = '"orientation" : { ';
461
			//$orientation .= '"unitQuaternion": [';
462
			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
463
			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
464
		} else {
465
			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
466
			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
467
			if ($spotter_item['ground_speed'] == 0) {
468
				$output .= $prevlong.', ';
469
				$output .= $prevlat;
470
				if (!$tracker && !$marine) $output .= ', '.$prevalt;
471
				else $output .= ', 0';
472
			} else {
473
				$output .= $spotter_item['longitude'].', ';
474
				$output .= $spotter_item['latitude'];
475
				if (!$tracker && !$marine) {
476
					if ($spotter_item['altitude'] == '') {
477
						if ($prevalt != '') {
478
							$output .= ', '.$prevalt;
479
						} else {
480
							$output .= ', 0';
481
						}
482
					} else {
483
						$output .= ', '.round($spotter_item['altitude']*30.48);
484
					}
485
				} else $output .= ', 0';
486
			}
487
			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
488
			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
489
		}
490
	}
491
	//$output  = substr($output, 0, -1);
492
	$output .= ']}}';
493
} else {
494
	$output  = substr($output, 0, -1);
495
}
496
$output .= ']';
497
$output = str_replace('%minitime%',date("c",$minitime),$output);
498
$output = str_replace('%maxitime%',date("c",$maxitime),$output);
499
print $output;
500
?>
501