|
|
@@ -29,6 +29,7 @@ pub mod tile_source;
|
|
29
|
29
|
use coord::ScreenCoord;
|
|
30
|
30
|
use glutin::{ControlFlow, ElementState, Event, GlContext, MouseButton, MouseScrollDelta, VirtualKeyCode, WindowEvent};
|
|
31
|
31
|
use map_view_gl::MapViewGl;
|
|
|
32
|
+use std::error::Error;
|
|
32
|
33
|
use std::time::{Duration, Instant};
|
|
33
|
34
|
use tile_source::TileSource;
|
|
34
|
35
|
|
|
|
@@ -174,19 +175,18 @@ fn dur_to_sec(dur: Duration) -> f64 {
|
|
174
|
175
|
dur.as_secs() as f64 + f64::from(dur.subsec_nanos()) * 1e-9
|
|
175
|
176
|
}
|
|
176
|
177
|
|
|
177
|
|
-fn main() {
|
|
178
|
|
- env_logger::init();
|
|
179
|
|
-
|
|
180
|
|
- let config = config::Config::from_arg_matches(&args::parse()).unwrap();
|
|
|
178
|
+fn run() -> Result<(), Box<Error>> {
|
|
|
179
|
+ let config = config::Config::from_arg_matches(&args::parse())?;
|
|
181
|
180
|
|
|
182
|
|
- let mut sources = TileSources::new(config.tile_sources()).unwrap();
|
|
|
181
|
+ let mut sources = TileSources::new(config.tile_sources())
|
|
|
182
|
+ .ok_or_else(|| "no tile sources provided.")?;
|
|
183
|
183
|
|
|
184
|
184
|
let mut events_loop = glutin::EventsLoop::new();
|
|
185
|
185
|
let builder = glutin::WindowBuilder::new()
|
|
186
|
186
|
.with_title(format!("DeltaMap - {}", sources.current_name()));
|
|
187
|
187
|
|
|
188
|
188
|
let gl_context = glutin::ContextBuilder::new();
|
|
189
|
|
- let gl_window = glutin::GlWindow::new(builder, gl_context, &events_loop).unwrap();
|
|
|
189
|
+ let gl_window = glutin::GlWindow::new(builder, gl_context, &events_loop)?;
|
|
190
|
190
|
let window = gl_window.window();
|
|
191
|
191
|
|
|
192
|
192
|
let _ = unsafe { gl_window.make_current() };
|
|
|
@@ -320,6 +320,17 @@ fn main() {
|
|
320
|
320
|
window.set_title(&format!("DeltaMap - {}", sources.current_name()));
|
|
321
|
321
|
}
|
|
322
|
322
|
}
|
|
|
323
|
+
|
|
|
324
|
+ Ok(())
|
|
|
325
|
+}
|
|
|
326
|
+
|
|
|
327
|
+fn main() {
|
|
|
328
|
+ env_logger::init();
|
|
|
329
|
+
|
|
|
330
|
+ if let Err(err) = run() {
|
|
|
331
|
+ println!("{}", err);
|
|
|
332
|
+ std::process::exit(1);
|
|
|
333
|
+ }
|
|
323
|
334
|
}
|
|
324
|
335
|
|
|
325
|
336
|
struct TileSources<'a> {
|