Commit bd957f8b authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

Getting Fgelev* working.

Replacing calls to deprecated logging.warn(
parent 64cbb4a3
......@@ -34,7 +34,7 @@ def _get_file_name(name, tile_name):
def _open_file(name, directory):
return open(directory + name, "wr")
return open(directory + name, "w")
def _write_to_file(command, file_handle, python_exe, params_out):
......
......@@ -347,7 +347,7 @@ def _compute_roof_height(b, max_height=1e99):
break
angle -= 5
if roof_height > max_height:
logging.warn("roof too high %g > %g" % (roof_height, max_height))
logging.warning("roof too high %g > %g" % (roof_height, max_height))
return False
b.roof_height = roof_height
......@@ -426,7 +426,7 @@ def analyse(buildings, static_objects, transform, elev, facades, roofs):
tools.stats.nodes_simplified += b.simplify(parameters.BUILDING_SIMPLIFY_TOLERANCE)
b.roll_inner_nodes()
except Exception as reason:
logging.warn("simplify or roll_inner_nodes failed (OSM ID %i, %s)", b.osm_id, reason)
logging.warning("simplify or roll_inner_nodes failed (OSM ID %i, %s)", b.osm_id, reason)
continue
# -- array of local outer coordinates
......@@ -712,7 +712,7 @@ def analyse(buildings, static_objects, transform, elev, facades, roofs):
b.roof_texture = roofs.find_matching(roof_requires)
if not b.roof_texture:
tools.stats.skipped_texture += 1
logging.warn("WARNING: no matching roof texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
logging.warning("WARNING: no matching roof texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
continue
else:
# 1 - Check if building and building parent infos are the same
......@@ -768,7 +768,7 @@ def analyse(buildings, static_objects, transform, elev, facades, roofs):
b.roof_texture = roofs.find_matching(roof_requires)
if not b.roof_texture:
tools.stats.skipped_texture += 1
logging.warn("WARNING: no matching texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
logging.warning("WARNING: no matching texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
continue
b.parent.roof_texture = b.roof_texture
else:
......@@ -777,7 +777,7 @@ def analyse(buildings, static_objects, transform, elev, facades, roofs):
b.roof_texture = roofs.find_matching(roof_requires)
if not b.roof_texture:
tools.stats.skipped_texture += 1
logging.warn("WARNING: no matching roof texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
logging.warning("WARNING: no matching roof texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
continue
if b.roof_texture:
......@@ -785,7 +785,7 @@ def analyse(buildings, static_objects, transform, elev, facades, roofs):
else:
tools.stats.skipped_texture += 1
logging.warn("WARNING: no matching roof texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
logging.warning("WARNING: no matching roof texture for OsmID %d <%s>" % (b.osm_id, str(roof_requires)))
continue
# -- finally: append building to new list
......
......@@ -95,7 +95,7 @@ def myskel(out, b, name = "roof", offset_xy = vec2d(0, 0), offset_z = 0., header
#We'll just flatten the roof then instead of loosing it
angle = angle - 5
if roof_height > max_height:
logging.warn("roof too high %g > %g" % (roof_height, max_height))
logging.warning("roof too high %g > %g" % (roof_height, max_height))
return False
result = roof_mesh.to_out(out, b, offset_xy, offset_z, header)
......
......@@ -685,7 +685,7 @@ if __name__ == "__main__":
osm_fname = parameters.PREFIX + os.sep + parameters.OSM_FILE
if parameters.USE_PKL and not os.path.exists(pkl_fname):
logging.warn("pkl file %s not found, will parse OSM file %s instead." % (pkl_fname, osm_fname))
logging.warning("pkl file %s not found, will parse OSM file %s instead." % (pkl_fname, osm_fname))
parameters.USE_PKL = False
if not parameters.USE_PKL:
......@@ -876,9 +876,9 @@ if __name__ == "__main__":
logging.verbose(" cand %i doesn't contains %i" % (cand_building.osm_id, building.osm_id))
except shgs.TopologicalError as reason:
logging.warn("Error while checking for intersection %s. This might lead to double buildings ID1 : %d ID2 : %d " % (reason, building.osm_id, cand_building.osm_id))
logging.warning("Error while checking for intersection %s. This might lead to double buildings ID1 : %d ID2 : %d " % (reason, building.osm_id, cand_building.osm_id))
except shgs.PredicateError as reason:
logging.warn("Error while checking for intersection %s. This might lead to double buildings ID1 : %d ID2 : %d " % (reason, building.osm_id, cand_building.osm_id))
logging.warning("Error while checking for intersection %s. This might lead to double buildings ID1 : %d ID2 : %d " % (reason, building.osm_id, cand_building.osm_id))
return False
......
......@@ -40,7 +40,7 @@ class Platform(object):
self.logger = logging.getLogger("platforms")
if 'layer' in tags:
self.logger.warn("layer %s %d", tags['layer'], osm_id)
self.logger.warning("layer %s %d", tags['layer'], osm_id)
self.osm_nodes = list()
for r in refs: # safe way instead of [nodes_dict[r] for r in refs] if ref would be missing
......
......@@ -628,7 +628,7 @@ class Roads(objectlist.ObjectList):
else:
self.roads_list.append(obj)
except ValueError as reason:
logging.warn("skipping OSM_ID %i: %s" % (the_way.osm_id, reason))
logging.warning("skipping OSM_ID %i: %s" % (the_way.osm_id, reason))
continue
self.G.add_edge(obj)
......@@ -858,7 +858,7 @@ class Roads(objectlist.ObjectList):
"""
logging.debug("Joining %i and %i", way1.osm_id, way2.osm_id)
if way1.osm_id == way2.osm_id:
logging.warn("Not joining way %i with itself", way1.osm_id)
logging.warning("Not joining way %i with itself", way1.osm_id)
return
if way1.refs[0] == way2.refs[0]:
new_refs = way1.refs[::-1] + way2.refs[1:]
......@@ -869,7 +869,7 @@ class Roads(objectlist.ObjectList):
elif way1.refs[-1] == way2.refs[-1]:
new_refs = way1.refs[:-1] + way2.refs[::-1]
else:
logging.warn("Not joining ways that share no endpoint %i %i", way1.osm_id, way2.osm_id)
logging.warning("Not joining ways that share no endpoint %i %i", way1.osm_id, way2.osm_id)
return
new_way = _init_way_from_existing(way1, new_refs)
......
......@@ -367,7 +367,7 @@ def separate_skillion(out, b, X, inward_meters = 0., max_height = 1e99):
break
angle = angle - 5
if roof_height > max_height:
logging.warn("roof too high %g > %g" % (roof_height, max_height))
logging.warning("roof too high %g > %g" % (roof_height, max_height))
return False
#We don't want the hipped part to be greater than the height, which is 45 deg
......
......@@ -17,7 +17,7 @@ import tools
# return "%s %s %g %g %g %g" % (self.typ, self.path, self.lon, self.lat, self.alt, self.hdg)
DEPRECATED_MESSAGE = "stg_io.py is deprecated. Please consider porting to stg_io2.py"
logging.warn(DEPRECATED_MESSAGE)
logging.warning(DEPRECATED_MESSAGE)
def read(path, stg_fname, our_magic):
......
......@@ -226,7 +226,7 @@ class MyFrame(wx.Frame):
try:
shutil.copyfile(self.in_file_name, dst)
except OSError as reason:
logging.warn("Error while copying %s to %s: %s" % (self.in_file_name, dst, reason))
logging.warning("Error while copying %s to %s: %s" % (self.in_file_name, dst, reason))
print(s)
......
......@@ -333,7 +333,7 @@ class FacadeManager(TextureManager):
exclusions.append("%s:%s" % ('roof:colour', tags['roof:colour']))
candidates = self.find_candidates(requires, exclusions, height, width)
if len(candidates) == 0:
logging.warn("no matching facade texture for %1.f m x %1.1f m <%s>", height, width, str(requires))
logging.warning("no matching facade texture for %1.f m x %1.1f m <%s>", height, width, str(requires))
return None
ranked_list = self.rank_candidates(candidates, tags)
the_texture = ranked_list[random.randint(0, len(ranked_list) - 1)]
......
......@@ -220,10 +220,10 @@ class Probe_fgelev(object):
fpickle.close()
logging.info("OK")
except IOError as reason:
logging.warn("Loading elev cache failed (%s)", reason)
logging.warning("Loading elev cache failed (%s)", reason)
self._cache = {}
except EOFError as reason:
logging.warn("Loading elev cache failed (%s)", reason)
logging.warning("Loading elev cache failed (%s)", reason)
self._cache = {}
else:
self._cache = None
......@@ -234,11 +234,8 @@ class Probe_fgelev(object):
fgelev_cmd = path_to_fgelev + ' --expire 1000000 --fg-scenery ' + parameters.PATH_TO_SCENERY
logging.info("cmd line: " + fgelev_cmd)
self.fgelev_pipe = subprocess.Popen(fgelev_cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
# -- This should catch spawn errors, but it doesn't. We
# check for sane return values on fgelev calls later.
# if self.fgelev_pipe.poll() != 0:
# raise RuntimeError("Spawning fgelev failed.")
self.fgelev_pipe = subprocess.Popen(fgelev_cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
bufsize=1, universal_newlines=True)
def save_cache(self):
"""save cache to disk"""
......@@ -467,8 +464,9 @@ def _raster_fgelev(transform, fname, x0, y0, size_x=1000, size_y=1000, step_x=5,
fg_elev_path = parameters.FG_ELEV
fgelev = subprocess.Popen(fg_elev_path + ' --expire 1000000 --fg-scenery ' + parameters.PATH_TO_SCENERY
, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
fgelev = subprocess.Popen(fg_elev_path + ' --expire 1000000 --fg-scenery ' + parameters.PATH_TO_SCENERY,
shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
bufsize=1, universal_newlines=True)
buf_in = queue.Queue(maxsize=0)
f = open(fname, 'w')
......@@ -496,13 +494,10 @@ def _raster_fgelev(transform, fname, x0, y0, size_x=1000, size_y=1000, step_x=5,
if not buf_in.empty():
line = buf_in.get()
logging.debug(line)
encoded = line.encode()
fgelev.stdin.write(encoded)
fgelev.stdin.write(line)
tmp, elev = fgelev.stdout.readline().split()
lon, lat = transform.toGlobal((x, y))
# f.write("%i " % i)
f.write("%1.8f %1.8f %g %g %g\n" % (lon, lat, x, y, float(elev)))
# if i > 10000: return
f.write("\n")
logging.info("done %i %3.1f %%\r", i, i*100/n_total)
......@@ -783,9 +778,9 @@ def install_files(file_list, dst, from_osm2city_root=False):
shutil.copy2(my_file, the_dst)
except OSError as reason:
if reason.errno not in [17]:
logging.warn("Error while installing %s: %s" % (the_file, reason))
logging.warning("Error while installing %s: %s" % (the_file, reason))
except (AttributeError, shutil.Error) as e:
logging.warn("Error while installing %s: %s" % (the_file, repr(e)))
logging.warning("Error while installing %s: %s" % (the_file, repr(e)))
def get_interpolator(**kwargs):
......
......@@ -52,7 +52,7 @@ def troubleshoot(stats):
msg += t.skipped_no_texture()
if t.n_problems > 0:
logging.warn("We've detected %i problem(s):\n\n%s" % (t.n_problems, msg))
logging.warning("We've detected %i problem(s):\n\n%s" % (t.n_problems, msg))
if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment