Skip to content

Commit 01f7dd6

Browse files
committed
feat: Support non-wrappable tile schemas
1 parent 5363825 commit 01f7dd6

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

galileo/src/tile_schema/builder.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct TileSchemaBuilder {
1919
tile_width: u32,
2020
tile_height: u32,
2121
y_direction: VerticalDirection,
22+
wrap_x: bool,
2223
}
2324

2425
#[derive(Debug)]
@@ -165,6 +166,7 @@ impl TileSchemaBuilder {
165166
tile_width: self.tile_width,
166167
tile_height: self.tile_height,
167168
y_direction: self.y_direction,
169+
wrap_x: self.wrap_x,
168170
})
169171
}
170172

@@ -192,6 +194,7 @@ impl TileSchemaBuilder {
192194
tile_width: 0,
193195
tile_height: 0,
194196
y_direction: VerticalDirection::TopToBottom,
197+
wrap_x: true,
195198
}
196199
}
197200

@@ -218,6 +221,21 @@ impl TileSchemaBuilder {
218221
self.lods = Lods::Custom(z_levels.into_iter().collect());
219222
self
220223
}
224+
225+
/// If set to true, tiles will wrap around x axis of the schema bounds.
226+
///
227+
/// This means, that if a tile requested for x coordinate that is larger than the maximum x of the
228+
/// bounding box or smaller than the minimum x value, the tile index will be calculated by reducing
229+
/// or increasing x coordinate by the whole number of bounding box widths. This produces an effect of
230+
/// horizontally infinite map, where a user can pan as log as they want to the right or left.
231+
///
232+
/// Note, that for wrapping to work property, bounds of the tile schema should cover the whole globe.
233+
/// This is not enforced in `.build()` method validatation since tile schema is agnostic to the CRS
234+
/// it will be used for.
235+
pub fn wrap_x(mut self, shall_wrap: bool) -> Self {
236+
self.wrap_x = shall_wrap;
237+
self
238+
}
221239
}
222240

223241
#[cfg(test)]

galileo/src/tile_schema/schema.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ pub struct TileSchema {
3434
pub(super) tile_height: u32,
3535
/// Direction of the Y-axis.
3636
pub(super) y_direction: VerticalDirection,
37+
/// Specifies whether tiles should be wrapped over x index.
38+
pub(super) wrap_x: bool,
3739
}
3840

3941
pub struct Lod {
@@ -173,8 +175,7 @@ impl TileSchema {
173175
}
174176

175177
fn wrap_x(&self) -> bool {
176-
// TODO: https://github.com/Maximkaaa/galileo/issues/221
177-
true
178+
self.wrap_x
178179
}
179180

180181
fn min_x_displayed_index(&self, resolution: f64) -> i32 {
@@ -254,6 +255,7 @@ mod tests {
254255
tile_width: 256,
255256
tile_height: 256,
256257
y_direction: VerticalDirection::BottomToTop,
258+
wrap_x: true,
257259
}
258260
}
259261

0 commit comments

Comments
 (0)