Skip to content
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 bike elevation profiles #26

Draft
wants to merge 128 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
e3894ab
make bike faster
felixguendling Nov 26, 2024
2daa78c
Merge branch 'master' of github.com:motis-project/osr
felixguendling Nov 26, 2024
82171e5
WIP: Copy parser for BIL files from ppr
MichaelKutzner Nov 27, 2024
31caebe
Add example test query
MichaelKutzner Nov 27, 2024
cb0dfe6
Replace magic numbers
MichaelKutzner Nov 27, 2024
3c15f22
Prepare data structure for elevation data
MichaelKutzner Nov 27, 2024
478bed2
Merge branch 'master' of github.com:motis-project/osr
felixguendling Nov 28, 2024
f9fa329
Create test BIL data
MichaelKutzner Dec 2, 2024
329a44e
Fix error when loading BIL data
MichaelKutzner Dec 2, 2024
797230e
return lookup timing
felixguendling Dec 2, 2024
cb118f0
Fix test data
MichaelKutzner Dec 3, 2024
dc81f8b
Fix not loaded BIL data
MichaelKutzner Dec 3, 2024
9d42846
Accumulate elevation data
MichaelKutzner Dec 3, 2024
ff16508
Add elevation data to paths
MichaelKutzner Dec 3, 2024
7d81ecd
Cleanup some development code
MichaelKutzner Dec 3, 2024
e39e928
Make test elevation data more readable
MichaelKutzner Dec 3, 2024
29e4f1d
WIP: Add bike profile for elevations
MichaelKutzner Dec 4, 2024
9f01817
Simplify elevation cost calculation
MichaelKutzner Dec 4, 2024
c3a0169
Remove static member function
MichaelKutzner Dec 4, 2024
c683de3
Remove unused code
MichaelKutzner Dec 4, 2024
c983938
Enable elevation profile
MichaelKutzner Dec 4, 2024
9625dc5
Simplify elevation cost calculation
MichaelKutzner Dec 4, 2024
94e699f
Prepare progress bar updates
MichaelKutzner Dec 4, 2024
83edfdc
Parallelize way elevation calculation
MichaelKutzner Dec 4, 2024
9c17bb3
Move code for elevation calculation
MichaelKutzner Dec 5, 2024
597c769
Remove duplicated code for coordinates
MichaelKutzner Dec 5, 2024
a48239b
Store elevation data in memory mapped files
MichaelKutzner Dec 5, 2024
259f351
Remove no longer required members
MichaelKutzner Dec 5, 2024
35d17cf
Rename sum variable
MichaelKutzner Dec 5, 2024
7e5d715
Rename elevation struct
MichaelKutzner Dec 5, 2024
59ff8ba
Simplify check for existing files
MichaelKutzner Dec 5, 2024
a1a2e5d
Group filenames into namespace
MichaelKutzner Dec 5, 2024
8d68ecc
Merge remote-tracking branch 'origin/master' into altitude_profiles
MichaelKutzner Dec 5, 2024
43224b5
Cleanup code style
MichaelKutzner Dec 5, 2024
2bcba5f
Add bike profile with high elevation costs
MichaelKutzner Dec 5, 2024
2b94cb0
Copy value
MichaelKutzner Dec 5, 2024
736a5b7
Merge elevation costs into bike profile
MichaelKutzner Dec 6, 2024
ec185cf
Simplify segment elevation cost calculation
MichaelKutzner Dec 6, 2024
852c625
Use function composition to load elevations
MichaelKutzner Dec 6, 2024
b207dd3
WIP: Prepare way partitioning for way elevations
MichaelKutzner Dec 6, 2024
cabdf26
raw matches
felixguendling Dec 6, 2024
f2ceb19
Merge branch 'master' of github.com:motis-project/osr
felixguendling Dec 6, 2024
4ac20e1
Add step size to read intermediate elevation values
MichaelKutzner Dec 9, 2024
38259c8
Adjust elevation costs
MichaelKutzner Dec 9, 2024
cc52c51
Use more expressive return type
MichaelKutzner Dec 9, 2024
f12db6a
Update test data
MichaelKutzner Dec 9, 2024
faffac2
Delete dead code
MichaelKutzner Dec 9, 2024
fd29db3
Merge remote-tracking branch 'origin/master' into altitude_profiles
MichaelKutzner Dec 9, 2024
37b84f6
Fix code style
MichaelKutzner Dec 9, 2024
70df3dd
Rename variable
MichaelKutzner Dec 9, 2024
4cf8e7b
Improve code for elevation calculation
MichaelKutzner Dec 9, 2024
ba010d9
Fix possible out of bounds issue
MichaelKutzner Dec 9, 2024
8e03c10
Simplify `get_*()` methods
MichaelKutzner Dec 9, 2024
f45be4a
Fix formatting
MichaelKutzner Dec 9, 2024
033cb3e
Add missing header
MichaelKutzner Dec 9, 2024
1de3df2
Add missing file
MichaelKutzner Dec 9, 2024
f882250
Fix missing call argument
MichaelKutzner Dec 9, 2024
82a7853
Add missing header
MichaelKutzner Dec 9, 2024
fa15dc3
Add missing header
MichaelKutzner Dec 9, 2024
0b797b2
Update function signature
MichaelKutzner Dec 9, 2024
df7349c
WIP: Add support for SRTM HGT format
MichaelKutzner Dec 10, 2024
397cbec
Load data from SRTM HGT files
MichaelKutzner Dec 11, 2024
824cfde
Rename elevation provider
MichaelKutzner Dec 11, 2024
f668f94
WIP: Implement raster to improve import time
MichaelKutzner Dec 12, 2024
0fceb26
Add concept for raster drivers
MichaelKutzner Dec 12, 2024
bbcbb23
Use raster driver for STRM HGT data
MichaelKutzner Dec 12, 2024
97f0432
Remove used std::mutex
MichaelKutzner Dec 12, 2024
97c7339
Remove code for parallel elevation calculation
MichaelKutzner Dec 12, 2024
bd3a00d
Use R-Tree for SRTM HGT data files
MichaelKutzner Dec 13, 2024
5c99cf9
Fix compiler errors when using libc++
MichaelKutzner Dec 16, 2024
f3b21d5
Store elevation difference between two nodes
MichaelKutzner Dec 16, 2024
fb426a2
Store non flat elevations only
MichaelKutzner Dec 16, 2024
2d7190a
Remove useless assertion
MichaelKutzner Dec 17, 2024
1c527eb
Simpilfy code to calculate path elevation
MichaelKutzner Dec 17, 2024
aed7f0d
Remove passed progress tracker
MichaelKutzner Dec 17, 2024
5a0ecb3
WIP: Compress elevation data
MichaelKutzner Dec 17, 2024
2b03981
Fix elevation costs for segments
MichaelKutzner Dec 18, 2024
8eb811a
Update useabel sparse elevation values
MichaelKutzner Dec 18, 2024
42112a8
Rename structs and methods
MichaelKutzner Dec 18, 2024
a19965c
Fix MSVC compile errors
MichaelKutzner Dec 18, 2024
76139b1
Load elevation data for benchmark
MichaelKutzner Dec 18, 2024
d45b258
Make path to elevation data mandatory
MichaelKutzner Dec 18, 2024
4591676
Fix code style
MichaelKutzner Dec 18, 2024
6d844dc
Delete unused code for SRTM HGT driver
MichaelKutzner Dec 18, 2024
b6fcca2
Rename method to count drivers
MichaelKutzner Dec 18, 2024
016e419
Merge up and down elevations into one variable
MichaelKutzner Dec 18, 2024
e81d654
Fix maximum offset value
MichaelKutzner Dec 19, 2024
5985572
Simplify file checks
MichaelKutzner Dec 19, 2024
bc3cbb0
Rename variable
MichaelKutzner Dec 19, 2024
5fbb488
Improve calculation required for short ways
MichaelKutzner Dec 19, 2024
4a7be63
Fix header order
MichaelKutzner Dec 19, 2024
90df5c1
Remove incorrect std::move
MichaelKutzner Dec 19, 2024
2d9c290
Fix step size for mixed HGT tiles
MichaelKutzner Dec 19, 2024
7651a81
Remove unused headers
MichaelKutzner Dec 19, 2024
756bfdc
Remove variable used exactly once
MichaelKutzner Dec 19, 2024
e0150ad
Fix not matching header definition
MichaelKutzner Dec 19, 2024
e70ef4c
Revert unstable commits on 'origin/master'
MichaelKutzner Dec 19, 2024
353063a
Merge remote-tracking branch 'origin/master' into altitude_profiles
MichaelKutzner Dec 20, 2024
1615277
Fix header order
MichaelKutzner Dec 20, 2024
c10af84
Fix error for valid edge case
MichaelKutzner Dec 23, 2024
5395284
Revert "Use R-Tree for SRTM HGT data files"
MichaelKutzner Dec 24, 2024
8f6126b
Simplify offset calculation
MichaelKutzner Dec 24, 2024
c29766f
Fix offset calculation
MichaelKutzner Dec 27, 2024
17283b7
Fix value when no elevation data is available
MichaelKutzner Dec 27, 2024
0fe8c0b
Fix way approximation near longitude 180
MichaelKutzner Dec 27, 2024
64afd87
Reapply "Use R-Tree for SRTM HGT data files"
MichaelKutzner Jan 13, 2025
b685546
Simplify bounding box calculation for tiles
MichaelKutzner Jan 13, 2025
669f903
Fix tile offset calculation
MichaelKutzner Jan 13, 2025
afdb8b3
WIP: Fix route elevation
MichaelKutzner Jan 14, 2025
4feafe8
Cleanup code
MichaelKutzner Jan 14, 2025
e3ed4d2
Fix costs not matching direction
MichaelKutzner Jan 14, 2025
9dfc53b
WIP: Store elevation data to paged vector
MichaelKutzner Jan 14, 2025
d4bc92a
Parallelize way elevation calculation
MichaelKutzner Jan 15, 2025
45668ce
Unify elevation providers
MichaelKutzner Jan 15, 2025
ed14871
Fix variable name
MichaelKutzner Jan 15, 2025
94cef06
Group ways by elevation tiles
MichaelKutzner Jan 15, 2025
16c55a9
Fix compile errors
MichaelKutzner Jan 15, 2025
e1f63eb
Add check for empty ways
MichaelKutzner Jan 15, 2025
9d24a6c
Fix code style
MichaelKutzner Jan 16, 2025
a663ded
Rename hgt tile files
MichaelKutzner Jan 16, 2025
237e4e5
Use defined concepts for std::visit
MichaelKutzner Jan 16, 2025
012a811
Show route elevations for all bike profiles
MichaelKutzner Jan 16, 2025
d29e3de
Fix type for MSVC build
MichaelKutzner Jan 16, 2025
82a6a05
Fix type for MSVC build
MichaelKutzner Jan 16, 2025
a18cbe1
Remove std::mutex used for BIL files
MichaelKutzner Jan 16, 2025
5d83cce
Fix variable names in debug build
MichaelKutzner Jan 16, 2025
8e5de56
WIP: Group ways by tile
MichaelKutzner Jan 21, 2025
7779cb3
WIP: Delete not required code
MichaelKutzner Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: Fix route elevation
  • Loading branch information
MichaelKutzner committed Jan 14, 2025
commit afdb8b39822800613e60f97e8c4cea12b1c46a90
6 changes: 4 additions & 2 deletions include/osr/elevation_storage.h
Original file line number Diff line number Diff line change
@@ -39,12 +39,14 @@ struct elevation_storage {
std::filesystem::path const&);
void set_elevations(ways const&, preprocessing::elevation::provider const&);
elevation get_elevations(way_idx_t const way,
std::uint16_t const from,
std::uint16_t const to) const;
std::uint16_t const segment) const;

mm_vecvec<way_idx_t, encoding> elevations_;
};

elevation_storage::elevation get_elevations(elevation_storage const*,
way_idx_t const way,
std::uint16_t const segment);
elevation_storage::elevation get_elevations(elevation_storage const*,
way_idx_t const way,
std::uint16_t const from,
2 changes: 1 addition & 1 deletion include/osr/routing/dijkstra.h
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ struct dijkstra {
Profile::template adjacent<SearchDir, WithBlocked>(
r, curr, blocked, sharing, elevations,
[&](node const neighbor, std::uint32_t const cost, distance_t,
way_idx_t const way, std::uint16_t, std::uint16_t) {
way_idx_t const way, std::uint16_t, std::uint16_t, elevation_storage::elevation const={}) {
if constexpr (kDebug) {
std::cout << " NEIGHBOR ";
neighbor.print(std::cout, w);
11 changes: 9 additions & 2 deletions include/osr/routing/profiles/bike.h
Original file line number Diff line number Diff line change
@@ -139,18 +139,25 @@ struct bike {
}

auto const dist = w.way_node_dist_[way][std::min(from, to)];
auto elevation = [&]() {
if constexpr (ElevationUpCost == 0) {
return elevation_storage::elevation{};
} else {
auto const e = get_elevations(elevations, way, from, to);
return (way_dir == direction::kForward) ? e : e.swap();
}
}();
auto const elevation_cost = [&]() {
if constexpr (ElevationUpCost == 0) {
return cost_t{0};
} else {
auto const elevation = get_elevations(elevations, way, from, to);
return static_cast<cost_t>(ElevationUpCost * elevation.up_);
}
};
auto const cost = way_cost(target_way_prop, way_dir, dist) +
node_cost(target_node_prop) + elevation_cost();
fn(node{target_node}, static_cast<std::uint32_t>(cost), dist, way, from,
to);
to, std::move(elevation));
};

if (i != 0U) {
8 changes: 4 additions & 4 deletions include/osr/routing/profiles/bike_sharing.h
Original file line number Diff line number Diff line change
@@ -281,9 +281,9 @@ struct bike_sharing {
w, to_foot(n), blocked, nullptr, elevations,
[&](footp::node const neighbor, std::uint32_t const cost,
distance_t const dist, way_idx_t const way,
std::uint16_t const from, std::uint16_t const to) {
std::uint16_t const from, std::uint16_t const to, elevation_storage::elevation&& elevation={}) {
fn(to_node(neighbor, nt), cost + switch_penalty, dist, way, from,
to);
to, std::move(elevation));
});
if (include_additional_edges) {
// walk to station or free-floating bike
@@ -307,9 +307,9 @@ struct bike_sharing {
[&](bike<kElevationNoCost>::node const neighbor,
std::uint32_t const cost, distance_t const dist,
way_idx_t const way, std::uint16_t const from,
std::uint16_t const to) {
std::uint16_t const to, elevation_storage::elevation&& elevation={}) {
fn(to_node(neighbor, kNoLevel), cost + switch_penalty, dist, way,
from, to);
from, to, std::move(elevation));
});
if (include_additional_edges) {
// drive to station
25 changes: 14 additions & 11 deletions src/elevation_storage.cc
Original file line number Diff line number Diff line change
@@ -118,23 +118,26 @@ void elevation_storage::set_elevations(
}

elevation_storage::elevation elevation_storage::get_elevations(
way_idx_t const way,
std::uint16_t const from,
std::uint16_t const to) const {
auto const idx = (from < to) ? from : to;
auto const e = (way < elevations_.size() && idx < elevations_[way].size())
? elevations_[way][idx].decode()
: elevation{0U, 0U};
return (from < to) ? e : e.swap();
way_idx_t const way, std::uint16_t const segment) const {
return (way < elevations_.size() && segment < elevations_[way].size())
? elevations_[way][segment].decode()
: elevation{0U, 0U};
}

elevation_storage::elevation get_elevations(elevation_storage const* elevations,
way_idx_t const way,
std::uint16_t const from,
std::uint16_t const to) {
std::uint16_t const segment) {
return elevations == nullptr
? elevation_storage::elevation{elevation_t{0}, elevation_t{0}}
: elevations->get_elevations(way, from, to);
: elevations->get_elevations(way, segment);
}

elevation_storage::elevation get_elevations(elevation_storage const* elevations,
way_idx_t const way,
std::uint16_t const from,
std::uint16_t const to) {
return from < to ? get_elevations(elevations, way, from)
: get_elevations(elevations, way, to).swap();
}

elevation_storage::elevation& elevation_storage::elevation::operator+=(
7 changes: 3 additions & 4 deletions src/route.cc
Original file line number Diff line number Diff line change
@@ -46,14 +46,13 @@ connecting_way find_connecting_way(ways const& w,
r, from, blocked, sharing, elevations,
[&](typename Profile::node const target, std::uint32_t const cost,
distance_t const dist, way_idx_t const way, std::uint16_t const a_idx,
std::uint16_t const b_idx) {
std::uint16_t const b_idx,
elevation_storage::elevation&& elevation = {}) {
if (target == to && cost == expected_cost) {
auto const is_loop = way != way_idx_t::invalid() && r.is_loop(way) &&
static_cast<unsigned>(std::abs(a_idx - b_idx)) ==
r.way_nodes_[way].size() - 2U;
conn = {way, a_idx,
b_idx, is_loop,
dist, get_elevations(elevations, way, a_idx, b_idx)};
conn = {way, a_idx, b_idx, is_loop, dist, std::move(elevation)};
}
});
utl::verify(