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
Landmark Routing 6 PR: Update narrative generation with landmarks #4301
base: master
Are you sure you want to change the base?
Conversation
Reminder to ourselves: since we're updating (possibly) stale translation files here, we should first pull whatever transifex has currently, merge to master, then merge master in this PR, to avoid tons of conflicts. Let's do that right before merging in a few weeks. |
locales/en-US.json
Outdated
@@ -2036,6 +2188,7 @@ | |||
"6": "Make a <RELATIVE_DIRECTION> U-turn at <JUNCTION_NAME>.", | |||
"7": "Make a <RELATIVE_DIRECTION> U-turn toward <TOWARD_SIGN>." | |||
}, | |||
"landmark_types": [], |
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.
for u-turn we also want landmark narratives
src/odin/narrativebuilder.cc
Outdated
@@ -4531,6 +4581,52 @@ NarrativeBuilder::FormRelativeThreeDirection(DirectionsLeg_Maneuver_Type type, | |||
} | |||
} | |||
|
|||
std::string NarrativeBuilder::FormLandmarkType(RouteLandmark_Type type, |
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.
instead of this function, we can cast the RouteLandmark_Type
to uint8_t
and index into the phrases directly
src/odin/narrativebuilder.cc
Outdated
// close, than we pick the nearest left handed one. | ||
valhalla::RouteLandmark select_landmark(const std::vector<valhalla::RouteLandmark>& landmarks, | ||
const std::string& relative_direction) { | ||
bool direction = relative_direction == "right" ? 1 : 0; |
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.
bool direction = relative_direction == "right" ? 1 : 0; | |
bool turn_direction = relative_direction == "right"; |
src/odin/narrativebuilder.cc
Outdated
int idx = -1; | ||
double min_dist = -1; | ||
for (auto i = 0; i < landmarks.size(); ++i) { | ||
// adjust landmark distance with compensation based on their direction | ||
auto dist = landmarks[i].right() == direction | ||
? landmarks[i].distance() | ||
: (landmarks[i].distance() + kLandmarkOppositeDirectionCompensation); | ||
if (idx == -1) { | ||
idx = i; | ||
min_dist = dist; | ||
} else if (dist < min_dist) { | ||
idx = i; | ||
min_dist = dist; | ||
} | ||
} | ||
return landmarks[idx]; | ||
} |
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.
int idx = -1; | |
double min_dist = -1; | |
for (auto i = 0; i < landmarks.size(); ++i) { | |
// adjust landmark distance with compensation based on their direction | |
auto dist = landmarks[i].right() == direction | |
? landmarks[i].distance() | |
: (landmarks[i].distance() + kLandmarkOppositeDirectionCompensation); | |
if (idx == -1) { | |
idx = i; | |
min_dist = dist; | |
} else if (dist < min_dist) { | |
idx = i; | |
min_dist = dist; | |
} | |
} | |
return landmarks[idx]; | |
} | |
size_t idx = 0; | |
double min_dist = std::numeric_limits<double>::max(); | |
for (auto i = 0; i < landmarks.size(); i++) { | |
// adjust landmark distance with compensation based on their direction | |
auto dist = landmarks[i].right() == direction | |
? landmarks[i].distance() | |
: (landmarks[i].distance() + kLandmarkOppositeDirectionCompensation); | |
if (dist < min_dist) { | |
idx = i; | |
min_dist = dist; | |
} | |
} | |
return landmarks[idx]; | |
} |
src/odin/narrativebuilder.cc
Outdated
// Make sure the landmark type is legal | ||
if (static_cast<int>(landmark.type()) > 0 && | ||
static_cast<int>(landmark.type()) < subset->landmark_types.size()) { | ||
// increment the phrase id by 6 to get the corresponding landmark phrase | ||
phrase_id += 6; | ||
} |
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.
IMO we don't need a check like this, bcs we're in full control of the landmark types and we do make sure in the data building pipeline that nothing enters that's outside of the type bounds. If we want to check this at this point, then let's throw an exception, bcs that'd be a very serious flaw.
…ot added in case of lack of vacancy, and inconsistent input in valhalla_add_landmarks and AddLandmarks
One thing we noticed is that the overall graph size is shrinking after adding landmarks. |
@@ -51,7 +49,7 @@ int main(int argc, char** argv) { | |||
valhalla::midgard::logging::Configure(logging_config); | |||
} | |||
|
|||
if (!valhalla::mjolnir::AddLandmarks(pt.get_child("mjolnir"))) { | |||
if (!valhalla::mjolnir::AddLandmarks(pt)) { |
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.
if (!valhalla::mjolnir::AddLandmarks(pt)) { | |
if (!valhalla::mjolnir::AddLandmarks(pt.get_child("mjolnir"))) { |
I've edited AddLandmarks to handle the input as child mjolnir, maybe we want to change this back to get child mjolnir. it works for me :)
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.
Yeah I must not've seen that for some reason. Weird though that I could push at all if I didn't pull your changes before.. I'll revert this!
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.
I guess you can push because there is no conflict caused by this commit
I started looking at this again, but didn't get very far yet. When I tried a route request, it wouldn't work, because we mess smth up when adding landmarks and make the tiles invalid somehow (as said before, tile size shrinks when adding landmarks!). It's not much code, but still annoying to debug. |
yeah i was hoping we could patch it up to the point that it could somewhat work sometimes and be a thing we opt into. maybe in the coming weeks we can pair on it for an hour at a time a couple times a week |
my shortcut PR to remove names/speed is just tripping over the landmarks stuff: @kevinkreiser reminder for us to check how shortcuts are behaving with landmarks.. might be very well the key.. |
interesting hypothesis. imho we shouldn't put them on shortcuts anyway its a duplication without purpose |
Yeah we don’t want that. But seems like we are, and while not being aware of it, |
also we use loki search iirc which doesn't return shortcuts |
Right, I think that was a fluke.. the test was going over the tileset and exactly, didn’t expect to see shortcuts, so all good there |
Issue
Update narrative generation process to support the use of landmarks in text guidance.
Tasklist
Requirements / Relations
Landmark Routing 6: Narrative Generation Updates #4138