def _populateActivityWaypoints(self, rawData, activity):
        ''' populate the Waypoints collection from pulsstory API data '''
        lap = Lap(stats=activity.Stats, startTime=activity.StartTime, endTime=activity.EndTime)
        activity.Laps = [lap]

        streamData = {}

        self._convertList(streamData, "heart_rate", rawData, "HeartRate")
        self._convertList(streamData, "distance", rawData, "Distance")
        self._convertList(streamData, "speed", rawData, "Speed")
        self._convertList(streamData, "power", rawData, "Power")
        self._convertList(streamData, "cadence", rawData, "Cadence")
        self._convertPathList(streamData, "path", rawData)

        def _addWaypoint(timestamp, path=None, heart_rate=None, power=None, distance=None, speed=None, cadence=None):
            waypoint = Waypoint(activity.StartTime + timedelta(seconds=timestamp))
            if path:
                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 = WaypointType.Regular
            waypoint.HR = heart_rate
            waypoint.Distance = distance
            waypoint.Speed = speed
            waypoint.Cadence = cadence
            waypoint.Power = power
            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
 populate the Waypoints collection from pulsstory API data 
tapiriik/services/Pulsstory/pulsstory.py