oscarpilote / Ortho4XP

A scenery generator for the X-Plane flight simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

White squares at high resolution; ZL19

Matt-Cummins opened this issue · comments

168336_252176_BI19

As seen in the attached image.

Used GPT4 to hopefully correct the file O4_Imagery_Utils adding the following;

###############################################################################################################################
# Additional logic for identifying and redownloading white areas missing_areas = identify_white_boxes(big_image) for area in missing_areas: new_area = attempt_redownload(area) if new_area: merge_areas(big_image, new_area, area) # Rest of your existing saving logic # ...# Additional functions like identify_white_boxes, download_specific_area, is_valid, merge_areas# would need to be implemented.
###############################################################################################################################
def build_jpeg_ortho(tile, til_x_left,til_y_top,zoomlevel,provider_code,out_file_name=''):
texture_attributes=(til_x_left,til_y_top,zoomlevel,provider_code)
if provider_code in local_combined_providers_dict:
data_found=False
for rlayer in local_combined_providers_dict[provider_code]:
(y0,x0)=GEO.gtile_to_wgs84(til_x_left,til_y_top,zoomlevel)
(y1,x1)=GEO.gtile_to_wgs84(til_x_left+16,til_y_top+16,zoomlevel)
if len(local_combined_providers_dict[provider_code])==1 or has_data((x0,y0,x1,y1),rlayer['extent_code'],is_mask_layer= (tile.lat,tile.lon, tile.mask_zl) if rlayer['priority']=='mask' else False):
data_found=True
true_til_x_left=til_x_left
true_til_y_top=til_y_top
true_zl=zoomlevel
if 'max_zl' in providers_dict[rlayer['layer_code']]:
max_zl=int(providers_dict[rlayer['layer_code']]['max_zl'])
if max_zl<zoomlevel:
(latmed,lonmed)=GEO.gtile_to_wgs84(til_x_left+8,til_y_top+8,zoomlevel)
(true_til_x_left,true_til_y_top)=GEO.wgs84_to_orthogrid(latmed,lonmed,max_zl)
true_zl=max_zl
true_texture_attributes=(true_til_x_left,true_til_y_top,true_zl,rlayer['layer_code'])
true_file_name=FNAMES.jpeg_file_name_from_attributes(true_til_x_left, true_til_y_top, true_zl,rlayer['layer_code'])
true_file_dir=FNAMES.jpeg_file_dir_from_attributes(tile.lat, tile.lon,true_zl,providers_dict[rlayer['layer_code']])
if not os.path.isfile(os.path.join(true_file_dir,true_file_name)):
UI.vprint(1," Downloading missing orthophoto "+true_file_name+" (for combining in "+provider_code+")")
if not download_jpeg_ortho(true_file_dir,true_file_name,*true_texture_attributes):
return 0
else:
UI.vprint(1," The orthophoto "+true_file_name+" (for combining in "+provider_code+") is already present.")
if not data_found:
UI.lvprint(1," -> !!! Warning : No data found for building the combined texture",
FNAMES.dds_file_name_from_attributes(*texture_attributes)," !!!")
return 0
if out_file_name:
big_img=combine_textures(tile,til_x_left,til_y_top,zoomlevel,provider_code)
big_img.convert('RGB').save(out_file_name)
elif provider_code in providers_dict: # In case one would like to save combined orthos as jpegs (this can be useful to use different masks parameters for imagery masks layers and actual masks
file_name=FNAMES.jpeg_file_name_from_attributes(til_x_left, til_y_top, zoomlevel,provider_code)
file_dir=FNAMES.jpeg_file_dir_from_attributes(tile.lat, tile.lon,zoomlevel,providers_dict[provider_code])
big_img=combine_textures(tile,til_x_left,til_y_top,zoomlevel,provider_code)
if not os.path.exists(file_dir):
os.makedirs(file_dir)
try:
big_img.convert('RGB').save(os.path.join(file_dir,file_name))
except Exception as e:
UI.lvprint(0,"OS Error : could not save orthophoto on disk, received message :",e)
return 0
elif provider_code in providers_dict:
file_name=FNAMES.jpeg_file_name_from_attributes(til_x_left, til_y_top, zoomlevel,provider_code)
file_dir=FNAMES.jpeg_file_dir_from_attributes(tile.lat, tile.lon,zoomlevel,providers_dict[provider_code])
if not os.path.isfile(os.path.join(file_dir,file_name)):
UI.vprint(1," Downloading missing orthophoto "+file_name)
if not download_jpeg_ortho(file_dir,file_name,*texture_attributes):
return 0
else:
UI.vprint(1," The orthophoto "+file_name+" is already present.")
else:
(tlat,tlon)=GEO.gtile_to_wgs84(til_x_left+8,til_y_top+8,zoomlevel)
UI.vprint(1," Unknown provider",provider_code,"or it has no data around",tlat,tlon,".")
return 0
return 1

Seems to work thus far but I'm shooting in the dark essentially, I'm not a coder, just a hobbtist.

There are already config options to deal with network issues, maybe I shouldn't but I will trust favor them over GPT4.