Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
wip: change route location naming to route point
  • Loading branch information
benlrichards committed Oct 15, 2024
commit d0adb6461ee5edc0eec9d38e0cb6d5c38e3e4d1a
2 changes: 1 addition & 1 deletion packages/health/lib/health.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ part 'src/health_data_point.dart';
part 'src/health_plugin.dart';
part 'src/health_value_types.dart';
part 'src/heath_data_types.dart';
part 'src/route_location.dart';
part 'src/route_point.dart';
part 'src/workout_summary.dart';
32 changes: 22 additions & 10 deletions packages/health/lib/health.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions packages/health/lib/src/route_location.dart

This file was deleted.

55 changes: 55 additions & 0 deletions packages/health/lib/src/route_point.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
part of '../health.dart';

/// A [RoutePoint] object stores various metrics of a route location.
///
/// * [longitude] - The longitude of the location.
/// * [latitude] - The latitude of the location.
/// * [altitude] - The altitude of the location.
/// * [timestamp] - The timestamp of the location.
/// * [horizontalAccuracy] - The horizontal accuracy of the location.
/// * [verticalAccuracy] - The vertical accuracy of the location.
@JsonSerializable(includeIfNull: false, explicitToJson: true)
class RoutePoint {
/// The longitude of the location.
double longitude;

/// The latitude of the location.
double latitude;

/// The altitude of the location.
double altitude;

/// The timestamp of the location.
int timestamp;

/// The horizontal accuracy of the location.
double? horizontalAccuracy;

/// The vertical accuracy of the location.
double? verticalAccuracy;

RoutePoint({
required this.longitude,
required this.latitude,
required this.altitude,
required this.timestamp,
this.horizontalAccuracy,
this.verticalAccuracy,
});

/// Create a [RoutePoint] from json.
factory RoutePoint.fromJson(Map<String, dynamic> json) =>
_$RoutePointFromJson(json);

/// Convert this [RoutePoint] to json.
Map<String, dynamic> toJson() => _$RoutePointToJson(this);

@override
String toString() => '$runtimeType - '
'longitude: $longitude'
'latitude: $latitude, '
'altitude: $altitude, '
'timestamp: $timestamp, '
'horizontalAccuracy: $horizontalAccuracy, '
'verticalAccuracy: $verticalAccuracy';
}
10 changes: 7 additions & 3 deletions packages/health/lib/src/workout_summary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ part of '../health.dart';
/// * [totalDistance] - The total distance that was traveled during a workout.
/// * [totalEnergyBurned] - The amount of energy that was burned during a workout.
/// * [totalSteps] - The number of steps during a workout.
/// * [route] - The route of the workout.
@JsonSerializable(includeIfNull: false, explicitToJson: true)
class WorkoutSummary {
/// Workout type.
Expand All @@ -20,7 +21,8 @@ class WorkoutSummary {
/// The total steps value of the workout.
num totalSteps;

List<RouteLocation>? route;
/// The route of the workout.
List<RoutePoint>? route;

WorkoutSummary({
required this.workoutType,
Expand All @@ -39,11 +41,13 @@ class WorkoutSummary {
totalSteps: dataPoint['total_steps'] as num? ?? 0,
route: (dataPoint['route'] as List<dynamic>?)?.isNotEmpty ?? false
? (dataPoint['route'] as List<dynamic>?)!
.map((l) => RouteLocation(
.map((l) => RoutePoint(
longitude: l['longitude'] as double,
latitude: l['latitude'] as double,
altitude: l['altitude'] as double,
timestamp: l['timestamp'] as int))
timestamp: l['timestamp'] as int,
horizontalAccuracy: l['horizontal_accuracy'] as double?,
verticalAccuracy: l['vertical_accuracy'] as double?))
.toList()
: null,
);
Expand Down