Skip to content

Commit

Permalink
Merge pull request #31 from shred86/dev
Browse files Browse the repository at this point in the history
Version 1.40.05
  • Loading branch information
shred86 authored Jun 30, 2024
2 parents 97afd19 + e56fc4e commit 9af6496
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 81 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Ortho4XP
![example](https://github.com/shred86/Ortho4XP/assets/32663154/f06ebfe5-ba1d-4f05-9439-8e569bd99ef5)

Ortho4XP is a scenery generation tool for X-Plane. It creates the scenery base mesh and texture layer using external data and orthophoto sources.
Ortho4XP is a scenery generation tool for [X-Plane](https://www.x-plane.com). It creates the scenery base mesh and texture layer using external data and orthophoto sources.

This is a forked version of [Ortho4XP](https://github.com/oscarpilote/Ortho4XP) developed by [@oscarpilote](https://github.com/oscarpilote) which includes some updates, fixes and documentation. The official version is infrequently updated which is the reason I created this forked version to provide quicker updates and documentation.

Expand All @@ -16,6 +16,7 @@ The specific changes in this forked version:
* "Read per tile cfg" removed and a "Override tile cfg" option added. This override setting allows you to force using the global configuration setting on all tiles, overriding any existing tile configurations.
* Erased cached data feature works like batch building tiles now, meaning Shift-Click (red rectangle) to select tiles, choose deletion options, and click "Batch Delete". The batch delete has no effect on the active tile selection (yellow rectangle).
* Display asterisk next to each tile zoom level number in the Tiles and configuration window if custom zoom levels have been specified.
* Added ability to create a symlink to the yOrtho4XP_Overlays folder by pressing the "O" key in the Tiles Collection and Management window.

#### Config
* Ortho4XP Config window is now separated into three tabs: Tile Config, Global Config, and Application Config.
Expand All @@ -27,7 +28,7 @@ The specific changes in this forked version:
* "Load Backup Cfg" buttons added to the Tile, Global, and Application Config tabs which loads settings from a backup config file (if available).
* Added ability to set an alternate `custom_overlay_src` directory to resolve an issue for some users. The default X-Plane scenery files are split up between `/X-Plane 12/Global Scenery/X-Plane Global Scenery` and `/X-Plane 12/Global Scenery/X-Plane Demo Areas`. So if you set `custom_overlay_src` to the first directory and try to batch build a bunch of tiles, you might get an error that the .dsf file can't be found if it's a location where the .dsf files are located in the second directory.
* The `custom_dem` and `fill_nodata` settings are now saved to the global configuration.
* Prompt user if attempting to close the config window with unsaved changes.
* Prompt user if attempting to close the application or config window with unsaved changes.
* Prompt user if attempting to change the active tile with unsaved changes on the Tile Tab in the config window.
* Prompt user if attempting to build tiles with unsaved changes in the config window.
* Backup of the tile configuration is created when using the "Save Tile Config" button (previously was only during a tile build process).
Expand All @@ -46,6 +47,7 @@ The specific changes in this forked version:
* Fixed zones being saved to tile configuration that were outside of the tile location.
* Fixed a bug where symlinks weren't automatically deleted if you used the Erased cached data - Tile (whole) option.
* Fixed a bug if you created zones on a tile then clicked "Apply" (which no longer exists as a button) before saving the tile config, it would delete your zones.
* Fix Viewfinderpanorama elevation source for certain regions of the world.
* Corrected a few typos in setting descriptions.


Expand Down
97 changes: 28 additions & 69 deletions src/O4_DEM_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,61 +594,22 @@ def ensure_elevation(source, lat, lon, verbose=True):
if source == "View":
# Viewfinderpanorama grouping of files and resolutions is a
# bit complicated...
if (lat, lon) in (
(44, 5),
(45, 5),
(46, 5),
(43, 6),
(44, 6),
(45, 6),
(46, 6),
(47, 6),
(43, 7),
(44, 7),
(45, 7),
(46, 7),
(47, 7),
(45, 8),
(46, 8),
(47, 8),
(45, 9),
(46, 9),
(47, 9),
(45, 10),
(46, 10),
(47, 10),
(45, 11),
(46, 11),
(47, 11),
(45, 12),
(46, 12),
(47, 12),
(46, 13),
(47, 13),
(46, 14),
(47, 14),
(46, 15),
(47, 15),
):
resol = 1
url = (
"http://viewfinderpanoramas.org/dem1/"
+ os.path.basename(FNAMES.base_file_name(lat, lon)).lower()
+ ".zip"
)
deferranti_nbr = 31 + lon // 6
if deferranti_nbr < 10:
deferranti_nbr = "0" + str(deferranti_nbr)
else:
deferranti_nbr = 31 + lon // 6
if deferranti_nbr < 10:
deferranti_nbr = "0" + str(deferranti_nbr)
else:
deferranti_nbr = str(deferranti_nbr)
alphabet = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
deferranti_letter = (
alphabet[lat // 4] if lat >= 0 else alphabet[(-1 - lat) // 4]
)
if lat < 0:
deferranti_letter = "S" + deferranti_letter
if deferranti_letter + deferranti_nbr in (
deferranti_nbr = str(deferranti_nbr)
alphabet = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
deferranti_letter = (
alphabet[lat // 4] if lat >= 0 else alphabet[(-1 - lat) // 4]
)
if lat < 0:
deferranti_letter = "S" + deferranti_letter
if deferranti_letter + deferranti_nbr in (
"L31",
"L32",
"L33",
"K32",
"O31",
"P31",
"N32",
Expand Down Expand Up @@ -683,21 +644,19 @@ def ensure_elevation(source, lat, lon, verbose=True):
"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)
+ "/"
+ deferranti_letter
+ deferranti_nbr
+ ".zip"
)
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)
+ "/"
+ deferranti_letter
+ deferranti_nbr
+ ".zip"
)
if os.path.exists(FNAMES.viewfinderpanorama(lat, lon)) and (
resol == 3
or os.path.getsize(FNAMES.viewfinderpanorama(lat, lon)) >= 25934402
Expand Down
56 changes: 47 additions & 9 deletions src/O4_GUI_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,16 @@ def open_custom_zl_window(self):
def set_red_flag(self):
UI.red_flag = True

def exit_prg(self):
def exit_prg(self) -> None:
"""Close the Ortho4XP application."""
if (
self.config_window is not None
and self.config_window.winfo_exists()
and not UI.is_working
):
result = self.config_window.check_unsaved_changes(select_tile=True)
if result == "cancel":
return
try:
f = open(FNAMES.resource_path(".last_gui_params.txt"), "w")
f.write(
Expand Down Expand Up @@ -979,8 +988,8 @@ def __init__(self, parent, lat, lon):
row += 1
tk.Label(
self.frame_left,
text="Ctrl+B1 : add texture\nShift+B1: add zone point\n" + \
"Ctrl+B2 : delete zone",
text="Ctrl+B1 : Add texture\nShift+B1: Add zone point\n" + \
"Ctrl+B2 : Delete zone",
bg="light green",
justify=LEFT,
).grid(row=row, column=0, padx=5, pady=20, sticky=N + S + E + W)
Expand Down Expand Up @@ -1495,10 +1504,12 @@ def __init__(self, parent, lat, lon):
row +=1
tk.Label(
self.frame_left,
text="Shortcuts :\n-----------------\nB2-press+hold: move map\n" + \
"B1-double-click: select active\n" + \
"Shift+B1: select multiple tiles\nCtrl+B1: link in Custom Scenery",
bg="light green"
text="B2-click+hold: Move map\n" + \
"B1-double-click: Select active\n" + \
"Shift+B1: Select multiple tiles\nCtrl+B1: Link in Custom Scenery\n" + \
"O: Link overlays in Custom Scenery",
bg="light green",
justify=LEFT
).grid(row=row, column=0, padx=0, pady=5, sticky=N + S + E + W)
row += 1
# Refresh window
Expand Down Expand Up @@ -1539,6 +1550,7 @@ def __init__(self, parent, lat, lon):
self.canvas.bind("<Double-Button-1>", self.select_tile)
self.canvas.bind("<Shift-ButtonPress-1>", self.add_tile)
self.canvas.bind("<Control-ButtonPress-1>", self.toggle_to_custom)
self.canvas.bind("o", self.add_overlay_symlink)
self.canvas.focus_set()
self.draw_canvas(self.nx0, self.ny0)
self.active_lat = lat
Expand Down Expand Up @@ -1650,6 +1662,32 @@ def remove_symlink(self, lat: int, lon: int) -> None:
except:
pass

def add_overlay_symlink(self, *args) -> None:
"""Add/remove symlink for overlays to custom_scenery_dir."""
if not CFG.custom_scenery_dir:
UI.vprint(1, "Custom Scenery directory not set.")
return
link = os.path.join(CFG.custom_scenery_dir, "yOrtho4XP_Overlays")
# Remove symlink if it already exists
if os.path.isdir(link) and os.path.samefile(
os.path.realpath(link), FNAMES.Overlay_dir
):
os.remove(link)
UI.vprint(
1,
f"yOrtho4XP_Overlays link removed from: {CFG.custom_scenery_dir}",
)
return
# Add symlink if it doesn't exist
if ("dar" in sys.platform) or ("win" not in sys.platform):
# Mac and Linux
os.system("ln -s " + ' "' + FNAMES.Overlay_dir + '" "' + link + '"')
else:
os.system('MKLINK /J "' + link + '" "' + FNAMES.Overlay_dir + '"')
UI.vprint(
1, f"yOrtho4XP_Overlays link added to: {CFG.custom_scenery_dir}"
)

def set_working_dir(self):
self.custom_build_dir = self.parent.custom_build_dir.get()
self.grouped = (
Expand Down Expand Up @@ -1692,7 +1730,7 @@ def preview_existing_tiles(self):
lon = int(dir_name.split("XP_")[1][3:7])
except:
continue
# With the enlarged accepetance rule for directory name
# With the enlarged accepetance rule for directory name
# there might be more than one tile for the same (lat,lon),
# we skip all but the first encountered.
if (lat, lon) in self.dico_tiles_done:
Expand Down Expand Up @@ -2049,7 +2087,7 @@ def select_tile(self, event):
result = self.parent.config_window.check_unsaved_changes(select_tile=True)
if result == "cancel":
return

try:
self.canvas.delete(self.active_tile)
except:
Expand Down
2 changes: 1 addition & 1 deletion src/O4_Version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version='1.40.04'
version='1.40.05'

0 comments on commit 9af6496

Please sign in to comment.