Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/mobility_features/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.2.1

* Fix `distanceTraveled` always being 0: the path window between two stops ended at the first stop, so every move had an empty path. Falls back to the straight-line distance when no samples are kept (e.g. after a restart).

## 6.2.0

* upgrade to `carp_serializable` ^3.0.0
Expand Down
1 change: 1 addition & 0 deletions packages/mobility_features/lib/mobility_features.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class MobilityFeatures {
_places.clear();
_cluster.clear();
_buffer.clear();
_samples.clear();
}

/// Save a sample to the buffer and store samples on disk if buffer overflows
Expand Down
8 changes: 6 additions & 2 deletions packages/mobility_features/lib/src/mobility_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ List<Move> _findMoves(List<Stop> stops, List<LocationSample> samples) {
final path = samples
.where((s) =>
previous!.dateTime.leq(s.dateTime) &&
previous.dateTime.geq(s.dateTime))
current.dateTime.geq(s.dateTime))
.toList();
Move m = Move.fromPath(previous, current, path);
// No path (samples not kept across restarts) - fall back to the
// straight line between the stops rather than reporting 0 m.
Move m = path.length > 1
? Move.fromPath(previous, current, path)
: Move.fromStops(previous, current);
moves.add(m);
}
previous = current;
Expand Down
2 changes: 1 addition & 1 deletion packages/mobility_features/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mobility_features
description: Calculation of real-time mobility features like places, stops, and home stay
version: 6.2.0
version: 6.2.1
homepage: https://github.com/cph-cachet/flutter-plugins/

environment:
Expand Down
5 changes: 5 additions & 0 deletions packages/mobility_features/test/mobility_features_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ void main() async {
void onContext(MobilityContext mc) {
print(mc.toJson());
printList(mc.stops!);
// Once there is a move, distance is the walked path (~1.5 km home ->
// Falkoner Alle), not 0 - the path window must span the two stops.
if (mc.numberOfMoves! > 0) {
expect(mc.distanceTraveled, greaterThan(1000));
}
}

flushFiles();
Expand Down
Loading