diff --git a/inc/import/parser/class.ParserFITSingle.php b/inc/import/parser/class.ParserFITSingle.php index 6a6e3528ea..fb04885750 100644 --- a/inc/import/parser/class.ParserFITSingle.php +++ b/inc/import/parser/class.ParserFITSingle.php @@ -189,7 +189,7 @@ protected function readFileId() { * Read device info */ protected function readDeviceInfo() { - if (isset($this->Values['garmin_product'])) + if (isset($this->Values['garmin_product']) && isset($this->Values['device_index']) && $this->Values['device_index'][0] == 0) $this->TrainingObject->setCreator($this->Values['garmin_product'][1]); } @@ -308,6 +308,8 @@ protected function readRecord() { $this->gps['km'][] = isset($this->Values['distance']) ? round($this->Values['distance'][0] / 1e5, ParserAbstract::DISTANCE_PRECISION) : end($this->gps['km']); $this->gps['heartrate'][] = isset($this->Values['heart_rate']) ? (int)$this->Values['heart_rate'][0] : 0; $this->gps['rpm'][] = isset($this->Values['cadence']) ? (int)$this->Values['cadence'][0] : 0; + $this->gps['power'][] = isset($this->Values['power']) ? (int)$this->Values['power'][0] : 0; + //$this->gps['left_right'][] = isset($this->Values['left_right_balance']) ? (int)$this->Values['left_right_balance'][0] : 0; $this->gps['temp'][] = isset($this->Values['temperature']) ? (int)$this->Values['temperature'][0] : 0; diff --git a/tests/inc/import/filetypes/ImporterFiletypeFITTest.php b/tests/inc/import/filetypes/ImporterFiletypeFITTest.php index e05f724e74..50100a657d 100644 --- a/tests/inc/import/filetypes/ImporterFiletypeFITTest.php +++ b/tests/inc/import/filetypes/ImporterFiletypeFITTest.php @@ -354,4 +354,30 @@ public function testHRV() { } } + + /* + * Test: with power data + * Filename: "with-power.fit" + */ + public function testWithPowerData() { + if (Shell::isPerlAvailable()) { + $this->object->parseFile('../tests/testfiles/fit/with-power.fit'); + + $this->assertFalse( $this->object->hasMultipleTrainings() ); + $this->assertFalse( $this->object->failed() ); + + $this->assertEquals('edge810', $this->object->object()->getCreator()); + $this->assertEquals(3600 + 18*60 + 9, $this->object->object()->getTimeInSeconds()); + $this->assertEquals(39.023, $this->object->object()->getDistance()); + + $this->assertTrue($this->object->object()->hasArrayTime()); + $this->assertTrue($this->object->object()->hasArrayDistance()); + $this->assertTrue($this->object->object()->hasArrayAltitude()); + $this->assertTrue($this->object->object()->hasArrayHeartrate()); + $this->assertTrue($this->object->object()->hasArrayCadence()); + $this->assertTrue($this->object->object()->hasArrayTemperature()); + $this->assertTrue($this->object->object()->hasArrayPower()); + + } + } } diff --git a/tests/testfiles/fit/with-power.fit b/tests/testfiles/fit/with-power.fit new file mode 100755 index 0000000000..4f166b19cc Binary files /dev/null and b/tests/testfiles/fit/with-power.fit differ