本文整理汇总了PHP中OperationsData::getAirportDistance方法的典型用法代码示例。如果您正苦于以下问题:PHP OperationsData::getAirportDistance方法的具体用法?PHP OperationsData::getAirportDistance怎么用?PHP OperationsData::getAirportDistance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationsData
的用法示例。
在下文中一共展示了OperationsData::getAirportDistance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_schedule_post
protected function add_schedule_post()
{
if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->deptime == '' || $this->post->arrtime == '' || $this->post->depicao == '' || $this->post->arricao == '') {
$this->set('message', 'All of the fields must be filled out');
$this->render('core_error.tpl');
return;
}
# Check if the schedule exists
$sched = SchedulesData::getScheduleByFlight($this->post->code, $this->post->flightnum);
if (is_object($sched)) {
$this->set('message', 'This schedule already exists!');
$this->render('core_error.tpl');
return;
}
$enabled = $this->post->enabled == 'on' ? true : false;
# Check the distance
if ($this->post->distance == '' || $this->post->distance == 0) {
$this->post->distance = OperationsData::getAirportDistance($this->post->depicao, $this->post->arricao);
}
# Format the flight level
$this->post->flightlevel = str_replace(',', '', $this->post->flightlevel);
$this->post->flightlevel = str_replace(' ', '', $this->post->flightlevel);
$this->post->route = strtoupper($this->post->route);
$this->post->route = str_replace($this->post->depicao, '', $this->post->route);
$this->post->route = str_replace($this->post->arricao, '', $this->post->route);
$this->post->route = str_replace('SID', '', $this->post->route);
$this->post->route = str_replace('STAR', '', $this->post->route);
$data = array('code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'route' => $this->post->route, 'aircraft' => $this->post->aircraft, 'flightlevel' => $this->post->flightlevel, 'distance' => $this->post->distance, 'deptime' => $this->post->deptime, 'arrtime' => $this->post->arrtime, 'flighttime' => $this->post->flighttime, 'daysofweek' => implode('', $_POST['daysofweek']), 'price' => $this->post->price, 'flighttype' => $this->post->flighttype, 'notes' => $this->post->notes, 'enabled' => $enabled);
# Add it in
$ret = SchedulesData::AddSchedule($data);
if (DB::errno() != 0 && $ret == false) {
$this->set('message', 'There was an error adding the schedule, already exists DB error: ' . DB::error());
$this->render('core_error.tpl');
return;
}
$this->set('message', 'The schedule "' . $this->post->code . $this->post->flightnum . '" has been added');
$this->render('core_success.tpl');
LogData::addLog(Auth::$userinfo->pilotid, 'Added schedule "' . $this->post->code . $this->post->flightnum . '"');
}
示例2: fileReport
//.........这里部分代码省略.........
$pirepdata['route_details'] = NavData::parseRoute($tmp);
$pirepdata['route_details'] = serialize($pirepdata['route_details']);
unset($tmp);
}
if (empty($pirepdata['route']) && !empty($sched->route)) {
$pirepdata['route'] = $sched->route;
$pirepdata['route'] = str_replace('SID', '', $pirepdata['route']);
$pirepdata['route'] = str_replace('STAR', '', $pirepdata['route']);
$pirepdata['route'] = str_replace('DCT', '', $pirepdata['route']);
$pirepdata['route'] = trim($pirepdata['route']);
/* The schedule doesn't have any route_details, so let's populate
the schedule while we're here. Then we'll use that same info
to populate our details information
*/
if (empty($sched->route_details)) {
$pirepdata['route_details'] = serialize(SchedulesData::getRouteDetails($sched->id));
} else {
/* The schedule does have route information, and it's already been cached */
$pirepdata['route_details'] = $sched->route_details;
}
}
/* This setting forces the next code to automatically
calculate a load value for this current PIREP */
if (Config::Get('PIREP_OVERRIDE_LOAD') == true) {
$pirepdata['load'] == '';
}
# Check the load, if it's blank then look it up
# Based on the aircraft that was flown
if (!isset($pirepdata['load']) || empty($pirepdata['load'])) {
$pirepdata['load'] = FinanceData::getLoadCount($pirepdata['aircraft'], $sched->flighttype);
}
/* If the distance isn't supplied, then calculate it */
if (!isset($pirepdata['distance']) || empty($pirepdata['distance'])) {
$pirepdata['distance'] = OperationsData::getAirportDistance($depapt, $arrapt);
}
/* See if there's a landing rate */
if (!isset($pirepdata['landingrate']) || empty($pirepdata['landingrate'])) {
$pirepdata['landingrate'] = 0;
}
/* Any "raw" parameterized data which needs to be added */
if (isset($pirepdata['rawdata'])) {
$pirepdata['rawdata'] = serialize($pirepdata['rawdata']);
} else {
$pirepdata['rawdata'] = '';
}
/* Escape the comment field */
//$pirepdata['log'] = DB::escape($pirepdata['log']);
if (isset($pirepdata['comment'])) {
$comment = DB::escape($pirepdata['comment']);
unset($pirepdata['comment']);
}
/* Proper timestamp */
$pirepdata['flighttime'] = str_replace(':', '.', $pirepdata['flighttime']);
$pirepdata['flighttime_stamp'] = str_replace('.', ':', $pirepdata['flighttime']) . ':00';
/* Export status as 0 */
$pirepdata['exported'] = 0;
$pirepdata['submitdate'] = 'NOW()';
$pirepdata['modifieddate'] = 'NOW()';
$pirepdata['accepted'] = PIREP_PENDING;
$pirepdata['expenselist'] = '0';
$pirepdata['flighttype'] = $sched->flighttype;
# Do the insert based on the columns here
$cols = array();
$col_values = array();
foreach ($pirepdata as $key => $value) {
if ($key == 'submitdate') {
示例3: processimport
public function processimport()
{
echo '<h3>Processing Import</h3>';
if (!file_exists($_FILES['uploadedfile']['tmp_name'])) {
$this->set('message', 'File upload failed!');
$this->render('core_error.tpl');
return;
}
echo '<p><strong>DO NOT REFRESH OR STOP THIS PAGE</strong></p>';
set_time_limit(270);
$errs = array();
$skip = false;
# Fix for bug VMS-325
$temp_name = $_FILES['uploadedfile']['tmp_name'];
$new_name = CACHE_PATH . $_FILES['uploadedfile']['name'];
move_uploaded_file($temp_name, $new_name);
$fp = fopen($new_name, 'r');
if (isset($_POST['header'])) {
$skip = true;
}
/* Delete all schedules before doing an import */
if (isset($_POST['erase_routes'])) {
SchedulesData::deleteAllSchedules();
}
$added = 0;
$updated = 0;
$total = 0;
echo '<div style="overflow: auto; height: 400px; border: 1px solid #666; margin-bottom: 20px; padding: 5px; padding-top: 0px; padding-bottom: 20px;">';
while ($fields = fgetcsv($fp, 1000, ',')) {
// Skip the first line
if ($skip == true) {
$skip = false;
continue;
}
// list fields:
$code = $fields[0];
$flightnum = $fields[1];
$depicao = $fields[2];
$arricao = $fields[3];
$route = $fields[4];
$aircraft = $fields[5];
$flightlevel = $fields[6];
$distance = $fields[7];
$deptime = $fields[8];
$arrtime = $fields[9];
$flighttime = $fields[10];
$notes = $fields[11];
$price = $fields[12];
$flighttype = $fields[13];
$daysofweek = $fields[14];
$enabled = $fields[15];
$week1 = $fields[16];
$week2 = $fields[17];
$week3 = $fields[18];
$week4 = $fields[19];
if ($code == '') {
continue;
}
// Check the code:
if (!OperationsData::GetAirlineByCode($code)) {
echo "Airline with code {$code} does not exist! Skipping...<br />";
continue;
}
// Make sure airports exist:
if (!($depapt = OperationsData::GetAirportInfo($depicao))) {
$this->get_airport_info($depicao);
}
if (!($arrapt = OperationsData::GetAirportInfo($arricao))) {
$this->get_airport_info($arricao);
}
# Check the aircraft
$aircraft = trim($aircraft);
$ac_info = OperationsData::GetAircraftByReg($aircraft);
# If the aircraft doesn't exist, skip it
if (!$ac_info) {
echo 'Aircraft "' . $aircraft . '" does not exist! Skipping<br />';
continue;
}
$ac = $ac_info->id;
if ($flighttype == '') {
$flighttype = 'P';
}
if ($daysofweek == '') {
$daysofweek = '0123456';
}
// Replace a 7 (Sunday) with 0 (since PHP thinks 0 is Sunday)
$daysofweek = str_replace('7', '0', $daysofweek);
# Check the distance
if ($distance == 0 || $distance == '') {
$distance = OperationsData::getAirportDistance($depicao, $arricao);
}
$flighttype = strtoupper($flighttype);
if ($enabled == '0') {
$enabled = false;
} else {
$enabled = true;
}
# This is our 'struct' we're passing into the schedule function
# to add or edit it
$data = array('code' => $code, 'flightnum' => $flightnum, 'depicao' => $depicao, 'arricao' => $arricao, 'route' => $route, 'aircraft' => $ac, 'flightlevel' => $flightlevel, 'distance' => $distance, 'deptime' => $deptime, 'arrtime' => $arrtime, 'flighttime' => $flighttime, 'daysofweek' => $daysofweek, 'notes' => $notes, 'enabled' => $enabled, 'price' => $price, 'flighttype' => $flighttype, 'week1' => $week1, 'week2' => $week2, 'week3' => $week3, 'week4' => $week4);
//.........这里部分代码省略.........
示例4: foreach
?>
<html>
<head>
</head>
<body>
<form method="get" action="">
Enter airport: <input type ="text" name="depicao" value="<?php
echo $_GET['depicao'];
?>
" />
<input type="submit" name="submit" value="View Distances" />
</form>
<p>To verify, use <a href="http://www.gpsvisualizer.com/calculators" target="_new">gps visualizer</a>. press control+f to find a certain airport.</p>
<?php
if (!isset($_GET['submit'])) {
exit;
}
$depicao = OperationsData::getAirportInfo($_GET['depicao']);
$all_airports = OperationsData::getAllAirports();
echo "Plotting distance between {$depicao->name} ({$depicao->icao}) and...<br><br>";
echo '<ul>';
foreach ($all_airports as $airport) {
Config::Set('UNITS', 'mi');
$mi_dist = OperationsData::getAirportDistance($depicao, $airport);
Config::Set('UNITS', 'km');
$km_dist = OperationsData::getAirportDistance($depicao, $airport);
Config::Set('UNITS', 'nm');
$nm_dist = OperationsData::getAirportDistance($depicao, $airport);
echo "<li>{$airport->name} ({$airport->icao})\n\t\t\t<ul>\n\t\t\t\t<li>{$depicao->lat}, {$depicao->lng} > {$airport->lat}, {$airport->lng}</li>\n\t\t\t\t<li>{$mi_dist} m</li>\n\t\t\t\t<li>{$km_dist} km</li>\n\t\t\t\t<li>{$nm_dist} nm</li>\n\t\t\t</ul>\n\t\t </li>";
}
echo '</ul>';