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
This draft replaces expensive latlon3 wrapper calls in geographic helpers with direct reusable pyproj.Geod calls.
The goal is to keep the same WGS84/spherical geodesic behavior while avoiding repeated object construction, repeated Geod construction, string formatting, and string parsing in routing hot paths.
Added scripts/benchmark_latlon.py to compare the old latlon path against the new direct pyproj path for:
point_distance
routage_point_distance
lossodromic
Number of iterations: 10000
>> utils.point_distance <<
Sum relative error = 0.000E+00
latlon time: 1.148272
pyproj time time: 0.095083
time reduction: 12.1x
>> utils.routage_point_distance <<
Sum errors = 1.063E-12
latlon time: 1.446403
pyproj time time: 0.118104
time reduction: 12.2x
>> utils.lossodromic <<
Sum relative error (distance) = 0.000E+00
Sum relative error (angle) = 1.106E-15
latlon time: 1.382446
pyproj time time: 0.123218
time reduction: 11.2x
Using the current test suite as a rough routing benchmark, with a minor temporary fix for tests/shortestpathrouter_test.py::TestRoutingNoIsland (see below), I averaged the runtime over 10 runs. Baseline (latlon):
Test time - runs: 10
max: 113.005s
mean: 101.295s
Proposed (pyproj):
Test time - runs: 10
max: 24.573s
mean: 17.482s
TestRoutingNoIsland
The proposed change exposes a brittle assertion in tests/shortestpathrouter_test.py::TestRoutingNoIsland. The test uses the length of the serialized GeoJSON output as a reference value. This is a rough proxy for correctness and is sensitive to insignificant floating-point representation differences.
Comparing the route produced by the baseline library with the route produced by this PR shows that the route is effectively unchanged. The same route structure, timestamps, predecessor chain, endpoint, wind values, speed, and headings are preserved. The differences are only floating-point tail differences.
The coordinate drift is negligible. This should not be treated as a routing regression.
A more suitable test could assert route properties with numeric tolerances, such as the number of steps, the final timestamp, the path length, the endpoint, and the distance between expected and actual coordinates, instead of json.dumps(path_as_geojson(...)).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This draft replaces expensive
latlon3wrapper calls in geographic helpers with direct reusablepyproj.Geodcalls.The goal is to keep the same WGS84/spherical geodesic behavior while avoiding repeated object construction, repeated
Geodconstruction, string formatting, and string parsing in routing hot paths.Added
scripts/benchmark_latlon.pyto compare the oldlatlonpath against the new directpyprojpath for:point_distanceroutage_point_distancelossodromic