Skip to content

Commit

Permalink
Slight changes in preparation of the release
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarpilote committed May 29, 2018
1 parent 3e65ef0 commit a7ae212
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 67 deletions.
Binary file renamed Utils/Triangle4XP_v130 → Utils/Triangle4XP
Binary file not shown.
Binary file added Utils/Triangle4XP.app
Binary file not shown.
17 changes: 8 additions & 9 deletions Utils/Triangle4XP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,9 @@ int minus1mod3[3] = {2, 0, 1};
/* Modified for Triangle4XP */
/* * (int *) ((osub).ss + 8) = value */
#define setmark(osub, value) \
* (int *) ((osub).ss + 8) = (value | (* (int *) ((osub).ss+8)))
* (int *) ((osub).ss + 8) = value
#define updatemark(osub, value) \
* (int *) ((osub).ss + 8) = (value | (* (int *) ((osub).ss+8)))
/* End of Modified for Triangle4XP */


Expand Down Expand Up @@ -8044,7 +8046,7 @@ int subsegmark; /* Marker for the new subsegment. */
} else {
/* Modified for Triangle4XP */
/* if (mark(newsubseg) == 0) {*/
setmark(newsubseg, subsegmark);
updatemark(newsubseg, subsegmark);
/* End of Modified for Triangle4XP */
/*} */
}
Expand Down Expand Up @@ -13138,11 +13140,11 @@ REAL area;
/* We wish to traverse any segment whose corresponding bit (each */
/* bit corresponds to a regional attribute) is zero. */
if ((neighbor.tri != m->dummytri) && !infected(neighbor)
&& ((neighborsubseg.ss == m->dummysub)| !(mark(neighborsubseg) & (int)(attribute+0.1)))) {
&& ((neighborsubseg.ss == m->dummysub)| !(mark(neighborsubseg) & (int)(attribute+0.1)))) {
/* End of : Added for Triangle4XP */
/*printf("%i",(int)(attribute+0.5));
fflush(stdout);*/
if (b->verbose > 2) {
/*printf("%i",(int)(attribute+0.5));
fflush(stdout);*/
if (b->verbose > 2) {
org(neighbor, regionorg);
dest(neighbor, regiondest);
apex(neighbor, regionapex);
Expand Down Expand Up @@ -16093,9 +16095,6 @@ char **argv;
readnodes(&m, &b, b.innodefilename, b.inpolyfilename, &polyfile);
#endif /* not TRILIBRARY */

/* HACK */
/*writenodes(&m, &b, b.outnodefilename, argc, argv);*/
/*triexit(1);*/

#ifndef NO_TIMER
if (!b.quiet) {
Expand Down
Binary file not shown.
Binary file removed Utils/Triangle4XP_v130.app
Binary file not shown.
47 changes: 24 additions & 23 deletions src/O4_Airport_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import O4_DEM_Utils as DEM
import O4_File_Names as FNAMES

runway_chunks=50
runway_chunks=100 # how much chunks to split a runway longitudinally, ...
chunk_min_size=10 # as long as the chunks do not get smaller than this (in meters) .

def discover_airport_names(airport_layer,dico_airports):
for osmtype in ('r','w','n'):
Expand Down Expand Up @@ -381,7 +382,7 @@ def smooth_raster_over_airports(tile,dico_airports,preserve_boundary=True):

####################################################################################################
def encode_runways_taxiways_and_aprons(tile,airport_layer,dico_airports,vector_map,patches_list):
seeds=[]
seeds={'RUNWAY':[],'TAXIWAY':[],'APRON':[]}
total_rwy=0
total_taxi=0
for airport in dico_airports:
Expand Down Expand Up @@ -420,30 +421,29 @@ def encode_runways_taxiways_and_aprons(tile,airport_layer,dico_airports,vector_m
## First runways
for (runway_pol,runway_start,runway_end,runway_width) in apt['runway'][1]+apt['runway'][2]:
runway_length=VECT.length_in_meters(numpy.vstack((runway_start,runway_end)))
refine_size=max(runway_length//runway_chunks,7)
refine_size=max(runway_length//runway_chunks,chunk_min_size)
for pol in VECT.ensure_MultiPolygon(VECT.cut_to_tile(runway_pol)):
#way=numpy.round(VECT.refine_way(numpy.array(pol.exterior.coords),refine_size),7)
way=numpy.round(VECT.refine_way(numpy.array(pol.exterior.coords),15),7)
#way=numpy.round(numpy.array(pol.exterior.coords),7)
way=numpy.round(VECT.refine_way(numpy.array(pol.exterior.coords),refine_size),7)
alti_way=numpy.array([VECT.weighted_alt(node,alt_idx,alt_dico,tile.dem) for node in way]).reshape((len(way),1))
vector_map.insert_way(numpy.hstack([way,alti_way]),'RUNWAY',check=True)
pols.append(pol)
for pol in pols:
for subpol in VECT.ensure_MultiPolygon(pol.difference(ops.cascaded_union([pol2 for pol2 in pols if pol2!=pol]))):
seeds.append(numpy.array(subpol.representative_point()))
seeds['RUNWAY'].append(numpy.array(subpol.representative_point()))
for subpol in VECT.ensure_MultiPolygon(pol.intersection(ops.cascaded_union([pol2 for pol2 in pols if pol2!=pol]))):
seeds.append(numpy.array(subpol.representative_point()))
seeds['RUNWAY'].append(numpy.array(subpol.representative_point()))
## Then taxiways
cleaned_taxiway_area=VECT.improved_buffer(apt['taxiway'][0].difference(VECT.improved_buffer(apt['runway'][0].union(apt['hangar']),20,0,0)),5,3,1)
#cleaned_taxiway_area=VECT.improved_buffer(apt['taxiway'][0].difference(VECT.improved_buffer(apt['runway'][0],10,0,0).union(VECT.improved_buffer(apt['hangar'],20,0,0))),5,3,1)
cleaned_taxiway_area=VECT.improved_buffer(apt['taxiway'][0].difference(VECT.improved_buffer(apt['hangar'],20,0,0)),0,0,0.5)
for pol in VECT.ensure_MultiPolygon(VECT.cut_to_tile(cleaned_taxiway_area)):
way=numpy.round(VECT.refine_way(numpy.array(pol.exterior),20),7)
alti_way=numpy.array([VECT.weighted_alt(node,alt_idx,alt_dico,tile.dem) for node in way]).reshape((len(way),1))
vector_map.insert_way(numpy.hstack([way,alti_way]),'RUNWAY',check=True)
vector_map.insert_way(numpy.hstack([way,alti_way]),'TAXIWAY',check=True)
for subpol in pol.interiors:
way=numpy.round(VECT.refine_way(numpy.array(subpol),20),7)
alti_way=numpy.array([VECT.weighted_alt(node,alt_idx,alt_dico,tile.dem) for node in way]).reshape((len(way),1))
vector_map.insert_way(numpy.hstack([way,alti_way]),'RUNWAY',check=True)
seeds.append(numpy.array(pol.representative_point()))
vector_map.insert_way(numpy.hstack([way,alti_way]),'TAXIWAY',check=True)
seeds['TAXIWAY'].append(numpy.array(pol.representative_point()))
## Try to bring some aprons with, we are looking for the small ones along runways
for wayid in apt['apron'][1]:
if wayid not in airport_layer.dicosmtags['w'] or 'include' not in airport_layer.dicosmtags['w'][wayid]: continue
Expand All @@ -453,15 +453,16 @@ def encode_runways_taxiways_and_aprons(tile,airport_layer,dico_airports,vector_m
apron_pol=geometry.Polygon(way)
if not apron_pol.is_empty and runway_pol.is_valid:
alti_way=numpy.array([VECT.weighted_alt(node,alt_idx,alt_dico,tile.dem) for node in way]).reshape((len(way),1))
vector_map.insert_way(numpy.hstack([way,alti_way]),'RUNWAY',check=True)
seeds.append(numpy.array(apron_pol.representative_point()))
vector_map.insert_way(numpy.hstack([way,alti_way]),'APRON',check=True)
seeds['APRON'].append(numpy.array(apron_pol.representative_point()))
except:
pass
if seeds:
if 'RUNWAY' in vector_map.seeds:
vector_map.seeds['RUNWAY']+=seeds
else:
vector_map.seeds['RUNWAY']=seeds
for surface in ('RUNWAY','TAXIWAY','APRON'):
if seeds[surface]:
if surface in vector_map.seeds:
vector_map.seeds[surface]+=seeds[surface]
else:
vector_map.seeds[surface]=seeds[surface]
plural_rwy='s' if total_rwy>1 else ''
plural_taxi='s' if total_taxi>1 else ''
UI.vprint(1," Auto-patched",total_rwy,"runway"+plural_rwy+" and",total_taxi,"piece"+plural_taxi+" of taxiway.")
Expand All @@ -478,13 +479,13 @@ def encode_hangars(tile,dico_airports,vector_map,patches_list):
for pol in VECT.ensure_MultiPolygon(VECT.cut_to_tile(dico_airports[airport]['hangar'])):
way=numpy.array(pol.exterior.coords)
alti_way=numpy.ones((len(way),1))*numpy.min(tile.dem.alt_vec(way))
vector_map.insert_way(numpy.hstack([way,alti_way]),'INTERP_ALT',check=True)
vector_map.insert_way(numpy.hstack([way,alti_way]),'HANGAR',check=True)
seeds.append(numpy.array(pol.representative_point()))
if seeds:
if 'INTERP_ALT' in vector_map.seeds:
vector_map.seeds['INTERP_ALT']+=seeds
if 'HANGAR' in vector_map.seeds:
vector_map.seeds['HANGAR']+=seeds
else:
vector_map.seeds['INTERP_ALT']=seeds
vector_map.seeds['HANGAR']=seeds
return 1
####################################################################################################

Expand Down
22 changes: 17 additions & 5 deletions src/O4_Config_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'custom_scenery_dir': {'type':str,'default':'','hint':'Your X-Plane Custom Scenery. Used only for "1-click" creation (or deletion) of symbolic links from Ortho4XP tiles to there.'},
'custom_overlay_src': {'module':'OVL','type':str,'default':'','hint':'The directory containing the sceneries with the overlays you would like to extract. You need to select the level of directory just _ABOVE_ Earth nav data.'},
# Vector
'apt_smoothing_pix': {'type':int, 'default':8,'hint':"How much gaussian blur is applied to the elevation raster for the look up of altitude over airports. Unit is the evelation raster pixel size."},
'road_level': {'type':int,'default':1,'values':[0,1,2,3,4,5],'hint':'Allows to level the mesh along roads and railways. Zero means nothing such is included; "1" looks for banking ways among motorways, primary and secondary roads and railway tracks; "2" adds tertiary roads; "3" brings residential and unclassified roads; "4" takes service roads, and 5 finishes with tracks. Purge the small_roads.osm cached data if you change your mind in between the levels 2-5.'},
'road_banking_limit': {'type':float,'default':0.5,'hint':"How much sloped does a roads need to be to be in order to be included in the mesh levelling process. The value is in meters, measuring the height difference between a point in the center of a road node and its closest point on the side of the road."},
'lane_width': {'type':float,'default':5,'hint':"With (in meters) to be used for buffering that part of the road network that requires levelling."},
Expand All @@ -48,7 +49,6 @@
'limit_tris' : {'type':int, 'default':0,'hint':"If non zero, upper bound on the number of final triangles in the mesh."},
'hmin': {'type':float,'default':0,'hint':"The mesh algorithm will not try to subdivide triangles whose shortest edge is already smaller than hmin (in meters). If hmin is smaller than half of the levation data step size, it will default to it anyhow (its default zero value thus means : as good as the DEM can do)."},
'min_angle': {'type':float,'default':10,'hint':"The mesh algorithm will try to not have mesh triangles with second smallest angle less than the value (in deg) of min_angle (prior to v1.3 it was the smallest, not second smallest) The goal behind this is to avoid potential artifacts when a triangle vertex is very close the the middle of its facing edge."},
'apt_smoothing_pix': {'type':int, 'default':8,'hint':"How much gaussian blur is applied to the elevation raster for the look up of altitude over airports. Unit is the evelation raster pixel size."},
'sea_smoothing_mode': {'type':str, 'default':'zero','values':['zero','mean','none'],'hint':"Zero means that all nodes of sea triangles are set to zero elevation. With mean, some kind of smoothing occurs (triangles are levelled one at a time to their mean elevation), None (a value mostly appropriate for DEM resolution of 10m and less), positive altitudes of sea nodes are kept intact, only negative ones are brought back to zero, this avoids to create unrealistic vertical cliffs if the coastline vector data was lower res."},
'water_smoothing': {'type':int, 'default':10,'hint':"Number of smoothing passes over all inland water triangles (sequentially set to their mean elevation)."},
'iterate': {'type':int, 'default':0,'hint':"Allows to refine a mesh using higher resolution elevation data of local scope only (requires Gdal), typically LIDAR data. Having an iterate number is handy to go backward one step when some choice of parameters needs to be revised. REQUIRES cleaning_level=0."},
Expand Down Expand Up @@ -85,8 +85,8 @@
gui_app_vars_short=list_app_vars[:-2]
gui_app_vars_long=list_app_vars[-2:]

list_vector_vars=['road_level','road_banking_limit','lane_width','max_levelled_segs','water_simplification','min_area','max_area','clean_bad_geometries','mesh_zl']
list_mesh_vars=['curvature_tol','apt_curv_tol','apt_curv_ext','coast_curv_tol','coast_curv_ext','limit_tris','hmin','min_angle','apt_smoothing_pix','sea_smoothing_mode','water_smoothing','iterate']
list_vector_vars=['apt_smoothing_pix','road_level','road_banking_limit','lane_width','max_levelled_segs','water_simplification','min_area','max_area','clean_bad_geometries','mesh_zl']
list_mesh_vars=['curvature_tol','apt_curv_tol','apt_curv_ext','coast_curv_tol','coast_curv_ext','limit_tris','hmin','min_angle','sea_smoothing_mode','water_smoothing','iterate']
list_mask_vars=['mask_zl','masks_width','masking_mode','use_masks_for_inland','masks_use_DEM_too','masks_custom_extent']
list_dsf_vars=['cover_airports_with_highres','cover_extent','cover_zl','ratio_water','overlay_lod','sea_texture_blur','add_low_res_sea_ovl','experimental_water','normal_map_strength','terrain_casts_shadows','use_decal_on_terrain']
list_other_vars=['custom_dem','fill_nodata']
Expand Down Expand Up @@ -176,8 +176,15 @@ def read_from_config(self,config_file=None):
cmd="self."+var+"=cfg_vars['"+var+"']['type'](value)"
exec(cmd)
except Exception as e:
UI.vprint(2,e)
pass
# compatibility with zone_list config files from version <= 1.20
if "zone_list.append" in line:
try:
exec("self."+line)
except:
pass
else:
UI.vprint(2,e)
pass
f.close()
return 1
except:
Expand All @@ -188,6 +195,11 @@ def read_from_config(self,config_file=None):
def write_to_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")
config_file_bak=config_file+".bak"
try:
os.replace(config_file,config_file_bak)
except:
pass
try:
f=open(config_file,'w')
for var in list_tile_vars:
Expand Down
4 changes: 2 additions & 2 deletions src/O4_DEM_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ def load_data(self,source,info_only=False):


def nodata_to_zero(self):
if self.nodata!=0 and (self.alt_dem==self.nodata).any():
if (self.alt_dem==self.nodata).any():
UI.vprint(1," INFO: Replacing nodata nodes with zero altitude.")
self.alt_dem[self.alt_dem==self.nodata]=0
self.nodata=0
self.nodata=-32768
return

def write_to_file(self,filename):
Expand Down
2 changes: 1 addition & 1 deletion src/O4_DSF_Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def build_dsf(tile,download_queue):
bary_lon=(node_coords[5*n1]+node_coords[5*n2]+node_coords[5*n3])/3
bary_lat=(node_coords[5*n1+1]+node_coords[5*n2+1]+node_coords[5*n3+1])/3
texture_attributes=dico_customzl[GEO.wgs84_to_orthogrid(bary_lat,bary_lon,tile.mesh_zl)]
# Triangles whith type>=8 are set for type=0, and type between 2 and 7 are set to 2 (mask)
# Triangles of mixed types are set for water in priority (to avoid water cut by solid roads), and others are set for type=0
tri_type = (tri_type & has_water) and (2*((tri_type & has_water)>1 or tile.use_masks_for_inland) or 1)
# The entries for the terrain and texture main dictionnaries
terrain_attributes=(texture_attributes,tri_type)
Expand Down
5 changes: 4 additions & 1 deletion src/O4_File_Names.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ def output_poly_file(tile):
def output_ele_file(tile):
return os.path.join(tile.build_dir,'Data'+short_latlon(tile.lat,tile.lon)+'.'+str(tile.iterate+1)+'.ele')
def alt_file(tile):
return os.path.join(tile.build_dir,'Data'+short_latlon(tile.lat,tile.lon)+'.alt')
if tile.iterate:
return os.path.join(tile.build_dir,'Data'+short_latlon(tile.lat,tile.lon)+'.'+str(tile.iterate)+'.alt')
else:
return os.path.join(tile.build_dir,'Data'+short_latlon(tile.lat,tile.lon)+'.alt')
def apt_file(tile):
return os.path.join(tile.build_dir,'Data'+short_latlon(tile.lat,tile.lon)+'.apt')
def weight_file(tile):
Expand Down
Loading

0 comments on commit a7ae212

Please sign in to comment.