Repository navigation
feat: partial gurka tile build - #6136
Conversation
| --if num > 150kph or num < 10kph....toss | ||
| if num > 150 or num < 10 then | ||
| --toss unusably low speeds and values at/above the "unlimited" sentinel (255) | ||
| if num < 10 or num >= 255 then |
There was a problem hiding this comment.
we can't allow 255, that's signal "unlimited" in c++.
There was a problem hiding this comment.
btw. MAX_TRAFFIC_SPEED_KPH is 252
constexpr uint32_t UNKNOWN_TRAFFIC_SPEED_RAW = (1 << 7) - 1;
constexpr uint32_t MAX_TRAFFIC_SPEED_KPH = (UNKNOWN_TRAFFIC_SPEED_RAW - 1) << 1;There was a problem hiding this comment.
which is only interesting for live traffic but not max_speed right? we cap it at 140 before it enters tiles.
There was a problem hiding this comment.
also, I think that change doesn't makes much sense because speeds are capped by kMaxOSMSpeed in
valhalla/src/mjolnir/osmway.cc
Lines 66 to 88 in 9bc6bac
There was a problem hiding this comment.
my point is that this PR adds one more magic number around max speed and this time it's 254
There was a problem hiding this comment.
ah thanks, didn't see that set_speed.. brings me to my point: our current speeds handling is ridiculously distributed among the codebase. needs a cleanup really
There was a problem hiding this comment.
indeed this change is then redundant
| {{"mjolnir.concurrency", "1"}}, mjolnir::BuildStage::kInitialize, | ||
| mjolnir::BuildStage::kParseWays); | ||
|
|
||
| auto way = gurka::findWay(map, 100); |
There was a problem hiding this comment.
it would probably be simpler to search ways by name so each test could be enhanced with additional checks without changing too much like this
auto way = gurka::findWay(map, "BC");There was a problem hiding this comment.
yep, sounds like a good overload:)
There was a problem hiding this comment.
oh, and it is simpler in this scenario, so I'll change to use that pattern instead of manual osm_ids
| end | ||
|
|
||
| --if num > 150kph or num < 10kph....toss | ||
| if num > 150 or num < 10 then |
There was a problem hiding this comment.
ok this is a behavioral change hidden in here i guess. previously we would throw away anything this high but now it becomes 140 on the c++ side?
There was a problem hiding this comment.
ah right, that's correct. although "hidden" is not correct! it's clearly written in the PR description!
| @@ -0,0 +1,107 @@ | |||
| #include "baldr/graphconstants.h" | |||
There was a problem hiding this comment.
damn there wasnt an existing test we could have squeezed this into? the number of targets is... too long already imho
There was a problem hiding this comment.
I know, but my karma this week would be net-0. I did (or do?) remove a gurka test file in some other PR and a much heavier one.
There was a problem hiding this comment.
I'd be happy to really really dumb those gurka tests down to a (larger) handful very soon. it's hard to make those test files truly sensible! but we can definitely decrease the count by at least 75%!
| EXPECT_EQ(clamped.speed(), 140); | ||
|
|
||
| auto clamped_high = gurka::findWay(map, "CD"); | ||
| EXPECT_EQ(clamped_high.speed_limit(), 140); |
There was a problem hiding this comment.
ok so confirmed behavioral change, >150 now becomes 140, where it used to be 0, right?
There was a problem hiding this comment.
hm, IIRC (hahah, it's really old!), > 150 we simply tossed before. so not even 0. no edge at all.
| template <typename Pred> | ||
| mjolnir::OSMWay find_way(const map& map, const std::string& what, Pred pred) { | ||
| auto tile_dir = map.config.get<std::string>("mjolnir.tile_dir"); | ||
| // linear scan as the file's sort order is not guaranteed, it's tiny in tests anyway | ||
| midgard::sequence<mjolnir::OSMWay> ways(tile_dir + "/ways.bin"); | ||
| for (const auto& way : ways) { | ||
| if (pred(way)) | ||
| return way; | ||
| } | ||
| throw std::runtime_error("Could not find way " + what); | ||
| } | ||
|
|
||
| template <typename Pred> std::vector<mjolnir::OSMWayNode> find_way_nodes(const map& map, Pred pred) { | ||
| auto tile_dir = map.config.get<std::string>("mjolnir.tile_dir"); | ||
| // linear scan as the file's sort order changes between build stages | ||
| midgard::sequence<mjolnir::OSMWayNode> way_nodes(tile_dir + "/way_nodes.bin"); | ||
| std::vector<mjolnir::OSMWayNode> found; | ||
| for (const auto& way_node : way_nodes) { | ||
| if (pred(way_node)) | ||
| found.push_back(way_node); | ||
| } | ||
| return found; | ||
| } |
There was a problem hiding this comment.
nit: whats the significance of having these up here in the detail namespace with functors to do the matching? why not just put this down in the implementation? are there future uses we have planned with different predicates? seems like needless complication/indirection unless we have more uses planned or maybe a gut feeling that more use cases are around the corner
There was a problem hiding this comment.
@kinkard (rightfully IMO) requested that we have overloads for either identifying osm ways by numerical ID or string name. hence the templated versions where you can pick the predicate to be what you want it to be (though I guess this'll be it). in the current tests I only use the "string overload", but I assume that numerical OSM ID lookup might become useful in the future.
the numerical one is the one what I started with. then @kinkard requested the string overload. which fit that particular test use case way better. @kevinkreiser if you want me to remove the numerical overload now, no problem. it's more for the future.
There was a problem hiding this comment.
just to be clear: the numerical one is implemented/specialized, just not used yet in tests.
kevinkreiser
left a comment
There was a problem hiding this comment.
some nits but looks good!
closes #6135
first changes I tried with the new claude fable model. it's much better, but one thing I realized: it's trying a lot harder to emulate "my/our style", e.g. inline comments don't start with capital letter, both great and eery. the gurka tests I asked it to do were right on point!
adds:
gurka::findWay: readsways.binand finds a way by OSM IDgurka::findWayNodes: readsway_nodes.binand finds a vector ofway_nodesmatching the input node's OSM IDfixes:
maxspeed>= 150 entirely, instead of letting c++ clamp it to 140