You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 16, 2025. It is now read-only.
The get_bounds() function returns a BBox that does not take into account the search radius.
The function only returns the minimum and maximum latitude and longitude of the GPX points. The points at the maximum and minimum therefore have a half of their search area outside the BBOX. This can be particularly problematic on a spiral-shaped track.
Here is a proposed solution to this problem (sorry, I don't have a pull request because I got a little carried away on my fork).
defget_bounds(gpx, max_distance_m):
""" Return GPX trace bounding box [south, west, north, est] iterate over points only once. """# Initialize min/max values with extreme valuesmin_lat=float('inf')
max_lat=float('-inf')
min_lon=float('inf')
max_lon=float('-inf')
# Compute angular margin use to expand the boundsapprox_degrees_per_meter=1/111320.0angular_margin=max_distance_m*approx_degrees_per_meter*1.5#arbitrary safety factor# Flag to check if any points were foundfound_points=Falsefortrkingpx.tracks:
forsegintrk.segments:
forptinseg.points:
found_points=True# Update min/max latitudemin_lat=min(min_lat, pt.latitude)
max_lat=max(max_lat, pt.latitude)
# Update min/max longitudemin_lon=min(min_lon, pt.longitude)
max_lon=max(max_lon, pt.longitude)
ifnotfound_points:
returnNonemin_lat-=angular_marginmax_lat+=angular_marginmin_lon-=angular_marginmax_lon+=angular_marginreturnmin_lat, min_lon, max_lat, max_lon