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

Statistics - get Bounds of the GPX Routes #28

Open
ramblerswebs opened this issue Mar 27, 2018 · 15 comments
Open

Statistics - get Bounds of the GPX Routes #28

ramblerswebs opened this issue Mar 27, 2018 · 15 comments

Comments

@ramblerswebs
Copy link

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.

@Sibyx
Copy link
Owner

Sibyx commented Mar 28, 2018

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.

@Sibyx Sibyx added the feature label Mar 28, 2018
@ramblerswebs
Copy link
Author

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

@Sibyx Sibyx added this to the phpGPX 2.0 milestone Jul 29, 2023
@Sibyx
Copy link
Owner

Sibyx commented Jul 29, 2023

This feature is nice to have in a 2.x release. The bounding box will be created for each route, segment and track.

@miqwit
Copy link
Contributor

miqwit commented Mar 7, 2024

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;}
    }
  }
}

@Sibyx
Copy link
Owner

Sibyx commented Mar 7, 2024

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.

@miqwit
Copy link
Contributor

miqwit commented Mar 8, 2024

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.

@miqwit
Copy link
Contributor

miqwit commented Mar 8, 2024

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).

@Sibyx
Copy link
Owner

Sibyx commented Mar 10, 2024

@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.

@miqwit
Copy link
Contributor

miqwit commented Mar 10, 2024

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".

@Sibyx
Copy link
Owner

Sibyx commented Mar 10, 2024

@miqwit how did you created the feature branch? Did you created a fork? My proposed solution:

  1. Fork phpGPX
  2. Add you changes to the fork
  3. Create PR (hopefully without any problems)

@miqwit
Copy link
Contributor

miqwit commented Mar 14, 2024

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 element is not in the GPX (I am in this situation) it can be useful to compute it ; only when it's not there already. In this case my code will be useful. I can go in this direction if you agree it's a good way.

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?

@Sibyx
Copy link
Owner

Sibyx commented Mar 14, 2024

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.

@Sibyx
Copy link
Owner

Sibyx commented Mar 14, 2024

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.

@miqwit
Copy link
Contributor

miqwit commented Mar 14, 2024

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).

@Sibyx
Copy link
Owner

Sibyx commented Mar 14, 2024

Yeah, I guess that makes sense. Thank you very much. If you have any questions feel free to ask ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants