2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 $Spotter = new Spotter();
6 $registration = filter_input(INPUT_GET
,'registration',FILTER_SANITIZE_STRING
);
7 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
8 if (isset($_GET['sort'])) $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1", $sort);
9 else $spotter_array = $Spotter->getSpotterDataByRegistration($registration, "0,1");
10 $aircraft_array = $Spotter->getAircraftInfoByRegistration($registration);
13 if (!empty($spotter_array))
15 $title = sprintf(_("Most Common Departure Airports of aircraft with registration %s"),$registration);
16 require_once('header.php');
18 print '<div class="info column">';
19 print '<h1>'.$registration.' - '.$aircraft_array[0]['aircraft_name'].' ('.$aircraft_array[0]['aircraft_icao'].')</h1>';
20 print '<div><span class="label">'._("Name").'</span><a href="'.$globalURL.'/aircraft/'.$aircraft_array[0]['aircraft_icao'].'">'.$aircraft_array[0]['aircraft_name'].'</a></div>';
21 print '<div><span class="label">'._("ICAO").'</span><a href="'.$globalURL.'/aircraft/'.$aircraft_array[0]['aircraft_icao'].'">'.$aircraft_array[0]['aircraft_icao'].'</a></div>';
22 print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $aircraft_array[0]['aircraft_manufacturer'])).'">'.$aircraft_array[0]['aircraft_manufacturer'].'</a></div>';
25 include('registration-sub-menu.php');
26 print '<div class="column">';
27 print '<h2>'._("Most Common Departure Airports").'</h2>';
29 print '<p>'.sprintf(_("The statistic below shows all departure airports of flights with aircraft registration <strong>%s</strong>."),$registration).'</p>';
30 $airport_airport_array = $Spotter->countAllDepartureAirportsByRegistration($registration);
31 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
32 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
33 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
34 print '<div id="chartAirport" class="chart" width="100%"></div>';
36 print 'var series = [';
38 foreach($airport_airport_array as $airport_item)
40 if (isset($airport_item['airport_arrival_latitude']) && isset($airport_item['airport_arrival_longitude'])) {
41 $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
44 $airport_data = substr($airport_data, 0, -1);
47 print 'var onlyValues = series.map(function(obj){ return obj[0]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);'."\n";
48 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);'."\n";
49 print 'var radiusScale = d3.scale.log().domain([minValue,maxValue]).range([0,10]);'."\n";
50 print 'var dataset = [];'."\n";
51 print 'var colorset = [];'."\n";
52 print 'colorset["defaultFill"] = "#F5F5F5";';
53 print 'series.forEach(function(item){'."\n";
54 print 'var cnt = item[0], nm = item[1], lat = item[2], long = item[3];'."\n";
55 print 'colorset[nm] = paletteScale(cnt);';
56 print 'dataset.push({ count: cnt, name: nm, radius: Math.floor(radiusScale(cnt)), latitude: lat, longitude: long, fillKey: nm });'."\n";
58 print 'var bbl = new Datamap({
59 element: document.getElementById("chartAirport"),
60 projection: "mercator", // big world map
64 borderColor: "#DEDEDE",
65 highlightBorderWidth: 2,
66 highlightFillColor: function(geo) {
67 return geo["fillColor"] || "#F5F5F5";
69 highlightBorderColor: "#B7B7B7"},
70 done: function(datamap) {
71 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
73 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
78 popupTemplate: function(geo, data) {
79 if (!data) { return ; }
80 return ['."'".'<div class="hoverinfo">'."','<strong>', data.name, '</strong>','<br>Count: <strong>', data.count, '</strong>','</div>'].join('');
84 print '<div class="table-responsive">';
85 print '<table class="common-airport table-striped">';
88 print '<th>'._("Airport").'</th>';
89 print '<th>'._("Country").'</th>';
90 print '<th>'._("# of times").'</th>';
94 foreach($airport_airport_array as $airport_item)
97 print '<td><strong>'.$i.'</strong></td>';
99 print '<a href="'.$globalURL.'/airport/'.$airport_item['airport_departure_icao'].'">'.$airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')</a>';
102 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['airport_departure_country'])).'">'.$airport_item['airport_departure_country'].'</a>';
105 print $airport_item['airport_departure_icao_count'];
115 $title = _("Registration");
116 require_once('header.php');
117 print '<h1>'._("Error").'</h1>';
118 print '<p>'._("Sorry, this registration does not exist in this database. :(").'</p>';
121 require_once('footer.php');