2 if ($_GET['departure_airport'] == "" ||
$_GET['arrival_airport'] == "")
7 require_once('require/class.Connection.php');
8 require_once('require/class.Spotter.php');
9 require_once('require/class.Language.php');
10 $Spotter = new Spotter();
11 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
12 $departure_airport = filter_input(INPUT_GET
,'departure_airport',FILTER_SANITIZE_STRING
);
13 $arrival_airport = filter_input(INPUT_GET
,'arrival_airport',FILTER_SANITIZE_STRING
);
14 $spotter_array = $Spotter->getSpotterDataByRoute($departure_airport, $arrival_airport, "0,1", $sort);
16 if (!empty($spotter_array))
18 $title = sprintf(_("Most Common Airlines by Country between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']);
19 require_once('header.php');
20 print '<div class="info column">';
21 print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>';
22 print '<div><span class="label">'._("Coming From").'</span><a href="'.$globalURL.'/airport/'.$spotter_array[0]['departure_airport_icao'].'">'.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].'</a></div>';
23 print '<div><span class="label">'._("Flying To").'</span><a href="'.$globalURL.'/airport/'.$spotter_array[0]['arrival_airport_icao'].'">'.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</a></div>';
26 include('route-sub-menu.php');
27 print '<div class="column">';
28 print '<h2>'._("Most Common Airlines by Country").'</h2>';
29 print '<p>'.sprintf(_("The statistic below shows the most common airlines by Country of origin of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>';
31 $airline_array = $Spotter->countAllAirlineCountriesByRoute($departure_airport, $arrival_airport);
32 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
33 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
34 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
35 print '<div id="chartCountry" class="chart" width="100%"></div><script>';
36 print 'var series = [';
38 foreach($airline_array as $airline_item)
40 $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],';
42 $country_data = substr($country_data, 0, -1);
45 print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
46 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
47 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
49 element: document.getElementById("chartCountry"),
50 projection: "mercator", // big world map
51 fills: { defaultFill: "#F5F5F5" },
55 borderColor: "#DEDEDE",
56 highlightBorderWidth: 2,
57 highlightFillColor: function(geo) {
58 return geo["fillColor"] || "#F5F5F5";
60 highlightBorderColor: "#B7B7B7",
61 done: function(datamap) {
62 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
64 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
67 popupTemplate: function(geo, data) {
68 if (!data) { return ; }
69 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
74 if (!empty($airline_array))
76 print '<div class="table-responsive">';
77 print '<table class="common-country table-striped">';
80 print '<th>'._("Country").'</th>';
81 print '<th>'._("# of times").'</th>';
85 foreach($airline_array as $airline_item)
88 print '<td><strong>'.$i.'</strong></td>';
90 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>';
93 print $airline_item['airline_country_count'];
104 $title = _("Unknown Route");
105 require_once('header.php');
106 print '<h1>'._("Error").'</h1>';
107 print '<p>'._("Sorry, this route does not exist in this database. :(").'</p>';
109 require_once('footer.php');