本文整理汇总了PHP中Position::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Position::toArray方法的具体用法?PHP Position::toArray怎么用?PHP Position::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Position
的用法示例。
在下文中一共展示了Position::toArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: positionReport
/**
* Create a position report for a flight and store it
* in a class variable.
*
* @param array $data
* @param int $flightId
* @return void
*/
protected function positionReport($data, $flightId)
{
$position = new Position();
$position->flight_id = $flightId;
$position->lat = $data['latitude'];
$position->lon = $data['longitude'];
$position->altitude = $data['altitude'];
$position->speed = $data['groundspeed'];
$position->heading = $data['heading'];
$options = array('flags' => FILTER_FLAG_ALLOW_FRACTION);
$lat = number_format(filter_var($data['latitude'], FILTER_SANITIZE_NUMBER_FLOAT, $options), 5);
$lon = number_format(filter_var($data['longitude'], FILTER_SANITIZE_NUMBER_FLOAT, $options), 5);
$elevation = $this->elevations[$lat . ',' . $lon];
$position->ground_elevation = $elevation < 0 && $position->altitude > 0 ? 0 : $elevation;
$position->update_id = $this->updateId;
$this->positions[] = $position->toArray();
unset($position, $data, $flightId);
}