From d1919d537da63d30501c65b5208e148fda64a3bb Mon Sep 17 00:00:00 2001 From: Collin Fair Date: Thu, 10 Sep 2015 12:14:55 -0400 Subject: [PATCH] Fix incorrectly marking activities from RK as non-GPS, better handling of indoor activities --- tapiriik/services/RunKeeper/runkeeper.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tapiriik/services/RunKeeper/runkeeper.py b/tapiriik/services/RunKeeper/runkeeper.py index 5d99fc807..c6ba27119 100644 --- a/tapiriik/services/RunKeeper/runkeeper.py +++ b/tapiriik/services/RunKeeper/runkeeper.py @@ -150,7 +150,8 @@ def _populateActivity(self, rawRecord): activity.Stats.Energy = ActivityStatistic(ActivityStatisticUnit.Kilocalories, value=rawRecord["total_calories"] if "total_calories" in rawRecord else None) if rawRecord["type"] in self._activityMappings: activity.Type = self._activityMappings[rawRecord["type"]] - activity.GPS = rawRecord["has_path"] + activity.GPS = rawRecord["has_path"] and rawRecord['tracking_mode'] == "outdoor" + activity.Stationary = not rawRecord["has_path"] activity.CalculateUID() return activity @@ -205,20 +206,22 @@ def _populateActivityWaypoints(self, rawData, activity): def _addWaypoint(timestamp, path=None, heart_rate=None, calories=None, distance=None): waypoint = Waypoint(activity.StartTime + timedelta(seconds=timestamp)) if path: - waypoint.Location = Location(path["latitude"], path["longitude"], path["altitude"] if "altitude" in path and float(path["altitude"]) != 0 else None) # if you're running near sea level, well... + if path["latitude"] != 0 and path["longitude"] != 0: + waypoint.Location = Location(path["latitude"], path["longitude"], path["altitude"] if "altitude" in path and float(path["altitude"]) != 0 else None) # if you're running near sea level, well... waypoint.Type = self._wayptTypeMappings[path["type"]] if path["type"] in self._wayptTypeMappings else WaypointType.Regular waypoint.HR = heart_rate waypoint.Calories = calories waypoint.Distance = distance lap.Waypoints.append(waypoint) + StreamSampler.SampleWithCallback(_addWaypoint, streamData) + activity.Stationary = len(lap.Waypoints) == 0 + activity.GPS = any(wp.Location and wp.Location.Longitude is not None and wp.Location.Latitude is not None for wp in lap.Waypoints) if not activity.Stationary: lap.Waypoints[0].Type = WaypointType.Start lap.Waypoints[-1].Type = WaypointType.End - StreamSampler.SampleWithCallback(_addWaypoint, streamData) - def UploadActivity(self, serviceRecord, activity): # assembly dict to post to RK uploadData = self._createUploadData(activity, serviceRecord.GetConfiguration()["auto_pause"])