From 57e347a813577c285380946614603f5d5a3ab373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sat, 2 Nov 2024 14:33:09 +0100 Subject: [PATCH 1/5] update osr: no level propagation --- .pkg | 2 +- .pkg.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pkg b/.pkg index 031079622..0cfec6448 100644 --- a/.pkg +++ b/.pkg @@ -9,7 +9,7 @@ [osr] url=git@github.com:motis-project/osr.git branch=master - commit=03de6b4553e6d76b44a26b477dcd9343333f4f25 + commit=0bcf6cec26b3a11f1ffb0f7f5fae95b5bec9ae78 [utl] url=git@github.com:motis-project/utl.git branch=master diff --git a/.pkg.lock b/.pkg.lock index 2ca2bed0a..3d4fe2481 100644 --- a/.pkg.lock +++ b/.pkg.lock @@ -1,4 +1,4 @@ -747451078969031840 +15192418704236001364 cista 5b6808fd7d7a7c1c7e4cb152b563dbf71e3efba4 zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3 boost 73549ebca677fe6214202a1ab580362b4f80e653 @@ -39,7 +39,7 @@ sol2 40c7cbc7c5cfed1e8c7f1bbe6fcbe23d7a67fc75 variant 5aa73631dc969087c77433a5cdef246303051f69 tiles 6b6dc45bc904966640c7207ab91950848a8b3f6c rtree.c 6ed73a7dc4f1184f2b5b2acd8ac1c2b28a273057 -osr 03de6b4553e6d76b44a26b477dcd9343333f4f25 +osr 0bcf6cec26b3a11f1ffb0f7f5fae95b5bec9ae78 yaml-cpp 1d8ca1f35eb3a9c9142462b28282a848e5d29a91 reflect-cpp c54fe66de4650b60c23aadd4a06d9db4ffeda22f FTXUI dd6a5d371fd7a3e2937bb579955003c54b727233 From 4603b4b465d3aba37de39d147017f432cf4b3c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sat, 2 Nov 2024 21:42:30 +0100 Subject: [PATCH 2/5] wip --- .pkg | 2 +- .pkg.lock | 4 ++-- include/motis/get_loc.h | 2 +- src/endpoints/footpaths.cc | 2 +- src/endpoints/graph.cc | 9 ++++++--- src/endpoints/levels.cc | 4 ++-- src/endpoints/matches.cc | 29 +++++++++++++++-------------- src/endpoints/osr_routing.cc | 4 ++-- src/endpoints/platforms.cc | 2 +- src/match_platforms.cc | 2 +- src/parse_location.cc | 2 +- src/place.cc | 6 +++--- src/street_routing.cc | 2 ++ test/read_test.cc | 4 ++-- 14 files changed, 40 insertions(+), 34 deletions(-) diff --git a/.pkg b/.pkg index 0cfec6448..5c3e8ffa1 100644 --- a/.pkg +++ b/.pkg @@ -9,7 +9,7 @@ [osr] url=git@github.com:motis-project/osr.git branch=master - commit=0bcf6cec26b3a11f1ffb0f7f5fae95b5bec9ae78 + commit=02c6782ecb882a8beab6396608c6a5a279db3cbc [utl] url=git@github.com:motis-project/utl.git branch=master diff --git a/.pkg.lock b/.pkg.lock index 3d4fe2481..cfe6cb2b4 100644 --- a/.pkg.lock +++ b/.pkg.lock @@ -1,4 +1,4 @@ -15192418704236001364 +6189593023066036854 cista 5b6808fd7d7a7c1c7e4cb152b563dbf71e3efba4 zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3 boost 73549ebca677fe6214202a1ab580362b4f80e653 @@ -39,7 +39,7 @@ sol2 40c7cbc7c5cfed1e8c7f1bbe6fcbe23d7a67fc75 variant 5aa73631dc969087c77433a5cdef246303051f69 tiles 6b6dc45bc904966640c7207ab91950848a8b3f6c rtree.c 6ed73a7dc4f1184f2b5b2acd8ac1c2b28a273057 -osr 0bcf6cec26b3a11f1ffb0f7f5fae95b5bec9ae78 +osr 02c6782ecb882a8beab6396608c6a5a279db3cbc yaml-cpp 1d8ca1f35eb3a9c9142462b28282a848e5d29a91 reflect-cpp c54fe66de4650b60c23aadd4a06d9db4ffeda22f FTXUI dd6a5d371fd7a3e2937bb579955003c54b727233 diff --git a/include/motis/get_loc.h b/include/motis/get_loc.h index e2cf00d87..80dfe538d 100644 --- a/include/motis/get_loc.h +++ b/include/motis/get_loc.h @@ -25,7 +25,7 @@ inline osr::location get_loc( } } auto const lvl = matches[l] == osr::platform_idx_t::invalid() - ? osr::to_level(0.0F) + ? osr::level_t{0.F} : pl.get_level(w, matches[l]); return {pos, lvl}; } diff --git a/src/endpoints/footpaths.cc b/src/endpoints/footpaths.cc index 03bb6b595..d25d0147d 100644 --- a/src/endpoints/footpaths.cc +++ b/src/endpoints/footpaths.cc @@ -74,7 +74,7 @@ api::footpaths_response footpaths::operator()( .stopId_ = std::string{l.id_}, .lat_ = l.pos_.lat(), .lon_ = l.pos_.lng(), - .level_ = osr::to_float(pl_.get_level(w_, matches_[l.l_])), + .level_ = pl_.get_level(w_, matches_[l.l_]).to_float(), .vertexType_ = api::VertexTypeEnum::NORMAL}; }; diff --git a/src/endpoints/graph.cc b/src/endpoints/graph.cc index a3ce3a79a..c742b6244 100644 --- a/src/endpoints/graph.cc +++ b/src/endpoints/graph.cc @@ -16,7 +16,7 @@ json::value graph::operator()(json::value const& query) const { auto const min = geo::latlng{x[1].as_double(), x[0].as_double()}; auto const max = geo::latlng{x[3].as_double(), x[2].as_double()}; auto const level = q.contains("level") - ? osr::to_level(q.at("level").to_number()) + ? osr::level_t{q.at("level").to_number()} : osr::kNoLevel; auto gj = osr::geojson_writer{.w_ = w_}; @@ -39,7 +39,10 @@ json::value graph::operator()(json::value const& query) const { auto has_level = false; utl::for_each_set_bit( osr::foot::get_elevator_multi_levels(*w_.r_, n), - [&](auto&& bit) { has_level |= (level == osr::level_t{bit}); }); + [&](auto&& bit) { + has_level |= + (level == osr::level_t{static_cast(bit)}); + }); if (has_level) { gj.write_way(w); return; @@ -47,7 +50,7 @@ json::value graph::operator()(json::value const& query) const { } } - if ((level == osr::to_level(0.0) && + if ((level == osr::level_t{0.F} && way_prop.from_level() == osr::kNoLevel) || way_prop.from_level() == level || way_prop.to_level() == level) { gj.write_way(w); diff --git a/src/endpoints/levels.cc b/src/endpoints/levels.cc index a446e7974..6ccd2a256 100644 --- a/src/endpoints/levels.cc +++ b/src/endpoints/levels.cc @@ -23,8 +23,8 @@ api::levels_response levels::operator()( auto levels = hash_set{}; l_.find({min->pos_, max->pos_}, [&](osr::way_idx_t const x) { auto const p = w_.r_->way_properties_[x]; - levels.emplace(to_float(p.from_level())); - levels.emplace(to_float(p.to_level())); + levels.emplace(p.from_level().to_float()); + levels.emplace(p.to_level().to_float()); }); auto levels_sorted = utl::to_vec(levels, [](float const l) { return static_cast(l); }); diff --git a/src/endpoints/matches.cc b/src/endpoints/matches.cc index 044d23629..e6afbf767 100644 --- a/src/endpoints/matches.cc +++ b/src/endpoints/matches.cc @@ -36,7 +36,7 @@ json::value matches::operator()(json::value const& query) const { {"type", "Feature"}, {"properties", {{"type", "platform"}, - {"level", to_float(pl_.get_level(w_, p))}, + {"level", pl_.get_level(w_, p).to_float()}, {"platform_names", fmt::format("{}", get_names(pl_, p))}}}, {"geometry", osr::to_point(osr::point::from_latlng(*center))}}); }); @@ -54,19 +54,20 @@ json::value matches::operator()(json::value const& query) const { if (match == osr::platform_idx_t::invalid()) { props.emplace("level", "-"); } else { - std::visit( - utl::overloaded{ - [&](osr::way_idx_t x) { - props.emplace("osm_way_id", to_idx(w_.way_osm_idx_[x])); - props.emplace("level", - to_float(w_.r_->way_properties_[x].from_level())); - }, - [&](osr::node_idx_t x) { - props.emplace("osm_node_id", to_idx(w_.node_to_osm_[x])); - props.emplace( - "level", to_float(w_.r_->node_properties_[x].from_level())); - }}, - osr::to_ref(pl_.platform_ref_[match][0])); + std::visit(utl::overloaded{ + [&](osr::way_idx_t x) { + props.emplace("osm_way_id", to_idx(w_.way_osm_idx_[x])); + props.emplace( + "level", + w_.r_->way_properties_[x].from_level().to_float()); + }, + [&](osr::node_idx_t x) { + props.emplace("osm_node_id", to_idx(w_.node_to_osm_[x])); + props.emplace( + "level", + w_.r_->node_properties_[x].from_level().to_float()); + }}, + osr::to_ref(pl_.platform_ref_[match][0])); } matches.emplace_back( json::value{{"type", "Feature"}, diff --git a/src/endpoints/osr_routing.cc b/src/endpoints/osr_routing.cc index 0048ca9f4..3f4ca487f 100644 --- a/src/endpoints/osr_routing.cc +++ b/src/endpoints/osr_routing.cc @@ -15,7 +15,7 @@ osr::location parse_location(json::value const& v) { auto const& obj = v.as_object(); return {{obj.at("lat").as_double(), obj.at("lng").as_double()}, obj.contains("level") - ? osr::to_level(obj.at("level").to_number()) + ? osr::level_t{obj.at("level").to_number()} : osr::kNoLevel}; } @@ -54,7 +54,7 @@ json::value osr_routing::operator()(json::value const& query) const { return json::value{ {"type", "Feature"}, {"properties", - {{"level", to_float(s.from_level_)}, + {{"level", s.from_level_.to_float()}, {"way", s.way_ == osr::way_idx_t::invalid() ? 0U diff --git a/src/endpoints/platforms.cc b/src/endpoints/platforms.cc index 10fb0fa70..7a7b18cd7 100644 --- a/src/endpoints/platforms.cc +++ b/src/endpoints/platforms.cc @@ -9,7 +9,7 @@ namespace motis::ep { json::value platforms::operator()(json::value const& query) const { auto const& q = query.as_object(); auto const level = q.contains("level") - ? osr::to_level(query.at("level").to_number()) + ? osr::level_t{query.at("level").to_number()} : osr::kNoLevel; auto const waypoints = q.at("waypoints").as_array(); auto const min = osr::point::from_latlng( diff --git a/src/match_platforms.cc b/src/match_platforms.cc index 5421e62e7..17ca12a14 100644 --- a/src/match_platforms.cc +++ b/src/match_platforms.cc @@ -213,7 +213,7 @@ osr::platform_idx_t get_match(n::timetable const& tt, tt.locations_.names_[l].view()); auto const lvl = pl.get_level(w, x); auto const lvl_bonus = - lvl != osr::kNoLevel && osr::to_float(lvl) != 0.0F ? 5 : 0; + lvl != osr::kNoLevel && lvl.to_float() != 0.0F ? 5 : 0; auto const way_bonus = osr::is_way(pl.platform_ref_[x].front()) ? 20 : 0; auto const routes_bonus = get_routes_bonus(tt, l, pl.platform_names_[x]); auto const score = diff --git a/src/parse_location.cc b/src/parse_location.cc index 05fd7daa7..120c5461d 100644 --- a/src/parse_location.cc +++ b/src/parse_location.cc @@ -39,7 +39,7 @@ std::optional parse_location(std::string_view s, return std::nullopt; } - return osr::location{pos, osr::to_level(level)}; + return osr::location{pos, osr::level_t{level}}; } n::unixtime_t get_date_time(std::optional const& date, diff --git a/src/place.cc b/src/place.cc index 8bde47531..3ed1f1685 100644 --- a/src/place.cc +++ b/src/place.cc @@ -26,7 +26,7 @@ api::Place to_place(osr::location const l, std::string_view name) { .name_ = std::string{name}, .lat_ = l.pos_.lat_, .lon_ = l.pos_.lng_, - .level_ = to_float(l.lvl_), + .level_ = l.lvl_.to_float(), .vertexType_ = api::VertexTypeEnum::NORMAL, }; } @@ -42,11 +42,11 @@ double get_level(osr::ways const* w, osr::platforms const* pl, platform_matches_t const* matches, n::location_idx_t const l) { - return to_float(get_lvl(w, pl, matches, l)); + return get_lvl(w, pl, matches, l).to_float(); } osr::location get_location(api::Place const& p) { - return {{p.lat_, p.lon_}, osr::to_level(static_cast(p.level_))}; + return {{p.lat_, p.lon_}, osr::level_t{static_cast(p.level_)}}; } osr::location get_location(n::timetable const* tt, diff --git a/src/street_routing.cc b/src/street_routing.cc index a5a1b50a1..eddbc8859 100644 --- a/src/street_routing.cc +++ b/src/street_routing.cc @@ -205,6 +205,8 @@ api::Itinerary route(osr::ways const& w, return {}; } + std::cout << "ROUTING\n FROM: " << from << " \n TO: " << to + << "\n -> CREATING DUMMY LEG\n"; auto itinerary = api::Itinerary{ .duration_ = std::chrono::duration_cast( *end_time - start_time) diff --git a/test/read_test.cc b/test/read_test.cc index dc7d92138..7333a7d73 100644 --- a/test/read_test.cc +++ b/test/read_test.cc @@ -11,13 +11,13 @@ using namespace std::chrono_literals; TEST(motis, parse_location_with_level) { auto const parsed = parse_location("-123.1,44.2,-1.5"); ASSERT_TRUE(parsed.has_value()); - EXPECT_EQ((osr::location{{-123.1, 44.2}, osr::to_level(-1.5F)}), *parsed); + EXPECT_EQ((osr::location{{-123.1, 44.2}, osr::level_t{-1.5F}}), *parsed); } TEST(motis, parse_location_no_level) { auto const parsed = parse_location("-23.1,45.2"); ASSERT_TRUE(parsed.has_value()); - EXPECT_EQ((osr::location{{-23.1, 45.2}, osr::to_level(0.F)}), *parsed); + EXPECT_EQ((osr::location{{-23.1, 45.2}, osr::level_t{0.F}}), *parsed); } TEST(motis, parse_date_time) { From 740c95f57924a62b1d822fc4004fbd4155ac30d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sat, 2 Nov 2024 21:43:42 +0100 Subject: [PATCH 3/5] wip --- src/street_routing.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/street_routing.cc b/src/street_routing.cc index eddbc8859..f057826b3 100644 --- a/src/street_routing.cc +++ b/src/street_routing.cc @@ -65,8 +65,8 @@ std::vector get_step_instructions( .relativeDirection_ = api::RelativeDirectionEnum::CONTINUE, // TODO .absoluteDirection_ = api::AbsoluteDirectionEnum::NORTH, // TODO .distance_ = static_cast(s.dist_), - .fromLevel_ = to_float(s.from_level_), - .toLevel_ = to_float(s.to_level_), + .fromLevel_ = s.from_level_.to_float(), + .toLevel_ = s.to_level_.to_float(), .osmWay_ = s.way_ == osr::way_idx_t ::invalid() ? std::nullopt : std::optional{static_cast( From 224c0d3fb2b77a2755e904363999a12a79b897a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sat, 2 Nov 2024 21:52:03 +0100 Subject: [PATCH 4/5] wip --- test/routing_test.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/routing_test.cc b/test/routing_test.cc index 60261a6dc..5997be37b 100644 --- a/test/routing_test.cc +++ b/test/routing_test.cc @@ -362,12 +362,12 @@ TEST(motis, routing) { } EXPECT_EQ( - R"(date=2019-05-01, start=01:29, end=02:29, duration=01:04, transfers=1, legs=[ + R"(date=2019-05-01, start=01:29, end=02:28, duration=01:03, transfers=1, legs=[ (from=- [track=-, scheduled_track=-, level=0], to=test_DA_10 [track=10, scheduled_track=10, level=-1], start=2019-05-01 01:29, mode="WALK", trip="-", end=2019-05-01 01:35), (from=test_DA_10 [track=10, scheduled_track=10, level=-1], to=test_FFM_12 [track=12, scheduled_track=10, level=0], start=2019-05-01 01:35, mode="HIGHSPEED_RAIL", trip="ICE ", end=2019-05-01 01:55), (from=test_FFM_12 [track=12, scheduled_track=10, level=0], to=test_FFM_101 [track=101, scheduled_track=101, level=-3], start=2019-05-01 01:55, mode="WALK", trip="-", end=2019-05-01 02:01), (from=test_FFM_101 [track=101, scheduled_track=101, level=-3], to=test_FFM_HAUPT_S [track=-, scheduled_track=-, level=-3], start=2019-05-01 02:15, mode="METRO", trip="S3", end=2019-05-01 02:20), - (from=test_FFM_HAUPT_S [track=-, scheduled_track=-, level=-3], to=- [track=-, scheduled_track=-, level=0], start=2019-05-01 02:20, mode="WALK", trip="-", end=2019-05-01 02:29) + (from=test_FFM_HAUPT_S [track=-, scheduled_track=-, level=-3], to=- [track=-, scheduled_track=-, level=0], start=2019-05-01 02:20, mode="WALK", trip="-", end=2019-05-01 02:28) ])", ss.str()); } @@ -387,7 +387,7 @@ TEST(motis, routing) { EXPECT_EQ( R"(date=2019-05-01, start=01:25, end=02:14, duration=00:49, transfers=1, legs=[ - (from=- [track=-, scheduled_track=-, level=0], to=test_DA_10 [track=10, scheduled_track=10, level=-1], start=2019-05-01 01:25, mode="WALK", trip="-", end=2019-05-01 01:28), + (from=- [track=-, scheduled_track=-, level=0], to=test_DA_10 [track=10, scheduled_track=10, level=-1], start=2019-05-01 01:25, mode="WALK", trip="-", end=2019-05-01 01:30), (from=test_DA_10 [track=10, scheduled_track=10, level=-1], to=test_FFM_12 [track=12, scheduled_track=10, level=0], start=2019-05-01 01:35, mode="HIGHSPEED_RAIL", trip="ICE ", end=2019-05-01 01:55), (from=test_FFM_12 [track=12, scheduled_track=10, level=0], to=test_de:6412:10:6:1 [track=U4, scheduled_track=U4, level=-2], start=2019-05-01 01:55, mode="WALK", trip="-", end=2019-05-01 01:59), (from=test_de:6412:10:6:1 [track=U4, scheduled_track=U4, level=-2], to=test_FFM_HAUPT_U [track=-, scheduled_track=-, level=-4], start=2019-05-01 02:05, mode="SUBWAY", trip="U4", end=2019-05-01 02:10), From 2a6a5536e1f6d7f8c0a096bdf20ed8428ec02586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20G=C3=BCndling?= Date: Sat, 2 Nov 2024 22:02:51 +0100 Subject: [PATCH 5/5] wip --- include/motis/hashes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/motis/hashes.h b/include/motis/hashes.h index 56b24963c..3d8bb4b49 100644 --- a/include/motis/hashes.h +++ b/include/motis/hashes.h @@ -11,7 +11,7 @@ using meta_entry_t = std::pair; using meta_t = std::map; constexpr auto const osr_version = []() { - return meta_entry_t{"osr_bin_ver", 4U}; + return meta_entry_t{"osr_bin_ver", 5U}; }; constexpr auto const adr_version = []() { return meta_entry_t{"adr_bin_ver", 1U};