forked from jonaseberle/autoortho-scenery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ortho4xp.diff
286 lines (282 loc) · 10.9 KB
/
ortho4xp.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
diff --git a/Ortho4XP.cfg b/Ortho4XP.cfg
index 3bd794c..fffa9e9 100644
--- a/Ortho4XP.cfg
+++ b/Ortho4XP.cfg
@@ -1,8 +1,8 @@
verbosity=1
-cleaning_level=1
+cleaning_level=3
overpass_server_choice=DE
-skip_downloads=False
-skip_converts=False
+skip_downloads=True
+skip_converts=True
max_convert_slots=4
check_tms_response=True
http_timeout=10.0
@@ -11,12 +11,15 @@ max_baddata_retries=5
ovl_exclude_pol=[0]
ovl_exclude_net=[]
custom_scenery_dir=
-custom_overlay_src=
-road_level=1
+custom_overlay_src=/media/nas/xp_scenery/Global Scenery/X-Plane 11 Global Scenery
+apt_smoothing_pix=8
+road_level=2
road_banking_limit=0.5
+lane_width=5.0
max_levelled_segs=100000
+water_simplification=0.0
min_area=0.001
-max_area=200
+max_area=200.0
clean_bad_geometries=True
mesh_zl=19
curvature_tol=2.0
@@ -27,7 +30,6 @@ coast_curv_ext=0.5
limit_tris=0
hmin=0.0
min_angle=10.0
-apt_smoothing_pix=8
sea_smoothing_mode=zero
water_smoothing=10
iterate=0
@@ -35,10 +37,11 @@ mask_zl=14
masks_width=100
masking_mode=sand
use_masks_for_inland=False
+imprint_masks_to_dds=False
masks_use_DEM_too=False
masks_custom_extent=
-cover_airports_with_highres=False
-cover_extent=1.0
+cover_airports_with_highres=True
+cover_extent=0.5
cover_zl=18
ratio_water=0.25
overlay_lod=25000.0
@@ -47,4 +50,4 @@ add_low_res_sea_ovl=False
experimental_water=0
normal_map_strength=1.0
terrain_casts_shadows=True
-use_decal_on_terrain=False
+use_decal_on_terrain=True
diff --git a/Ortho4XP_v130.py b/Ortho4XP_v130.py
index 58b10c9..daba489 100755
--- a/Ortho4XP_v130.py
+++ b/Ortho4XP_v130.py
@@ -61,15 +61,33 @@ if __name__ == '__main__':
tile=CFG.Tile(lat,lon,'')
tile.default_website=provider_code
tile.default_zl=zoomlevel
- except:
+ tile.read_from_config()
+ except Exception as e:
+ print("Some kind of exception occurred!")
+ print(e)
print(cmd_line); sys.exit()
+
+ # Work around backwards return code logic
+ success = 1
try:
+ print("Build poly file")
VMAP.build_poly_file(tile)
+ print("Build mesh")
MESH.build_mesh(tile)
+ print("Build masks")
MASK.build_masks(tile)
- TILE.build_tile(tile)
+ print("Build tile")
+ success = TILE.build_tile(tile)
print("Bon vol!")
- except:
+ except Exception as e:
print("Crash!")
-
+ print(e)
+ success = 0
+ #sys.exit(1)
+
+ if success:
+ print("Successful tile build")
+ else:
+ print("Unsusccessful tile build. Exit with error")
+ sys.exit(1)
diff --git a/src/O4_Config_Utils.py b/src/O4_Config_Utils.py
index 32067a1..fbba41c 100755
--- a/src/O4_Config_Utils.py
+++ b/src/O4_Config_Utils.py
@@ -155,12 +155,14 @@ class Tile():
def read_from_config(self,config_file=None):
if not config_file:
config_file=os.path.join(self.build_dir,"Ortho4XP_"+FNAMES.short_latlon(self.lat,self.lon)+".cfg")
+ print(f"CONFIG FILE: {config_file}")
if not os.path.isfile(config_file):
config_file=os.path.join(self.build_dir,"Ortho4XP.cfg")
if not os.path.isfile(config_file):
UI.lvprint(0,"CFG error: No config file found for tile",FNAMES.short_latlon(self.lat,self.lon))
return 0
try:
+ print(f"CONFIG FILE: {config_file}")
f=open(config_file,'r')
for line in f.readlines():
line=line.strip()
@@ -369,6 +371,8 @@ class Ortho4XP_Config(tk.Toplevel):
custom_build_dir=self.parent.custom_build_dir_entry.get()
build_dir=FNAMES.build_dir(lat,lon,custom_build_dir)
try:
+ tilecfg=os.path.join(build_dir,'Ortho4XP_'+FNAMES.short_latlon(lat,lon)+'.cfg')
+ print(f"TILE CFG: {tilecfg}")
f=open(os.path.join(build_dir,'Ortho4XP_'+FNAMES.short_latlon(lat,lon)+'.cfg'),'r')
except:
try:
diff --git a/src/O4_GUI_Utils.py b/src/O4_GUI_Utils.py
index ce2d629..7f882a1 100755
--- a/src/O4_GUI_Utils.py
+++ b/src/O4_GUI_Utils.py
@@ -853,6 +853,12 @@ class Ortho4XP_Earth_Preview(tk.Toplevel):
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("<ButtonPress-1>", self.button_1_down)
+ self.canvas.bind("<B1-Motion>", self.button_1_move)
+ self.canvas.bind("<ButtonRelease-1>", self.button_1_up)
+ self.rect = None
+
self.canvas.focus_set()
self.draw_canvas(self.nx0,self.ny0)
self.active_lat=lat
@@ -1100,6 +1106,39 @@ class Ortho4XP_Earth_Preview(tk.Toplevel):
self.dico_tiles_todo.pop((lat,lon),None)
return
+
+ def button_1_down(self, event):
+ x=self.canvas.canvasx(event.x)
+ y=self.canvas.canvasy(event.y)
+ #self.rect = self.canvas.create_rectangle(x, y, 1, 1, fill="")
+ print(f"BUTTON DOWN: {x}, {y}")
+
+
+ def button_1_move(self, event):
+
+ x=self.canvas.canvasx(event.x)
+ y=self.canvas.canvasy(event.y)
+ (lat,lon)=[floor(t) for t in GEO.pix_to_wgs84(x,y,self.earthzl)]
+ if (lat,lon) not in self.dico_tiles_todo:
+ [x0,y0]=GEO.wgs84_to_pix(lat+1,lon,self.earthzl)
+ [x1,y1]=GEO.wgs84_to_pix(lat,lon+1,self.earthzl)
+ if not OsX:
+ self.dico_tiles_todo[(lat,lon)]=self.canvas.create_rectangle(x0,y0,x1,y1,fill='red',stipple='gray12')
+ else:
+ self.dico_tiles_todo[(lat,lon)]=self.canvas.create_rectangle(x0+2,y0+2,x1-2,y1-2,outline='red',width=1)
+ return
+ #self.rect = self.canvas.create_rectangle(x, y, 1, 1, fill="")
+ print(f"MOUSE MOVE: {x}, {y}")
+
+ def button_1_up(self, event):
+ x=self.canvas.canvasx(event.x)
+ y=self.canvas.canvasy(event.y)
+ self.rect = None
+ print(f"BUTTON UP: {x}, {y}")
+
+
+
+
def batch_build(self):
list_lat_lon=sorted(self.dico_tiles_todo.keys())
if not list_lat_lon: return
diff --git a/src/O4_Imagery_Utils.py b/src/O4_Imagery_Utils.py
index 333d453..dd9b71e 100755
--- a/src/O4_Imagery_Utils.py
+++ b/src/O4_Imagery_Utils.py
@@ -1422,7 +1422,13 @@ def convert_texture(tile,til_x_left,til_y_top,zoomlevel,provider_code,type='dds'
file_to_convert=os.path.join(file_dir,jpeg_file_name)
# eventually the dds conversion
if type=='dds':
- if not dxt5:
+ if providers_dict[provider_code].get('skip_img'):
+ with open(os.path.join(tile.build_dir,'textures',out_file_name), 'a'):
+ pass
+ #try: os.remove(os.path.join(UI.Ortho4XP_dir,'tmp',png_file_name))
+ try: os.remove(file_to_convert)
+ except: pass
+ elif not dxt5:
conv_cmd=[dds_convert_cmd,'-bc1','-fast',file_to_convert,os.path.join(tile.build_dir,'textures',out_file_name),devnull_rdir]
else:
conv_cmd=[dds_convert_cmd,'-bc3','-fast',file_to_convert,os.path.join(tile.build_dir,'textures',out_file_name),devnull_rdir]
@@ -1443,21 +1449,23 @@ def convert_texture(tile,til_x_left,til_y_top,zoomlevel,provider_code,type='dds'
return
conv_cmd=[gdalwarp_cmd,'-of','Gtiff','-co','COMPRESS=JPEG','-s_srs','epsg:3857','-t_srs','epsg:4326','-ts','4096','4096','-rb',tmp_tif_file_name,os.path.join(FNAMES.Geotiff_dir,out_file_name)]
tentative=0
- while True:
- if not subprocess.call(conv_cmd,stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT):
- break
- tentative+=1
- if tentative==10:
- UI.lvprint(1,"ERROR: Could not convert texture",os.path.join(tile.build_dir,'textures',out_file_name),"(10 tries)")
- break
- UI.lvprint(1,"WARNING: Could not convert texture",os.path.join(tile.build_dir,'textures',out_file_name))
- time.sleep(1)
- if erase_tmp_png:
- try: os.remove(os.path.join(UI.Ortho4XP_dir,'tmp',png_file_name))
- except: pass
- if erase_tmp_tif:
- try: os.remove(os.path.join(UI.Ortho4XP_dir,'tmp',png_file_name))
- except: pass
+ try:
+ while True and not providers_dict[provider_code].get('skip_img'):
+ if not subprocess.call(conv_cmd,stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT):
+ break
+ tentative+=1
+ if tentative==10:
+ UI.lvprint(1,"ERROR: Could not convert texture",os.path.join(tile.build_dir,'textures',out_file_name),"(10 tries)")
+ break
+ UI.lvprint(1,"WARNING: Could not convert texture",os.path.join(tile.build_dir,'textures',out_file_name))
+ time.sleep(1)
+ finally:
+ if erase_tmp_png:
+ try: os.remove(os.path.join(UI.Ortho4XP_dir,'tmp',png_file_name))
+ except: pass
+ if erase_tmp_tif:
+ try: os.remove(os.path.join(UI.Ortho4XP_dir,'tmp',png_file_name))
+ except: pass
return
###############################################################################################################################
diff --git a/src/O4_Mesh_Utils.py b/src/O4_Mesh_Utils.py
index 497cc73..28b7e8d 100755
--- a/src/O4_Mesh_Utils.py
+++ b/src/O4_Mesh_Utils.py
@@ -427,11 +427,12 @@ def build_mesh(tile):
'{:.9g}'.format(tile.dem.nodata),
'{:.9g}'.format(tile.curvature_tol*curv_tol_scaling),
'{:.9g}'.format(tile.min_angle),str(hmin_effective),alt_file,weight_file,poly_file]
-
+ print(mesh_cmd)
del(tile.dem) # for machines with not much RAM, we do not need it anymore
tile.dem=None
UI.vprint(1,"-> Start of the mesh algorithm Triangle4XP.")
UI.vprint(2,' Mesh command:',' '.join(mesh_cmd))
+ print(f" Mesh command: {' '.join(mesh_cmd)}")
fingers_crossed=subprocess.Popen(mesh_cmd,stdout=subprocess.PIPE,bufsize=0)
while True:
line = fingers_crossed.stdout.readline()
@@ -448,6 +449,7 @@ def build_mesh(tile):
UI.vprint(0,"\nWARNING: Triangle4XP could not achieve the requested quality (min_angle), most probably due to an uncatched OSM error.\n"+\
"It will be tempted now with no angle constraint (i.e. min_angle=0).")
mesh_cmd[-5]='{:.9g}'.format(0)
+ print(mesh_cmd)
fingers_crossed=subprocess.Popen(mesh_cmd,stdout=subprocess.PIPE,bufsize=0)
while True:
line = fingers_crossed.stdout.readline()
diff --git a/src/O4_Tile_Utils.py b/src/O4_Tile_Utils.py
index 036430e..d6e5044 100755
--- a/src/O4_Tile_Utils.py
+++ b/src/O4_Tile_Utils.py
@@ -75,6 +75,7 @@ def build_tile(tile):
UI.lvprint(0,"ERROR: Cannot create tile subdirectories.")
UI.vprint(3,e)
UI.exit_message_and_bottom_line('')
+ # :(
return 0
download_queue=queue.Queue()