public function getPoints($workoutId, $tz = null) { $url = "api/workout/get"; $params = ['fields' => 'points,simple', 'workoutId' => $workoutId]; for ($i = 0; $i < self::RETRIES; $i++) { $page = $this->getPageWithDot($url, $params); $json_decode = json_decode($page); if ($json_decode) { break; } } if (!$json_decode) { // three tries, and we can't get points $this->error .= "{$page}<br>"; return null; } $points = new Points($json_decode->start_time, $this->echoCallback, $this->googleMaps); $points->setGenerateGPX(true); if (isset($json_decode->points) && is_array($json_decode->points)) { foreach ($json_decode->points as $point) { if (isset($point->lat) && isset($point->lng) && isset($point->time)) { $points->add($point->lat, $point->lng, $point->time); } } } return $points; }
public function testGpx() { $points = new Points("2015-12-27 21:56:00 UTC", array($this, 'myEcho')); $points->clearStoredPoint(); $points->setGenerateGPX(true); $points->add(51.438407, -0.331903, "2015-12-28T10:40:13Z"); $points->add(51.438235, -0.331777, "2015-12-28T10:40:16Z"); $points->add(51.437872, -0.33151, "2015-12-28T10:40:22Z"); $points->add(51.437686, -0.331372, "2015-12-28T10:40:25Z"); $points->add(51.437498, -0.331266, "2015-12-28T10:40:28Z"); $points->add(51.437145, -0.331079, "2015-12-28T10:40:34Z"); $this->assertEquals(include 'data/expected/gpx.php', $points->gpx()); }