| 272 | } |
| 273 | |
| 274 | LatLon Track::calcAveragePosition() const |
| 275 | { |
| 276 | double avg_latitude = 0; |
| 277 | double avg_longitude = 0; |
| 278 | int num_samples = 0; |
| 279 | |
| 280 | int size = getNumWaypoints(); |
| 281 | for (int i = 0; i < size; ++i) |
| 282 | { |
| 283 | const TrackPoint& point = getWaypoint(i); |
| 284 | avg_latitude += point.latlon.latitude(); |
| 285 | avg_longitude += point.latlon.longitude(); |
| 286 | ++num_samples; |
| 287 | } |
| 288 | for (int i = 0; i < getNumSegments(); ++i) |
| 289 | { |
| 290 | size = getSegmentPointCount(i); |
| 291 | for (int k = 0; k < size; ++k) |
| 292 | { |
| 293 | const TrackPoint& point = getSegmentPoint(i, k); |
| 294 | avg_latitude += point.latlon.latitude(); |
| 295 | avg_longitude += point.latlon.longitude(); |
| 296 | ++num_samples; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | return LatLon((num_samples > 0) ? (avg_latitude / num_samples) : 0, |
| 301 | (num_samples > 0) ? (avg_longitude / num_samples) : 0); |
| 302 | } |
| 303 | |
| 304 | bool Track::loadGpxFrom(QIODevice& device, bool project_points) |
| 305 | { |
no test coverage detected