mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 07:53:43 +08:00
[gcs] specify max map zoom level with -maps_zoom option
- defaults to 18, max is 22 - TODO: check that a valid zoomlevel was given - add it to the menu to change at runtime? - if available, larger (low zoomlevel) tiles in cache are loaded right away, even if higher zoomlevel maps could be downloaded.
This commit is contained in:
@@ -174,10 +174,11 @@ end
|
||||
(************ Google, OSM Maps handling *****************************************)
|
||||
module GM = struct
|
||||
(** Fill the visible background with Google, OSM tiles *)
|
||||
let zoomlevel = ref 18
|
||||
let fill_tiles = fun geomap ->
|
||||
match geomap#georef with
|
||||
None -> ()
|
||||
| Some _ -> TodoList.add (fun () -> MapGoogle.fill_window geomap)
|
||||
| Some _ -> TodoList.add (fun () -> MapGoogle.fill_window geomap !zoomlevel)
|
||||
|
||||
let auto = ref false
|
||||
let update = fun geomap ->
|
||||
@@ -197,7 +198,7 @@ module GM = struct
|
||||
posn_long = min geo1.posn_long geo2.posn_long }
|
||||
and ne = { posn_lat = max geo1.posn_lat geo2.posn_lat;
|
||||
posn_long = max geo1.posn_long geo2.posn_long } in
|
||||
let pix = MapGoogle.pixbuf sw ne in
|
||||
let pix = MapGoogle.pixbuf sw ne !zoomlevel in
|
||||
let nw = { posn_lat = ne.posn_lat; posn_long = sw.posn_long }
|
||||
and se = { posn_lat = sw.posn_lat; posn_long = ne.posn_long } in
|
||||
save_map geomap ~projection:"Mercator" pix nw se
|
||||
@@ -347,6 +348,7 @@ let options =
|
||||
"-edit", Arg.Unit (fun () -> edit := true; layout_file := "editor.xml"), "Flight plan editor";
|
||||
"-fullscreen", Arg.Set fullscreen, "Fullscreen window";
|
||||
"-maps_fill", Arg.Set GM.auto, "Automatically start loading background maps";
|
||||
"-maps_zoom", Arg.Set_int GM.zoomlevel, "Background maps zoomlevel (default: 18, max: 22)";
|
||||
"-ign", Arg.String (fun s -> ign:=true; IGN.data_path := s), "IGN tiles path";
|
||||
"-lambertIIe", Arg.Unit (fun () -> projection:=G.LambertIIe),"Switch to LambertIIe projection";
|
||||
"-layout", Arg.Set_string layout_file, (sprintf "<XML layout specification> GUI layout. Default: %s" !layout_file);
|
||||
@@ -470,7 +472,7 @@ let create_geomap = fun switch_fullscreen editor_frame ->
|
||||
(** Separate from A/C menus *)
|
||||
ignore (geomap#factory#add_separator ());
|
||||
|
||||
(** Set the initial soom *)
|
||||
(** Set the initial zoom *)
|
||||
geomap#zoom !zoom;
|
||||
geomap, menu_fact
|
||||
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ open Latlong
|
||||
open Printf
|
||||
|
||||
let tile_size = 256, 256
|
||||
let zoom_max = 18
|
||||
let zoom_max = 22
|
||||
|
||||
let cache_path = ref "/var/tmp"
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ let display_tile = fun (geomap:MapCanvas.widget) wgs84 ->
|
||||
exception New_displayed of int
|
||||
(** [New_displayed zoom] Raised when a new is loadded *)
|
||||
|
||||
let fill_window = fun (geomap:MapCanvas.widget) ->
|
||||
let fill_window = fun (geomap:MapCanvas.widget) zoomlevel ->
|
||||
(** First estimate the coverage of the window *)
|
||||
let width_c, height_c = Gdk.Drawable.get_size geomap#canvas#misc#window
|
||||
and (xc0, yc0) = geomap#canvas#get_scroll_offsets in
|
||||
@@ -136,7 +136,7 @@ let fill_window = fun (geomap:MapCanvas.widget) ->
|
||||
if zoom = 1 then
|
||||
let tile, image = Gm.get_image key in
|
||||
display_the_tile geomap tile image;
|
||||
raise (New_displayed (19-String.length tile.Gm.key))
|
||||
raise (New_displayed (zoomlevel+1-String.length tile.Gm.key))
|
||||
else begin
|
||||
trees.(i) <- Node (Array.create 4 Empty);
|
||||
loop twest tsouth tsize trees i zoom key
|
||||
@@ -158,7 +158,7 @@ let fill_window = fun (geomap:MapCanvas.widget) ->
|
||||
New_displayed z when z = zoom ->
|
||||
trees.(i) <- Tile
|
||||
| Gm.Not_available -> () in
|
||||
loop (-1.) (-1.) 2. [|gm_tiles|] 0 18 "t"
|
||||
loop (-1.) (-1.) 2. [|gm_tiles|] 0 zoomlevel "t"
|
||||
|
||||
|
||||
exception To_copy of int * string
|
||||
@@ -172,7 +172,7 @@ let gdk_pixbuf_safe_copy_area ~dest ~dest_x ~dest_y ~width ~height ~src_x ~src_y
|
||||
and height = min height (GdkPixbuf.get_height dest -dest_y) in
|
||||
GdkPixbuf.copy_area ~dest ~dest_x ~dest_y ~width ~height ~src_x ~src_y pixbuf
|
||||
|
||||
let pixbuf = fun sw ne ->
|
||||
let pixbuf = fun sw ne zoomlevel->
|
||||
assert (sw.LL.posn_lat < ne.LL.posn_lat);
|
||||
assert (sw.LL.posn_long < ne.LL.posn_long);
|
||||
let west = sw.LL.posn_long /. LL.pi
|
||||
@@ -191,7 +191,7 @@ let pixbuf = fun sw ne ->
|
||||
if zoom = 1
|
||||
then
|
||||
let tile, image = Gm.get_image key in
|
||||
raise (To_copy (19-String.length tile.Gm.key, image))
|
||||
raise (To_copy (zoomlevel+1-String.length tile.Gm.key, image))
|
||||
else begin
|
||||
let continue = fun j tw ts ->
|
||||
loop tw ts tsize2 (zoom-1) (key^String.make 1 (char_of j)) in
|
||||
@@ -210,5 +210,5 @@ let pixbuf = fun sw ne ->
|
||||
let pixbuf = GdkPixbuf.from_file image in
|
||||
gdk_pixbuf_safe_copy_area ~dest ~dest_x ~dest_y ~width ~height:width ~src_x ~src_y pixbuf
|
||||
| Gm.Not_available -> () in
|
||||
loop (-1.) (-1.) 2. 18 "t";
|
||||
loop (-1.) (-1.) 2. zoomlevel "t";
|
||||
dest
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
val display_tile : MapCanvas.widget -> Latlong.geographic -> unit
|
||||
(** Displaying the Google Maps tile around the given point (zoom=1) *)
|
||||
|
||||
val fill_window : MapCanvas.widget -> unit
|
||||
(** Filling the canvas window with Google Maps tiles *)
|
||||
val fill_window : MapCanvas.widget -> int -> unit
|
||||
(** Filling the canvas window with Google Maps tiles at given zoomlevel*)
|
||||
|
||||
val pixbuf : Latlong.geographic -> Latlong.geographic -> GdkPixbuf.pixbuf
|
||||
(** [pixbuf south_west north_east] Returns a map background of the given area *)
|
||||
val pixbuf : Latlong.geographic -> Latlong.geographic -> int -> GdkPixbuf.pixbuf
|
||||
(** [pixbuf south_west north_east zoomlevel] Returns a map background of the given area *)
|
||||
|
||||
Reference in New Issue
Block a user