Line data Source code
1 : import 'coordinate.dart';
2 : import 'location.dart';
3 :
4 : class StayPoint extends Coordinate {
5 : DateTime arrival;
6 : DateTime departure;
7 : List<Location> locationsInvolved;
8 :
9 : StayPoint({latitude, longitude,
10 : this.arrival,
11 : this.departure,
12 : this.locationsInvolved})
13 2 : : super(latitude: latitude, longitude: longitude);
14 :
15 : StayPoint.fromLocations({this.locationsInvolved})
16 4 : : this.arrival = locationsInvolved.first.timestamp,
17 4 : this.departure = locationsInvolved.last.timestamp,
18 6 : super(latitude: sumLatitude(locationsInvolved), longitude: sumLongitude(locationsInvolved));
19 :
20 8 : Location get location => new Location(latitude: this.latitude, longitude: this.longitude, timestamp: this.departure);
21 :
22 : static LocationDegrees sumLatitude(List<Location> locations) {
23 10 : return new LocationDegrees(degrees: locations.fold(0.0, (value, element) => value + element.latitude.degrees));
24 : }
25 :
26 : static LocationDegrees sumLongitude(List<Location> locations) {
27 10 : return new LocationDegrees(degrees: locations.fold(0.0, (value, element) => value + element.longitude.degrees));
28 : }
29 : }
|