-
Notifications
You must be signed in to change notification settings - Fork 698
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
Add support for closure annotations #2816
Conversation
7082239
to
55278a9
Compare
55278a9
to
fff6c51
Compare
// is still within an existing closure) | ||
::valhalla::TripLeg_Closure* closure = fetch_or_create_closure_annotation(leg); | ||
if (!closure->has_begin_shape_index()) { | ||
closure->set_begin_shape_index(i - 1); |
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.
How come it's i - 1
and not just i
?
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.
Since this loops starts from the 2nd shape index. It does that since we create cuts only if speed changes in subsequent shape segments.
|
||
namespace { | ||
|
||
inline void SetLiveSpeedFrom(baldr::TrafficSpeed* live_speed, uint64_t speed, uint8_t subsegment) { |
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.
Any chance subsegment
argument can be renamed to breakpoint1
just to decrease number of terms describing the same thing?
Also, you're not setting the speed of the first subsegment here even though you do set the breakpoint1, is that intended? You may want to set speed1
to either unknown or 0 (or something else) for clarity
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.
Any chance
subsegment
argument can be renamed tobreakpoint1
just to decrease number of terms describing the same thing?
Yeah, I can change subsegment
to breakpoint1
(this was just me trying to reverse engg the TrafficSpeed
struct and trying to make sense of what breakpoint meant 😛 ).
Also, you're not setting the speed of the first subsegment here even though you do set the breakpoint1, is that intended? You may want to set
speed1
to either unknown or 0 (or something else) for clarity
So this function intends to set live speed to 0
starting from a particular subsegment/breakpoint of the edge. Anything before that should remain whatever value it previously had. TBH I arrived at the vlaues being set after a few iterations. Let me know if there's a better/correct/simpler way to do it. I want to partially close edges upto/from a certain percentage of the edge.
live_speed->speed3 = UNKNOWN_TRAFFIC_SPEED_RAW; | ||
} | ||
|
||
inline void SetLiveSpeedUpto(baldr::TrafficSpeed* live_speed, uint64_t speed, uint8_t subsegment) { |
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.
same note about name here
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.
The speed datatype should probably be uint8_t too
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.
How about overall_speed
?
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.
SetLiveSpeed
below can probably be collapsed into this function if you set subsegment/breakpoint1
argument to default to 255?
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'm not sure what overall_speed
should be set to if its already populated (I do that when constructing the gurka map in the setup function) and we want to close only part of the edge. Thats why I left it as is, and also why I have a separate function for setting speed for the entire edge as it sets the overall_speed
too.
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.
The most important is probably to set overall_speed
to 0 if any of the subsegments have zero speed. That marks the edge as closed if a subsegment is closed. Apart from that, it's not used if you have any unknown subsegment.
} | ||
} | ||
|
||
void close_partial_dir_edge_upto(baldr::GraphReader& reader, |
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.
Just an FYI:
There are some utility functions already for customizing live traffic like test::customize_live_traffic_data(map.config, cb_setter_max);
as used in https://github.com/valhalla/valhalla/blob/master/test/gurka/test_traffic.cc#L56
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.
Ohh I see that you are in fact using that below.
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.
yup 🙂
I added these functions here since I wanted partial closures. If this is reused elsewhere in the future, we could move it to the gurka module itself.
@@ -0,0 +1,327 @@ | |||
#include "gurka.h" |
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.
Could we apply more compiler warnings to this file at https://github.com/valhalla/valhalla/blob/master/test/gurka/CMakeLists.txt#L14 ?
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.
totally! will add it
a1846b1
to
daef98d
Compare
Adds a new shape attribute filter for getting closure locations in the directions response. Similar to incidents, each closure annotation has a start & end geometry index, which indexes into the coordinates list.
47bd9ec
to
845223e
Compare
Adds a new shape attribute filter for getting closure locations in the
directions response. Similar to incidents, each closure annotation has
a start & end geometry index, which indexes into the coordinates list.