| [008bce9] | 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 4 |
|
|---|
| 5 | This program is free software: you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | namespace GnuBoat;
|
|---|
| 20 |
|
|---|
| 21 | /**
|
|---|
| 22 | * @brief One item in a track
|
|---|
| 23 | */
|
|---|
| 24 | class TrackItem
|
|---|
| 25 | {
|
|---|
| 26 | function __construct()
|
|---|
| 27 | {
|
|---|
| 28 | $this->_time = null;
|
|---|
| 29 | $this->_latitude = null;
|
|---|
| 30 | $this->_longitude = null;
|
|---|
| 31 | $this->_speedThroughWater = null;
|
|---|
| 32 | $this->_speedOverGround = null;
|
|---|
| 33 | $this->_courseOverGround = null;
|
|---|
| 34 | $this->_waterDepth = null;
|
|---|
| 35 | $this->_waterTemperature = null;
|
|---|
| 36 | $this->_gpsfix = null;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | public function setTimestamp($time)
|
|---|
| 40 | {
|
|---|
| 41 | $this->_time = $time;
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | public function setDateTime($dateTime)
|
|---|
| 45 | {
|
|---|
| 46 | $timezone = new \DateTimeZone("UTC");
|
|---|
| 47 | if($dateTime == null)
|
|---|
| 48 | $this->_time = null;
|
|---|
| 49 | $dateTime->setTimezone($timezone);
|
|---|
| 50 | $this->_time = $dateTime->getTimestamp();
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | public function timestamp()
|
|---|
| 54 | {
|
|---|
| 55 | return $this->_time;
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | public function setLatitude($latitude)
|
|---|
| 59 | {
|
|---|
| 60 | $this->_latitude = $latitude;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | public function latitude()
|
|---|
| 64 | {
|
|---|
| 65 | return $this->_latitude;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | public function setLongitude($longitude)
|
|---|
| 69 | {
|
|---|
| 70 | $this->_longitude = $longitude;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | public function longitude()
|
|---|
| 74 | {
|
|---|
| 75 | return $this->_longitude;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | public function setSpeedThroughWater($speedThroughWater)
|
|---|
| 79 | {
|
|---|
| 80 | $this->_speedThroughWater = $speedThroughWater;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | public function speedThroughWater()
|
|---|
| 84 | {
|
|---|
| 85 | return $this->_speedThroughWater;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | public function setSpeedOverGround($speedOverGround)
|
|---|
| 89 | {
|
|---|
| 90 | $this->_speedOverGround = $speedOverGround;
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | public function speedOverGround()
|
|---|
| 94 | {
|
|---|
| 95 | return $this->_speedOverGround;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | public function setCourseOverGround($courseOverGround)
|
|---|
| 99 | {
|
|---|
| 100 | $this->_courseOverGround = $courseOverGround;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | public function courseOverGround()
|
|---|
| 104 | {
|
|---|
| 105 | return $this->_courseOverGround;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | public function setWaterDepth($waterDepth)
|
|---|
| 109 | {
|
|---|
| 110 | $this->_waterDepth = $waterDepth;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | public function waterDepth()
|
|---|
| 114 | {
|
|---|
| 115 | return $this->_waterDepth;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | public function setWaterTemperature($waterTemperature)
|
|---|
| 119 | {
|
|---|
| 120 | $this->_waterTemperature = $waterTemperature;
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | public function waterTemperature()
|
|---|
| 124 | {
|
|---|
| 125 | return $this->_waterTemperature;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | public function setGpsFix($gpsFix)
|
|---|
| 129 | {
|
|---|
| 130 | $this->_gpsFix = $gpsFix;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | public function gpsFix()
|
|---|
| 134 | {
|
|---|
| 135 | return $this->_gpsFix;
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | public function isValid()
|
|---|
| 139 | {
|
|---|
| 140 | if($this->timestamp() == null)
|
|---|
| 141 | return false;
|
|---|
| 142 | if($this->latitude() == null)
|
|---|
| 143 | return false;
|
|---|
| 144 | if($this->longitude() == null)
|
|---|
| 145 | return false;
|
|---|
| 146 | return true;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | public function toArray()
|
|---|
| 150 | {
|
|---|
| 151 | $speedThroughWater = ($this->speedThroughWater() != null) ? $this->speedThroughWater() : 0;
|
|---|
| 152 | $speedOverGround = ($this->speedOverGround() != null) ? $this->speedOverGround() : 0;
|
|---|
| 153 | $courseOverGround = ($this->courseOverGround() != null) ? $this->courseOverGround() : 0;
|
|---|
| 154 | $waterDepth = ($this->waterDepth() != null) ? $this->waterDepth() : 0;
|
|---|
| 155 | $waterTemperature = ($this->waterTemperature() != null) ? $this->waterTemperature() : 0;
|
|---|
| 156 | $gpsFix = ($this->gpsFix() != null) ? $this->gpsFix() : 0;
|
|---|
| 157 |
|
|---|
| 158 | return [
|
|---|
| 159 | "latitude" => $this->latitude(),
|
|---|
| 160 | "longitude" => $this->longitude(),
|
|---|
| 161 | "speedthroughwater" => $speedThroughWater,
|
|---|
| 162 | "speedoverground" => $speedOverGround,
|
|---|
| 163 | "courseoverground" => $courseOverGround,
|
|---|
| 164 | "waterdepth" => $waterDepth,
|
|---|
| 165 | "watertemperature" => $waterTemperature,
|
|---|
| 166 | "gpsfix" => $gpsFix,
|
|---|
| 167 | ];
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | private $_time;
|
|---|
| 171 | private $_latitude, $_longitude;
|
|---|
| 172 | private $_speedThroughWater, $_speedOverGround, $_courseOverGround;
|
|---|
| 173 | private $_waterDepth, $_waterTemperature;
|
|---|
| 174 | private $_gpsFix;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | ?>
|
|---|