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

Refactor the OSRM/BirdDistance management #256

Merged
merged 4 commits into from
Oct 23, 2023

Conversation

greenscientist
Copy link
Contributor

This:

  • Split The OsrmFetcher into 2 classes and a base class. The OSRM side and Bird distance (now Euclidean) are in their own class. We pass the desired object to the Calculator constructor.
  • Add a CLI option so active the Euclidean (Bird distance) mode
  • Add a check for errors from OSRM. (Like if the server is not running)

@greenscientist greenscientist requested a review from tahini August 31, 2023 20:19
@greenscientist greenscientist linked an issue Aug 31, 2023 that may be closed by this pull request
Copy link
Collaborator

@tahini tahini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions and comments, otherwise it looks good. Did you test with/without transition?

};
}

#endif // TR_OSRM_GEO_FILTER
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TR_EUCLIDEAN... fwiw

// Common utility functions
static std::tuple<float, float> calculateLengthOfOneDegree(const Point &point);
static float calculateMaxDistanceSquared(int maxWalkingTravelTime, float walkingSpeed);
//TODO WHy one point * and other &
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed good question, why? It was like that before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that was just a copy paste from the previous code.


std::string queryString = "/table/v1/" + mode + "/" + std::to_string(point.longitude) + "," + std::to_string(point.latitude);

for (auto &&[uuid,node] : nodes)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this part of the code actually use the euclidian distance? Instead of having to use the protected methods here to calculate something that really looks like the euclidian distance (I haven't compare the exact code).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum, I guess you are right, need to look at the code more, but it seems we are doing the euclidian first to filter the nodes and then filter those with OSRM.

(it hurts to know that the data is also in PostGIS usually, since that query would be so simple to do there. )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, re-read the code in more detail.
It does calculate the euclidian distance, but it does something different with the data. Using the common base functions seems the best way to go here. I'll try to add a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tahini Let me know if the comment I added explain the difference sufficiently.

The bird distance was renamed to euclidean.

This allow to pass the desired object to the Calculator constructor and thus allowing
us to select which method we want to use. This replace the global static
variable.

We don't use the cycling and driving mode so we instanciate an OsrmGeoFilter for those. The OSRM
parameters (host/port) are now part of the OsrmGeoFilter object.

AccessMode and EgressMode was always walking, we removed those variables from the Paramters object.
Setting the option --useEuclideanDistance=true will selection the EuclideanGeoFilter instead of
the OsrmGeoFilter. This is mostly useful for testing and debugging, where you might not
have an OSRM deamon running.
Validate that the server returned an 200 OK before attempting to parse the OSRM
data. The function will return an empty array if the response was not valid
…er in

the OSRMGeoFilter, in the first filter pass
Copy link
Collaborator

@tahini tahini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, but nothing to do about them

protected:
// Common utility functions
static std::tuple<float, float> calculateLengthOfOneDegree(const Point &point);
static float calculateMaxDistanceSquared(int maxWalkingTravelTime, float walkingSpeed);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually todo, don't refer to walking, it's just a travel time and speed

Calculator calculator(transitData);

// Selection which geofilter to use. OSRM is the default one. Euclidean mostly used for debugging and testing
GeoFilter *geoFilter = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pointer never gets deleted. I guess it doesn't matter since it's constructed once in the main?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it should be cleaned, but it does not really matter as you said since it lives for the whole duration of the program.

@greenscientist greenscientist merged commit 47b1615 into chairemobilite:v2c Oct 23, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to specify to use bird distance if osrm not present
2 participants