@@ -6,6 +6,7 @@ mod stats;
66use std:: sync:: Arc ;
77
88use crate :: config:: CONFIG ;
9+ use clap:: Parser ;
910use lyon:: math:: vector;
1011use osm:: math:: { deg2num, tile_to_world_space, TileId } ;
1112use winit:: {
@@ -21,6 +22,8 @@ fn main() {
2122 log:: set_max_level ( CONFIG . general . log . level . to_level_filter ( ) ) ;
2223 pretty_env_logger:: init ( ) ;
2324
25+ let args = Args :: parse ( ) ;
26+
2427 let tile_coordinate = deg2num (
2528 CONFIG . map . initial . center . latitude ,
2629 CONFIG . map . initial . center . longitude ,
@@ -72,6 +75,7 @@ fn main() {
7275 modifiers_state,
7376 mouse_down,
7477 last_pos,
78+ args,
7579 } ;
7680
7781 // Hack to make the UI scale correctly.
@@ -93,6 +97,7 @@ pub struct Application {
9397 modifiers_state : ModifiersState ,
9498 mouse_down : bool ,
9599 last_pos : LogicalPosition < f64 > ,
100+ args : Args ,
96101}
97102
98103impl ApplicationHandler for Application {
@@ -211,9 +216,22 @@ impl ApplicationHandler for Application {
211216 if !event_loop. exiting ( ) {
212217 self . painter . update_shader ( ) ;
213218 // self.app_state.load_tile(TileId::new(13, 4290, 2868));
214- self . app_state . load_tile ( TileId :: new ( 14 , 8580 , 5737 ) ) ;
215- // self.app_state.load_tile(TileId::new(17, 137290, 91796));
216- // self.app_state.load_tiles();
219+
220+ if self . args . tile . is_empty ( ) {
221+ self . app_state . load_tiles ( ) ;
222+ } else {
223+ for tile in & self . args . tile {
224+ let coords: Vec < u32 > =
225+ tile. split ( "/" ) . filter_map ( |v| v. parse ( ) . ok ( ) ) . collect ( ) ;
226+ if coords. len ( ) != 3 {
227+ continue ;
228+ }
229+
230+ self . app_state
231+ . load_tile ( TileId :: new ( coords[ 0 ] , coords[ 1 ] , coords[ 2 ] ) ) ;
232+ }
233+ }
234+
217235 self . painter . paint ( & mut self . hud , & mut self . app_state ) ;
218236
219237 self . app_state . stats . capture_frame ( ) ;
@@ -231,3 +249,14 @@ impl ApplicationHandler for Application {
231249 self . painter . window . request_redraw ( ) ;
232250 }
233251}
252+
253+ /// Render a map beautifully and ultra fast with CSS styling
254+ #[ derive( Parser , Debug ) ]
255+ #[ command( version, about, long_about = None ) ]
256+ struct Args {
257+ /// Tile to load (this argument can be given multiple times to load multiple tiles)
258+ ///
259+ /// If no tiles were given the full map is loaded.
260+ #[ arg( short, long) ]
261+ tile : Vec < String > ,
262+ }
0 commit comments