Skip to content

Commit

Permalink
Added possibility to guess custom zl zones from existing textures dir…
Browse files Browse the repository at this point in the history
…ectory
  • Loading branch information
oscarpilote committed Oct 12, 2018
1 parent 153e7c3 commit 71e62d5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Ortho4XP.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
verbosity=1
cleaning_level=1
overpass_server_choice=random
overpass_server_choice=DE
skip_downloads=False
skip_converts=False
max_convert_slots=4
Expand Down Expand Up @@ -31,7 +31,7 @@ apt_smoothing_pix=8
sea_smoothing_mode=zero
water_smoothing=10
iterate=0
mask_zl=15
mask_zl=14
masks_width=100
masking_mode=sand
use_masks_for_inland=False
Expand Down
2 changes: 1 addition & 1 deletion src/O4_Config_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
'default_website': {'type':str,'default':'','hint':''},
'default_zl': {'type':int,'default':16,'hint':''},
'zone_list': {'type':list,'default':[],'hint':''},
'cover_airports_with_highres':{'type':str,'default':'False','values':['False','True','ICAO'],'hint':'When set, textures above airports will be upgraded to a higher zoomlevel, the imagery being the same as the one they would otherwise receive. Can be limited to airports with an ICAO code for tiles with so many airports.','short_name':'high_zl_airports'},
'cover_airports_with_highres':{'type':str,'default':'False','values':['False','True','ICAO','Existing'],'hint':'When set, textures above airports will be upgraded to a higher zoomlevel, the imagery being the same as the one they would otherwise receive. Can be limited to airports with an ICAO code for tiles with so many airports. Exceptional: use "Existing" to (try to) derive custom zl zones from the textures directory of an existing tile.','short_name':'high_zl_airports'},
'cover_extent': {'type':float,'default':1,'hint':'The extent (in km) past the airport boundary taken into account for higher ZL. Note that for VRAM efficiency higher ZL textures are fully used on their whole extent as soon as part of them are needed.'},
'cover_zl': {'type':int,'default':18,'hint':'The zoomlevel with which to cover the airports zone when high_zl_airports is set. Note that if the cover_zl is lower than the zoomlevel which would otherwise be applied on a specific zone, the latter is used.'},
'sea_texture_blur': {'type':float,'default':0,'hint':'For layers of type "mask" in combined providers imageries, determines the extent (in meters) of the blur radius applied. This allows to smoothen some sea imageries where the wave or reflection pattern was too much present.'},
Expand Down
67 changes: 43 additions & 24 deletions src/O4_DSF_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,50 @@ def zone_list_to_ortho_dico(tile):
colmax=round(xmax*4095)
rowmax=round((1-ymin)*4095)
rowmin=round((1-ymax)*4095)
airport_array[rowmin:rowmax+1,colmin:colmax+1]=1
dico_tmp={}
dico_customzl={}
i=1
base_zone=((tile.lat,tile.lon,tile.lat,tile.lon+1,tile.lat+1,tile.lon+1,tile.lat+1,tile.lon,tile.lat,tile.lon),tile.default_zl,tile.default_website)
for region in [base_zone]+tile.zone_list[::-1]:
dico_tmp[i]=(region[1],region[2])
pol=[(round((x-tile.lon)*4095),round((tile.lat+1-y)*4095)) for (x,y) in zip(region[0][1::2],region[0][::2])]
masks_draw.polygon(pol,fill=i)
i+=1
airport_array[rowmin:rowmax+1,colmin:colmax+1]=1
dico_customzl={}
til_x_min,til_y_min=GEO.wgs84_to_orthogrid(tile.lat+1,tile.lon,tile.mesh_zl)
til_x_max,til_y_max=GEO.wgs84_to_orthogrid(tile.lat,tile.lon+1,tile.mesh_zl)
for til_x in range(til_x_min,til_x_max+1,16):
for til_y in range(til_y_min,til_y_max+1,16):
(latp,lonp)=GEO.gtile_to_wgs84(til_x+8,til_y+8,tile.mesh_zl)
lonp=max(min(lonp,tile.lon+1),tile.lon)
latp=max(min(latp,tile.lat+1),tile.lat)
x=round((lonp-tile.lon)*4095)
y=round((tile.lat+1-latp)*4095)
(zoomlevel,provider_code)=dico_tmp[masks_im.getpixel((x,y))]
if airport_array[y,x]:
zoomlevel=max(zoomlevel,tile.cover_zl)
til_x_text=16*(int(til_x/2**(tile.mesh_zl-zoomlevel))//16)
til_y_text=16*(int(til_y/2**(tile.mesh_zl-zoomlevel))//16)
dico_customzl[(til_x,til_y)]=(til_x_text,til_y_text,zoomlevel,provider_code)
til_x_max,til_y_max=GEO.wgs84_to_orthogrid(tile.lat,tile.lon+1,tile.mesh_zl)
if tile.cover_airports_with_highres=='Existing':
# first a base with default zl and default website
for til_x in range(til_x_min,til_x_max+1,16):
for til_y in range(til_y_min,til_y_max+1,16):
til_x_text=16*(int(til_x/2**(tile.mesh_zl-tile.default_zl))//16)
til_y_text=16*(int(til_y/2**(tile.mesh_zl-tile.default_zl))//16)
dico_customzl[(til_x,til_y)]=(til_x_text,til_y_text,tile.default_zl,tile.default_website)
# then what we find in the texture folder of the existing tile
for f in os.listdir(os.path.join(tile.build_dir,'textures')):
if f[-4:]!='.dds': continue
items=f.split('_')
(til_y_text,til_x_text)=[int(x) for x in items[:2]]
zoomlevel=int(items[-1][-6:-4])
provider_code='_'.join(items[2:])[:-6]
for til_x in range(til_x_text*2**(tile.mesh_zl-zoomlevel),(til_x_text+16)*2**(tile.mesh_zl-zoomlevel)):
for til_y in range(til_y_text*2**(tile.mesh_zl-zoomlevel),(til_y_text+16)*2**(tile.mesh_zl-zoomlevel)):
if ((til_x,til_y) not in dico_customzl) or dico_customzl[(til_x,til_y)][2]<=zoomlevel:
dico_customzl[(til_x,til_y)]=(til_x_text,til_y_text,zoomlevel,provider_code)
else:
dico_tmp={}
i=1
base_zone=((tile.lat,tile.lon,tile.lat,tile.lon+1,tile.lat+1,tile.lon+1,tile.lat+1,tile.lon,tile.lat,tile.lon),tile.default_zl,tile.default_website)
for region in [base_zone]+tile.zone_list[::-1]:
dico_tmp[i]=(region[1],region[2])
pol=[(round((x-tile.lon)*4095),round((tile.lat+1-y)*4095)) for (x,y) in zip(region[0][1::2],region[0][::2])]
masks_draw.polygon(pol,fill=i)
i+=1
for til_x in range(til_x_min,til_x_max+1,16):
for til_y in range(til_y_min,til_y_max+1,16):
(latp,lonp)=GEO.gtile_to_wgs84(til_x+8,til_y+8,tile.mesh_zl)
lonp=max(min(lonp,tile.lon+1),tile.lon)
latp=max(min(latp,tile.lat+1),tile.lat)
x=round((lonp-tile.lon)*4095)
y=round((tile.lat+1-latp)*4095)
(zoomlevel,provider_code)=dico_tmp[masks_im.getpixel((x,y))]
if airport_array[y,x]:
zoomlevel=max(zoomlevel,tile.cover_zl)
til_x_text=16*(int(til_x/2**(tile.mesh_zl-zoomlevel))//16)
til_y_text=16*(int(til_y/2**(tile.mesh_zl-zoomlevel))//16)
dico_customzl[(til_x,til_y)]=(til_x_text,til_y_text,zoomlevel,provider_code)
return dico_customzl
##############################################################################

Expand Down

0 comments on commit 71e62d5

Please sign in to comment.