Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rustdocflags = ["--cfg", "zerocopy_derive_union_into_bytes"]
linker = "s390x-linux-gnu-gcc"

# Use QEMU to run cross-compiled test binaries in CI
# qemu-s390x-static is provided by the qemu-user-static package
# The qemu-user package provides qemu-s390x
# The -L path points to the s390x sysroot installed by libc6-*-s390x-cross
runner = "qemu-s390x-static -L /usr/s390x-linux-gnu"
runner = "qemu-s390x -L /usr/s390x-linux-gnu"

2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

# .cargo/config.toml uses these packages as the s390x linker and test runner.
- name: Install s390x cross toolchain and QEMU
run: sudo apt-get update && sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu libc6-dev-s390x-cross qemu-user-static
run: sudo apt-get update && sudo apt-get install -y gcc-s390x-linux-gnu g++-s390x-linux-gnu libc6-dev-s390x-cross qemu-user

- name: Run tests (big-endian s390x)
run: cargo nextest run --no-fail-fast --target s390x-unknown-linux-gnu
Expand Down
Binary file not shown.
Binary file not shown.
28 changes: 18 additions & 10 deletions valhalla-graphtile/src/graph_id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::tile_hierarchy::{STANDARD_LEVELS, TRANSIT_LEVEL};
use crate::tile_hierarchy::tile_level;
#[cfg(feature = "serde")]
use serde::{Serialize, Serializer};
use std::fmt::{Display, Formatter};
Expand Down Expand Up @@ -44,8 +44,8 @@ pub enum InvalidGraphIdError {
/// # Hierarchy (level + Tile ID)
///
/// Valhalla organizes tiles into several levels.
/// For a description of the common ones, see [`STANDARD_LEVELS`]
/// and [`TRANSIT_LEVEL`].
/// For a description of the common ones, see [`STANDARD_LEVELS`](crate::tile_hierarchy::STANDARD_LEVELS)
/// and [`TRANSIT_LEVEL`](crate::tile_hierarchy::TRANSIT_LEVEL).
/// Each level includes progressively more "local" roads.
/// This helps improve efficiency.
///
Expand Down Expand Up @@ -213,16 +213,12 @@ impl GraphId {
///
/// # Errors
///
/// This will fail if the tile is invalid for this level of tiling.
/// This will fail if the level is not a standard level or the transit level,
/// or if the tile is invalid for this level of tiling.
/// TODO: It seems like we could do this check at tile creation time?
pub fn file_path(&self, extension: &str) -> Result<PathBuf, InvalidGraphIdError> {
// This is quite ugly and prone to failure; this is a pretty literal C++ translation
let level_number = self.level();
let level = if level_number == TRANSIT_LEVEL.level {
&*TRANSIT_LEVEL
} else {
&STANDARD_LEVELS[level_number as usize]
};
let level = tile_level(self.level()).ok_or(InvalidGraphIdError::Level)?;

let max_id = level.tiling_system.n_cols * level.tiling_system.n_rows - 1;
let tile_id = self.tile_id();
Expand Down Expand Up @@ -423,4 +419,16 @@ mod tests {
Ok("3/001/000/000.gph".into())
);
}

#[test]
fn test_graph_id_file_path_unknown_level() {
for level in 4..=MAX_HIERARCHY_LEVEL {
assert_eq!(
GraphId::try_from_components(level, 0, 0)
.unwrap()
.file_path("gph"),
Err(InvalidGraphIdError::Level)
);
}
}
}
Loading
Loading