diff --git a/src/O4_Config_Utils.py b/src/O4_Config_Utils.py index d181be99..16d19a0e 100644 --- a/src/O4_Config_Utils.py +++ b/src/O4_Config_Utils.py @@ -267,10 +267,16 @@ def write_to_config(self, config_file = None): f = open(config_file, "w") for var in list_tile_vars: tile_zones = [] + lat = self.lat + lon = self.lon + if lat < 0: + lat = lat + 1 + if lon < 0: + lon = lon + 1 for zone in globals()["zone_list"]: _zone_list = [int(coord) for coord in zone[0]] _zone_list = set(_zone_list) - if self.lat in _zone_list and self.lon+1 in _zone_list: + if lat in _zone_list and lon in _zone_list: tile_zones.append(zone) _LOGGER.debug("Zones in tile found: %s", tile_zones) if var == "zone_list": @@ -355,7 +361,7 @@ def tile_cfg_status(self, *args) -> None: if self.parent.tile_cfg_exists.get(): self.tile_cfg_msg.set( f"Tile configuration loaded for " \ - f"{self.parent.lat.get()}{self.parent.lon.get()}" + f"{self.parent.lat.get()} {self.parent.lon.get()}" ) state = "normal" for _, value in self.tile_entry_.items(): @@ -955,6 +961,10 @@ def reset_tile_cfg(self) -> None: return 0 # Find all the zones for the active tile tile_zones = [] + if lat < 0: + lat = lat + 1 + if lon < 0: + lon = lon + 1 for zone in globals()["zone_list"]: _zone_list = [int(coord) for coord in zone[0]] _zone_list = set(_zone_list) @@ -1029,7 +1039,7 @@ def load_backup_tile_cfg(self) -> None: pass # Apply changes to update global variables self.apply_changes("tile") - UI.vprint(0, f"Backup configuration loaded for tile at {lat}{lon}") + UI.vprint(0, f"Backup configuration loaded for tile at {lat} {lon}") f.close() def load_tile_cfg(self) -> None: @@ -1081,7 +1091,7 @@ def load_tile_cfg(self) -> None: self.parent.tile_cfg_exists.set(True) # Apply changes to update global variables self.apply_changes("tile") - UI.vprint(0, f"Configuration loaded for tile at {lat}{lon}") + UI.vprint(0, f"Configuration loaded for tile at {lat} {lon}") f.close() def write_tile_cfg(self) -> None: @@ -1115,10 +1125,14 @@ def write_tile_cfg(self) -> None: self.apply_changes("tile") # Get zones only for the tile tile_zones = [] + if lat < 0: + lat = lat + 1 + if lon < 0: + lon = lon + 1 for zone in globals()["zone_list"]: _zone_list = [int(coord) for coord in zone[0]] _zone_list = set(_zone_list) - if lat in _zone_list and lon+1 in _zone_list: + if lat in _zone_list and lon in _zone_list: tile_zones.append(zone) _LOGGER.debug("Zones saved for tile at %s %s: %s", lat, lon, tile_zones) for var in list_tile_vars: @@ -1128,7 +1142,7 @@ def write_tile_cfg(self) -> None: f.write(var + "=" + self.v_[var].get() + "\n") self.load_tile_cfg() self.tile_cfg_status() - UI.vprint(1, f"Configuration saved for tile at {lat}{lon}") + UI.vprint(1, f"Configuration saved for tile at {lat} {lon}") return def reset_global_cfg(self) -> None: diff --git a/src/O4_DEM_Utils.py b/src/O4_DEM_Utils.py index 04cd8315..5ddaf29f 100755 --- a/src/O4_DEM_Utils.py +++ b/src/O4_DEM_Utils.py @@ -671,10 +671,25 @@ def ensure_elevation(source, lat, lon, verbose=True): "P36", "Q36", "R36", + # New Zealand + "SL58", + "SI59", + "SJ59", + "SK59", + "SL59", + "SI60", + "SJ60", + "SK60", + "SL60", ): resol = 1 else: resol = 3 + + # Wellington Intl has missing elevation data in 1" resolution + if (lat, lon) == (-42, 174): + resol = 3 + url = ( "http://viewfinderpanoramas.org/dem" + str(resol) diff --git a/src/O4_DSF_Utils.py b/src/O4_DSF_Utils.py index 97806b7a..b0fdf003 100755 --- a/src/O4_DSF_Utils.py +++ b/src/O4_DSF_Utils.py @@ -364,6 +364,12 @@ def extract_elevation_and_bathymetry_data(lat, lon): "Earth nav data", FNAMES.long_latlon(lat, lon) + ".dsf", ) + if not os.path.exists(global_scenery_dsf): + global_scenery_dsf = os.path.join( + OVL.custom_overlay_src_alternate, + "Earth nav data", + FNAMES.long_latlon(lat, lon) + ".dsf", + ) if not os.path.exists(global_scenery_dsf): UI.exit_message_and_bottom_line( " ERROR: file ", diff --git a/src/O4_GUI_Utils.py b/src/O4_GUI_Utils.py index 611c863b..fc31e84e 100755 --- a/src/O4_GUI_Utils.py +++ b/src/O4_GUI_Utils.py @@ -490,7 +490,7 @@ def load_tile_cfg(self, lat: int, lon: int) -> None: self.default_website.set(CFG.default_website) self.default_zl.set(CFG.default_zl) self.tile_cfg_exists.set(True) - UI.vprint(1, f"Configuration loaded for tile at {lat}{lon}") + UI.vprint(1, f"Configuration loaded for tile at {lat} {lon}") f.close() else: for var in list_global_tile_vars: @@ -558,7 +558,21 @@ def get_lat_lon(self, check=True): return (48, -6) return (lat, lon) - def tile_from_interface(self): + def tile_from_interface(self) -> CFG.Tile | bool: + """ + Create a Tile object for building a tile from the main window. + + :return: Tile object or False + ;rtype: Tile object or False + """ + # Check for unsaved changes + if ( + self.config_window is not None + and self.config_window.winfo_exists() + ): + response = self.config_window.check_unsaved_changes() + if response == "cancel": + return False try: (lat, lon) = self.get_lat_lon() return CFG.Tile(lat, lon, str(self.custom_build_dir.get())) @@ -568,7 +582,10 @@ def tile_from_interface(self): def build_poly_file(self): try: tile = self.tile_from_interface() - tile.make_dirs() + if tile: + tile.make_dirs() + else: + return except Exception as e: UI.vprint(1, "Process aborted.\n") _LOGGER.exception(e) @@ -581,7 +598,10 @@ def build_poly_file(self): def build_mesh(self, event): try: tile = self.tile_from_interface() - tile.make_dirs() + if tile: + tile.make_dirs() + else: + return except Exception as e: UI.vprint(1, "Process aborted.\n") _LOGGER.exception("Exception on build_mesh") @@ -594,7 +614,10 @@ def build_mesh(self, event): def sort_mesh(self, event): try: tile = self.tile_from_interface() - tile.make_dirs() + if tile: + tile.make_dirs() + else: + return except Exception as e: UI.vprint(1, "Process aborted.\n") _LOGGER.exception("Exception on sort_mesh") @@ -607,7 +630,10 @@ def sort_mesh(self, event): def community_mesh(self, event): try: tile = self.tile_from_interface() - tile.make_dirs() + if tile: + tile.make_dirs() + else: + return except Exception as e: UI.vprint(1, "Process aborted.\n") _LOGGER.exception("Exception on community_mesh") @@ -621,7 +647,10 @@ def build_masks(self, event): for_imagery = "Shift" in str(event) or "shift" in str(event) try: tile = self.tile_from_interface() - tile.make_dirs() + if tile: + tile.make_dirs() + else: + return except Exception as e: UI.vprint(1, "Process aborted.\n") _LOGGER.exception(e) @@ -632,17 +661,12 @@ def build_masks(self, event): self.working_thread.start() def build_tile(self): - # Check for unsaved changes - if ( - self.config_window is not None - and self.config_window.winfo_exists() - ): - response = self.config_window.check_unsaved_changes() - if response == "cancel": - return try: tile = self.tile_from_interface() - tile.make_dirs() + if tile: + tile.make_dirs() + else: + return except Exception as e: UI.vprint(1, "Process aborted.\n") _LOGGER.exception(e) @@ -663,7 +687,10 @@ def build_all(self): return try: tile = self.tile_from_interface() - tile.make_dirs() + if tile: + tile.make_dirs() + else: + return except Exception as e: UI.vprint(1, "Process aborted.\n") _LOGGER.exception(e) diff --git a/src/O4_Overlay_Utils.py b/src/O4_Overlay_Utils.py index c59f9e81..345041fe 100644 --- a/src/O4_Overlay_Utils.py +++ b/src/O4_Overlay_Utils.py @@ -205,7 +205,7 @@ def build_overlay(lat, lon): dest_dir = os.path.join( FNAMES.Overlay_dir, "Earth nav data", FNAMES.round_latlon(lat, lon) ) - UI.vprint(1, "-> Coping the final overlay DSF in " + dest_dir) + UI.vprint(1, "-> Copying the final overlay DSF in " + dest_dir) if not os.path.exists(dest_dir): try: os.makedirs(dest_dir) diff --git a/src/O4_Version.py b/src/O4_Version.py index 778bc808..80242751 100755 --- a/src/O4_Version.py +++ b/src/O4_Version.py @@ -1 +1 @@ -version='1.40.03' +version='1.40.04'