1. Go to this page and download the library: Download emontis/fit-reader library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$session = FitReader::activity('run.fit')->sessions[0];
foreach ($session->records as $r) {
$dist[] = $r->distance; // cumulative metres
$time[] = $r->timestamp->getTimestamp(); // seconds
}
// slide a window over $dist/$time to find the min time covering ≥ N metres
foreach ($session->recordsNormalized() as $r) {
$zone = zoneFor($r->heartRate, $session->maxHeartRate);
$timeInZone[$zone]++; // one second per record on the normalized timeline
}
$bounds = FitReader::trackBounds($activity); // ?BoundingBox over all sessions
$center = $bounds?->center(); // GeoPoint
$json = FitReader::activityToGeoJsonString($activity);
// or write a file: FitReader::activityToGeoJson($activity, 'ride.geojson');
// from an already processed Activity object
FitReader::activityToCsv($activity, 'ride.csv'); // raw records
FitReader::activityToCsv($activity, 'ride.csv', normalize: true); // default normalizer
FitReader::activityToCsv($activity, 'ride.csv', normalize: [
'derive' => ['speed_kmh' => FitReader::kilometersPerHourFromGps(10)],
]); // records normalized with a customized normalizer
// or, directly from a FIT file
FitReader::fitToCsv('ride.fit', 'ride.csv');
// from an already processed Activity object
FitReader::activityToGpx($activity, 'ride.gpx'); // raw records
FitReader::activityToGpx($activity, 'ride.gpx', normalize: true); // default normalizer
FitReader::activityToGpx($activity, 'ride.gpx', normalize: [
'derive' => ['speed_kmh' => FitReader::kilometersPerHourFromGps(10)],
]); // records normalized with a customized normalizer
// or, directly from a FIT file
FitReader::fitToGpx('ride.fit', 'ride.gpx');
// from an already processed Activity object
FitReader::activityToKml($activity, 'ride.kml'); // raw records
FitReader::activityToKml($activity, 'ride.kml', normalize: true); // default normalizer
FitReader::activityToKml($activity, 'ride.kml', normalize: [
'derive' => ['speed_kmh' => FitReader::kilometersPerHourFromGps(10)],
]); // records normalized with a customized normalizer
// or, directly from a FIT file
FitReader::fitToKml('ride.fit', 'ride.kml');
// from an already processed Activity object
FitReader::activityToTcx($activity, 'ride.tcx'); // raw records
FitReader::activityToTcx($activity, 'ride.tcx', normalize: true); // default normalizer
FitReader::activityToTcx($activity, 'ride.tcx', normalize: [
'derive' => ['speed_kmh' => FitReader::kilometersPerHourFromGps(10)],
]); // records normalized with a customized normalizer
// or, directly from a FIT file
FitReader::fitToTcx('ride.fit', 'ride.tcx');
// from an already processed Activity object
FitReader::activityToGeoJson($activity, 'ride.geojson');
// or, directly from a FIT file
FitReader::fitToGeoJson('ride.fit', 'ride.geojson');
// string variants, without writing a file:
$json = FitReader::activityToGeoJsonString($activity);
$json = FitReader::fitToGeoJsonString('ride.fit');
$token = getenv('MAPBOX_TOKEN'); // your Mapbox access token
// from an already processed Activity object
FitReader::activityToMapPng($activity, 'ride.png', $token);
// or, directly from a FIT file
FitReader::fitToMapPng('ride.fit', 'ride.png', $token);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.