Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create statistics from GPX extensions #15

Open
carstengrimm opened this issue Oct 14, 2017 · 7 comments
Open

Create statistics from GPX extensions #15

carstengrimm opened this issue Oct 14, 2017 · 7 comments
Milestone

Comments

@carstengrimm
Copy link

I just discovered phpGPX and while i am only trying to read out my gpx files, i have quickly discovered that heart rate is no being read out...

gpxtpx:hr107</gpxtpx:hr>

i am not a coder myself and more like a user, so i'll leave that as suggestion for following releases.
other than that, i am really amazed how easily phpGPX can be integrated, while looking around the best way to calculate the total distance from GPX file, this has helped me tremendously.

@Sibyx
Copy link
Owner

Sibyx commented Oct 15, 2017

Hi,
so you have problem with reading heart rate from GPX files at all or hr is not shown in statistics?

Currecntly I am calculating stats only for basic data as distance, elevation etc. I don't know exactly how to calculate stats properly from extension objects such as Garmin TrackPointExtension, because I want to find an universal way and support all the extensions in the end.

If you have problems with reading heart rate at all, that probably a bug which have to be fixed, so please let me know.

It's also nice to hear that phpGPX is easy to integrate and helpful for you :)

@carstengrimm
Copy link
Author

carstengrimm commented Oct 15, 2017

(
[distance] => 6513.8143967259
[avgSpeed] => 3.4907901375809
[avgPace] => 286.46809478298
[minAltitude] => 122
[maxAltitude] => 132.9
[cumulativeElevationGain] => 40.1
[startedAt] => 2016-08-25T20:42:35+00:00
[finishedAt] => 2016-08-25T21:13:41+00:00
[duration] => 1866
)

that's one of my sample gpx files which are output (dumped from $track->stats->toArray())

while the gpx file obviously uses heart rate too.. gpxtpx:hr on each gps tracking i guess i could still get it done (i have used simplexml on gpx files before) but i don't want to run 2 seperate readouts for HR while phpGPX already is very simplistic...

<trkpt lat="50.162982000" lon="8.623605000">
   <ele>128.5</ele>
   <time>2016-08-25T20:44:18Z</time>
   <extensions>
      <gpxtpx:TrackPointExtension>
         <gpxtpx:hr>152</gpxtpx:hr>
      </gpxtpx:TrackPointExtension>
   </extensions>
</trkpt>

@Sibyx
Copy link
Owner

Sibyx commented Oct 15, 2017

The stats attribute contains only aggregated/calculated data from GPX file ($track->stats object contain statistics from the whole file - all segments & points). If you want to access extensions data (gpxtpx:hr is not part of original GPX specification, but it's an Garmin TrackPoint extension - fully supported by phpGPX).

Heart rate belongs to point, not to whole track. phpGPX not currently support stats for the extensions as I said before. I am looking for the best implementation how to calculate stats for all kind of extensions.

If you want to access Garmin TrackPointExtension data, you can use

$track->segments[0]->$points[0]->extensions->trackPointExtension->hr;

var_dump($track->segments[0]->points[0]->extensions->trackPointExtension->);

If you still can't find the extension data, please let me know, is probably a bug which have to be fixed. I hope I helped you, if there is still something unclear feel free to ask ;)

@carstengrimm
Copy link
Author

carstengrimm commented Oct 15, 2017

yeah i can call each single point...
i guess i would have to go manually iterate though each point[$i]->extension->track...->hr;
and calculate the average

@Sibyx
Copy link
Owner

Sibyx commented Oct 15, 2017

Yop,
I am so sorry but currently there is no other way :( But once I will be done with tests and new documentation, this is the first thing for marked for implementation.

@carstengrimm
Copy link
Author

no worries

@Sibyx Sibyx changed the title Heart Rate not accessable in Stats Create statistics from GPX extensions Oct 15, 2017
@Sibyx Sibyx added the feature label Oct 15, 2017
@Sibyx Sibyx added this to the phpGPX 2.0 milestone Jul 29, 2023
@Sibyx
Copy link
Owner

Sibyx commented Aug 2, 2023

I would like to implement this using middlewares in 2.x. Please check #67 for more information.

@Sibyx Sibyx removed the feature label Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants