phpGPX
phpGPX copied to clipboard
Statistics - get Bounds of the GPX Routes
A useful new feature would be to be able to obtain the bounds of points in the GPX file. So you would retrieve the min/max Longitude and Latitude. I am looking at this package to process walking routes to get overall stats. The bounds would allow me to display all my routes on a single map. Each walk would have an icon showing stats and a link to display the actual walk. I have only just found this project but it looks good.
Hi, auto-generation of the Bounds object should be a nice feature. I can start with the implementation next week, or feel free to offer a PR.
thanks, I am new to this package but it looks very good. It would be great to have the above facility.
On a side issue I am having trouble with my require statements as I seem to need them in a particular order. Is there an easy way to load these classes, I am running within Joomla which has its own autoload classes
This feature is nice to have in a 2.x release. The bounding box will be created for each route, segment and track.
Hello. +1 here. Any progress on this? Would you need help to implement it? I have this code in PHP in my project (reading a geojson file), which does the trick. It would be nice to have in this library.
// Find the bounds of the trace, for a later zoom in mapbox
$geojsonArray = json_decode($geoJson, true);
// Initialize variables to store the most NW and SE points
$north = -PHP_FLOAT_MAX; // Longest lat
$east = -PHP_FLOAT_MAX; // Longest lon
$south = PHP_FLOAT_MAX; // Smallest lat
$west = PHP_FLOAT_MAX; // Smallest lon
// Iterate through each feature and its coordinates
foreach ($geojsonArray['features'] as $feature) {
foreach ($feature['geometry']['coordinates'] as $lineString) {
foreach ($lineString as $point) {
$lng = $point[0];
$lat = $point[1];
// Update northWest and southEast points if needed
if ($lat > $north) {$north = $lat;}
if ($lng > $east) {$east = $lng;}
if ($lat < $south) {$south = $lat;}
if ($lng < $west) {$west = $lng;}
}
}
}
Yeah, I am sorry. I wish I had much more time for this project (think about it a lot). I don't want to make false promises about the deadline. If you offer a PR I will take a look. For the next two months, there is no way I will implement this. I am sorry. Thanks for your patience.
I updated my algorithm, as it had a problem. I will be happy to contribute to your library, I'll try to find time. On the other hand, it would be handy to export the track as an actual GeoJSON, rather than a proprietary JSON. I create another issue for that.
I worked on the bounds topic this morning, before seeing there is some work done in develop
:( Still, I'd like to submit my code in a PR for a review, even if it's discarded at a later stage. Can you add me as a collaborator to the project? (I can't create a PR right now).
@miqwit I will gladly wait for the PR ;) Sorry, but I am not right know a fan of direct access to the repository without PR process. I hope you are understand.
Yes I do. My problem is that I can't create a PR at all. I get this error: "Pull request creation failed. Validation failed: must be a collaborator".
@miqwit how did you created the feature branch? Did you created a fork? My proposed solution:
- Fork phpGPX
- Add you changes to the fork
- Create PR (hopefully without any problems)
OK, so I reviewed the develop
branch, and realised that it's taking the bounds from the GPX format, as described in the specification: https://www.topografix.com/GPX/1/1/#type_boundsType.
However, when the
First, can you tell me the state of the develop branch? Should I fork from there, or should I fork from master
and include both my code and your code?
Yeah, I agree that we should compute it. This feature should be configurable.
Currently, the state of the develop
branch is according to the Project Roadmap in the #67 discussion. I think that we should focus on the 2.x
release.
But I have to admit that develop
is right know not in the ideal state. There is still plenty of work regarding to the typing for example. I am already started with removing of the Summarizable interface and creating new configuration object.
Yes, I see. What I can suggest is that I work on another branch, and I take from develop
the work on the bounds, which is useful ; and in integrate my code (which respect the old-types format), what do you think? I created classes and even tests the way it is currently done (in master
).
Yeah, I guess that makes sense. Thank you very much. If you have any questions feel free to ask ;)