Skip to content

Commit

Permalink
remove Xyz::new(), makes it more complicated
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Dec 7, 2022
1 parent 12c42a2 commit ac02930
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions benches/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn main() {}
//
// async fn get_table_source_tile() {
// let source = mock_table_source("public", "table_source").await;
// let xyz = Xyz::new(0, 0, 0);
// let xyz = Xyz { z: 0, x: 0, y: 0 };
// let _tile = source.get_tile(&xyz, &None).await.unwrap();
// }
//
Expand All @@ -77,7 +77,7 @@ fn main() {}
// table_sources: vec![points1, points2],
// };
//
// let xyz = Xyz::new(0, 0, 0);
// let xyz = Xyz { z: 0, x: 0, y: 0 };
// let _tile = source.get_tile(&xyz, &None).await.unwrap();
// }
//
Expand All @@ -88,7 +88,7 @@ fn main() {}
//
// async fn get_function_source_tile() {
// let source = mock_function_source("public", "function_zxy_query");
// let xyz = Xyz::new(0, 0, 0);
// let xyz = Xyz { z: 0, x: 0, y: 0 };
//
// let _tile = source.get_tile(&xyz, &None).await.unwrap();
// }
Expand Down
8 changes: 1 addition & 7 deletions src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ pub struct Xyz {
pub y: i32,
}

impl Xyz {
pub fn new(z: i32, x: i32, y: i32) -> Self {
Self { z, x, y }
}
}

impl Display for Xyz {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
if f.alternate() {
Expand Down Expand Up @@ -129,7 +123,7 @@ mod tests {

#[test]
fn xyz_format() {
let xyz = Xyz::new(1, 2, 3);
let xyz = Xyz { z: 1, x: 2, y: 3 };
assert_eq!(format!("{xyz}"), "1,2,3");
assert_eq!(format!("{xyz:#}"), "1/2/3");
}
Expand Down
6 changes: 5 additions & 1 deletion src/srv/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ async fn get_tile(
let (sources, format) = state.get_sources(&path.source_ids, Some(path.z))?;

let query = Some(query.into_inner());
let xyz = Xyz::new(path.z, path.x, path.y);
let xyz = Xyz {
z: path.z,
x: path.x,
y: path.y,
};

let tile = try_join_all(sources.into_iter().map(|s| s.get_tile(&xyz, &query)))
.await
Expand Down
5 changes: 4 additions & 1 deletion tests/function_source_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ async fn function_source_tilejson() {
async fn function_source_tile() {
let mock = mock_unconfigured().await;
let src = source(&mock, "function_zxy_query");
let tile = src.get_tile(&Xyz::new(0, 0, 0), &None).await.unwrap();
let tile = src
.get_tile(&Xyz { z: 0, x: 0, y: 0 }, &None)
.await
.unwrap();

assert!(!tile.is_empty());
}
5 changes: 4 additions & 1 deletion tests/table_source_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ async fn tables_tilejson_ok() {
async fn tables_tile_ok() {
let mock = mock_unconfigured().await;
let src = source(&mock, "table_source");
let tile = src.get_tile(&Xyz::new(0, 0, 0), &None).await.unwrap();
let tile = src
.get_tile(&Xyz { z: 0, x: 0, y: 0 }, &None)
.await
.unwrap();

assert!(!tile.is_empty());
}
Expand Down

0 comments on commit ac02930

Please sign in to comment.