Skip to content

Commit

Permalink
Update to osr with elevation profile support (#746)
Browse files Browse the repository at this point in the history
* Update to osr with elevation profile support

* Remove repeated fallthrough attributes
  • Loading branch information
MichaelKutzner authored Feb 17, 2025
1 parent 2167a3b commit 8fa459b
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[osr]
[email protected]:motis-project/osr.git
branch=master
commit=02c4efb5749086fc74fc736b2d092fdd77829b86
commit=48b0f599173cd821004ff11bab2b78ec9ce47909
[utl]
[email protected]:motis-project/utl.git
branch=master
Expand Down
4 changes: 2 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
7522270935463922722
963138316830836792
cista e03a1ff0a84d3f638bf4bff7357d19e542640288
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 4a9aca6cb8af75be6e58f28c09cc7e39f61e6173
Expand Down Expand Up @@ -44,7 +44,7 @@ sol2 40c7cbc7c5cfed1e8c7f1bbe6fcbe23d7a67fc75
variant 5aa73631dc969087c77433a5cdef246303051f69
tiles ab6c4b13544570f893c2d64434c613d8fd7d2ceb
rtree.c 6ed73a7dc4f1184f2b5b2acd8ac1c2b28a273057
osr 02c4efb5749086fc74fc736b2d092fdd77829b86
osr 48b0f599173cd821004ff11bab2b78ec9ce47909
reflect-cpp c54fe66de4650b60c23aadd4a06d9db4ffeda22f
FTXUI dd6a5d371fd7a3e2937bb579955003c54b727233
tg 20c0f298b8ce58de29a790290f44dca7c4ecc364
Expand Down
2 changes: 2 additions & 0 deletions include/motis/compute_footpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "cista/memory_holder.h"

#include "osr/elevation_storage.h"
#include "osr/types.h"

#include "motis/fwd.h"
Expand All @@ -17,6 +18,7 @@ elevator_footpath_map_t compute_footpaths(osr::ways const&,
osr::lookup const&,
osr::platforms const&,
nigiri::timetable&,
osr::elevation_storage const*,
bool update_coordinates,
bool extend_missing,
std::chrono::seconds max_duration,
Expand Down
4 changes: 3 additions & 1 deletion include/motis/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "nigiri/types.h"

#include "osr/elevation_storage.h"
#include "osr/types.h"

#include "motis/compute_footpaths.h"
Expand Down Expand Up @@ -64,7 +65,7 @@ struct data {

auto cista_members() {
// !!! Remember to add all new members !!!
return std::tie(config_, t_, r_, tc_, w_, pl_, l_, tt_, tags_,
return std::tie(config_, t_, r_, tc_, w_, pl_, l_, elevations_, tt_, tags_,
location_rtee_, elevator_nodes_, shapes_, railviz_static_,
matches_, rt_, gbfs_);
}
Expand All @@ -78,6 +79,7 @@ struct data {
ptr<osr::ways> w_;
ptr<osr::platforms> pl_;
ptr<osr::lookup> l_;
ptr<osr::elevation_storage> elevations_;
cista::wrapped<nigiri::timetable> tt_;
cista::wrapped<tag_lookup> tags_;
ptr<point_rtree<nigiri::location_idx_t>> location_rtee_;
Expand Down
2 changes: 2 additions & 0 deletions include/motis/endpoints/footpaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "nigiri/types.h"

#include "osr/elevation_storage.h"
#include "osr/types.h"

#include "motis-api/motis-api.h"
Expand All @@ -22,6 +23,7 @@ struct footpaths {
osr::ways const& w_;
osr::lookup const& l_;
osr::platforms const& pl_;
osr::elevation_storage const* elevations_;
point_rtree<nigiri::location_idx_t> const& loc_rtree_;
platform_matches_t const& matches_;
std::shared_ptr<rt> rt_;
Expand Down
3 changes: 2 additions & 1 deletion src/compute_footpaths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ elevator_footpath_map_t compute_footpaths(
osr::lookup const& lookup,
osr::platforms const& pl,
nigiri::timetable& tt,
osr::elevation_storage const* elevations,
bool const update_coordinates,
bool const extend_missing,
std::chrono::seconds const max_duration,
Expand Down Expand Up @@ -145,7 +146,7 @@ elevator_footpath_map_t compute_footpaths(
utl::transform_to(s.neighbors_, s.neighbor_candidates_,
[&](auto&& x) { return candidates[x]; }),
kMaxDuration, osr::direction::kForward, nullptr, nullptr,
[](osr::path const& p) { return p.uses_elevator_; });
elevations, [](osr::path const& p) { return p.uses_elevator_; });
for (auto const [n, r] : utl::zip(s.neighbors_, results)) {
if (r.has_value()) {
auto const duration = n::duration_t{r->cost_ / 60U};
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/footpaths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ api::footpaths_response footpaths::operator()(
neighbors,
[&](auto&& l) { return get_loc(tt_, w_, pl_, matches_, l); }),
kMaxDuration, osr::direction::kForward, kMaxMatchingDistance,
e == nullptr ? nullptr : &e->blocked_, nullptr,
e == nullptr ? nullptr : &e->blocked_, nullptr, elevations_,
[](osr::path const& p) { return p.uses_elevator_; });

for (auto const [n, r] : utl::zip(neighbors, results)) {
Expand Down
5 changes: 3 additions & 2 deletions src/import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ data import(config const& c, fs::path const& data_path, bool const write) {
[&]() { return c.street_routing_; },
[&]() { return true; },
[&]() {
osr::extract(true, fs::path{*c.osm_}, data_path / "osr");
osr::extract(true, fs::path{*c.osm_}, data_path / "osr",
fs::path{});
d.load_osr();
},
[&]() { d.load_osr(); },
Expand Down Expand Up @@ -371,7 +372,7 @@ data import(config const& c, fs::path const& data_path, bool const write) {
[&]() { return d.tt_ && d.tags_ && d.w_ && d.l_ && d.pl_; },
[&]() {
auto const elevator_footpath_map = compute_footpaths(
*d.w_, *d.l_, *d.pl_, *d.tt_,
*d.w_, *d.l_, *d.pl_, *d.tt_, d.elevations_.get(),
c.timetable_->use_osm_stop_coordinates_,
c.timetable_->extend_missing_footpaths_,
std::chrono::seconds{c.timetable_->max_footpath_length_ * 60U},
Expand Down
2 changes: 2 additions & 0 deletions src/journey_to_response.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ api::ModeEnum to_mode(osr::search_profile const m) {
case osr::search_profile::kFoot: [[fallthrough]];
case osr::search_profile::kWheelchair: return api::ModeEnum::WALK;
case osr::search_profile::kCar: return api::ModeEnum::CAR;
case osr::search_profile::kBikeElevationLow:
case osr::search_profile::kBikeElevationHigh: [[fallthrough]];
case osr::search_profile::kBike: return api::ModeEnum::BIKE;
case osr::search_profile::kBikeSharing: return api::ModeEnum::RENTAL;
}
Expand Down
2 changes: 2 additions & 0 deletions src/max_distance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ double get_max_distance(osr::search_profile const profile,
case osr::search_profile::kWheelchair: return seconds * 0.8;
case osr::search_profile::kFoot: return seconds * 1.1;
case osr::search_profile::kBikeSharing:
case osr::search_profile::kBikeElevationLow:
case osr::search_profile::kBikeElevationHigh: [[fallthrough]];
case osr::search_profile::kBike: return seconds * 4.0;
case osr::search_profile::kCar:
case osr::search_profile::kCarParking: [[fallthrough]];
Expand Down

0 comments on commit 8fa459b

Please sign in to comment.