Skip to content

Commit b59437b

Browse files
committed
feat: Setter for tile schema point of origin
1 parent 3684064 commit b59437b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

galileo/src/tile_schema/builder.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,32 @@ impl TileSchemaBuilder {
236236
self.wrap_x = shall_wrap;
237237
self
238238
}
239+
240+
/// Sets the origin point of the tiles.
241+
///
242+
/// Origin point is set in projection coordinates (for example, in Mercator meters for Mercator projection).
243+
///
244+
/// It is the point where the tile with index `(X: 0, Y: 0)` is located (for every Z index). If the schema
245+
/// uses direction of Y indices from top to bottom, the origin point will be at the left top angle of the
246+
/// tile. If the direction of Y indices is from bottom to top, the origin point will be at the left bottom
247+
/// point of the tile.
248+
///
249+
/// ```
250+
/// # use galileo::tile_schema::TileSchemaBuilder;
251+
/// # use galileo::galileo_types::cartesian::Point2;
252+
/// let tile_schema = TileSchemaBuilder::web_mercator(0..23)
253+
/// .origin(Point2::new(-20_037_508.342787, 20_037_508.342787))
254+
/// .build()
255+
/// .expect("tile schema is properly defined");
256+
/// ```
257+
///
258+
/// Note that origin point doesn't have to be inside the schema bounds. For example, the origin may point to
259+
/// the top left angle of the world map, but tiles might only be available for a specific region, and the
260+
/// bounds will only contain that region. In this case tiles may have indicies starting not from 0.
261+
pub fn origin(mut self, origin: Point2) -> Self {
262+
self.origin = origin;
263+
self
264+
}
239265
}
240266

241267
#[cfg(test)]

0 commit comments

Comments
 (0)