-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Improve performance of map matching via getPathDistance optimization #6378
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5913d54
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou 4c29557
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou f4594b0
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou 7df38a0
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou ec1f10a
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou afede76
Update osrm-backend.yml
SiarheiFedartsou ed9d56a
Update osrm-backend.yml
SiarheiFedartsou 3b0dda5
Update osrm-backend.yml
SiarheiFedartsou 04bfcb4
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou dec039b
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou 1877e52
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou 05f3d10
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou 97e9e48
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou 0e38f36
Improve performance of map matching via getPathDistance optimization
SiarheiFedartsou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,49 +353,21 @@ double getPathDistance(const DataFacade<Algorithm> &facade, | |
const PhantomNode &source_phantom, | ||
const PhantomNode &target_phantom) | ||
{ | ||
using util::coordinate_calculation::detail::DEGREE_TO_RAD; | ||
using util::coordinate_calculation::detail::EARTH_RADIUS; | ||
|
||
double distance = 0; | ||
double prev_lat = | ||
static_cast<double>(util::toFloating(source_phantom.location.lat)) * DEGREE_TO_RAD; | ||
double prev_lon = | ||
static_cast<double>(util::toFloating(source_phantom.location.lon)) * DEGREE_TO_RAD; | ||
double prev_cos = std::cos(prev_lat); | ||
double distance = 0.0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
auto prev_coordinate = source_phantom.location; | ||
|
||
for (const auto &p : unpacked_path) | ||
{ | ||
const auto current_coordinate = facade.GetCoordinateOfNode(p.turn_via_node); | ||
|
||
const double current_lat = | ||
static_cast<double>(util::toFloating(current_coordinate.lat)) * DEGREE_TO_RAD; | ||
const double current_lon = | ||
static_cast<double>(util::toFloating(current_coordinate.lon)) * DEGREE_TO_RAD; | ||
const double current_cos = std::cos(current_lat); | ||
|
||
const double sin_dlon = std::sin((prev_lon - current_lon) / 2.0); | ||
const double sin_dlat = std::sin((prev_lat - current_lat) / 2.0); | ||
|
||
const double aharv = sin_dlat * sin_dlat + prev_cos * current_cos * sin_dlon * sin_dlon; | ||
const double charv = 2. * std::atan2(std::sqrt(aharv), std::sqrt(1.0 - aharv)); | ||
distance += EARTH_RADIUS * charv; | ||
distance += | ||
util::coordinate_calculation::greatCircleDistance(prev_coordinate, current_coordinate); | ||
|
||
prev_lat = current_lat; | ||
prev_lon = current_lon; | ||
prev_cos = current_cos; | ||
prev_coordinate = current_coordinate; | ||
} | ||
|
||
const double current_lat = | ||
static_cast<double>(util::toFloating(target_phantom.location.lat)) * DEGREE_TO_RAD; | ||
const double current_lon = | ||
static_cast<double>(util::toFloating(target_phantom.location.lon)) * DEGREE_TO_RAD; | ||
const double current_cos = std::cos(current_lat); | ||
|
||
const double sin_dlon = std::sin((prev_lon - current_lon) / 2.0); | ||
const double sin_dlat = std::sin((prev_lat - current_lat) / 2.0); | ||
|
||
const double aharv = sin_dlat * sin_dlat + prev_cos * current_cos * sin_dlon * sin_dlon; | ||
const double charv = 2. * std::atan2(std::sqrt(aharv), std::sqrt(1.0 - aharv)); | ||
distance += EARTH_RADIUS * charv; | ||
distance += | ||
util::coordinate_calculation::greatCircleDistance(prev_coordinate, target_phantom.location); | ||
|
||
return distance; | ||
} | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this to CI just to be more confident that they are still working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also numbers seem to be quite stable from run to run, i.e. we will probably be able to use it in the future to track performance changes in PRs.