|
|
@@ -287,7 +287,7 @@ impl OrthograficView {
|
|
287
|
287
|
}
|
|
288
|
288
|
|
|
289
|
289
|
// Returns the coordinates of the location that is nearest to the given `ScreenCoord`.
|
|
290
|
|
- pub fn screen_coord_to_latlonrad(map_view: &MapView, screen_coord: ScreenCoord) -> LatLonRad {
|
|
|
290
|
+ pub fn screen_coord_to_sphere_point(map_view: &MapView, screen_coord: ScreenCoord) -> Point3<f64> {
|
|
291
|
291
|
// Point on unit sphere
|
|
292
|
292
|
let sphere_point = {
|
|
293
|
293
|
let recip_radius = 2.0 * Self::diameter_physical_pixels(map_view).recip();
|
|
|
@@ -314,11 +314,33 @@ impl OrthograficView {
|
|
314
|
314
|
|
|
315
|
315
|
// Rotate
|
|
316
|
316
|
let inv_trans = Self::inv_rotation_matrix(map_view);
|
|
317
|
|
- let p = inv_trans.transform_point(sphere_point);
|
|
|
317
|
+ inv_trans.transform_point(sphere_point)
|
|
|
318
|
+ }
|
|
|
319
|
+
|
|
|
320
|
+ // Returns the coordinates of the location that is nearest to the given `ScreenCoord`.
|
|
|
321
|
+ pub fn screen_coord_to_latlonrad(map_view: &MapView, screen_coord: ScreenCoord) -> LatLonRad {
|
|
|
322
|
+ let p = Self::screen_coord_to_sphere_point(map_view, screen_coord);
|
|
318
|
323
|
|
|
319
|
324
|
// Transform to latitude, longitude
|
|
320
|
325
|
LatLonRad::new(p.y.asin(), p.z.atan2(p.x))
|
|
321
|
326
|
}
|
|
|
327
|
+
|
|
|
328
|
+ /// Change zoom value by `zoom_delta` and zoom to a position given in screen coordinates.
|
|
|
329
|
+ pub fn zoom_at(map_view: &mut MapView, pos: ScreenCoord, zoom_delta: f64) {
|
|
|
330
|
+ //TODO Do something sophisticated: Increase zoom and rotate slightly so that the given
|
|
|
331
|
+ // ScreenCoord points to the same geographical location.
|
|
|
332
|
+ /*
|
|
|
333
|
+ let latlon = Self::screen_coord_to_latlonrad(map_view, pos);
|
|
|
334
|
+
|
|
|
335
|
+ let delta_x = pos.x - map_view.width * 0.5;
|
|
|
336
|
+ let delta_y = pos.y - map_view.height * 0.5;
|
|
|
337
|
+
|
|
|
338
|
+ map_view.center = latlon.into();
|
|
|
339
|
+ */
|
|
|
340
|
+
|
|
|
341
|
+ map_view.zoom += zoom_delta;
|
|
|
342
|
+ }
|
|
|
343
|
+
|
|
322
|
344
|
}
|
|
323
|
345
|
|
|
324
|
346
|
#[cfg(test)]
|