Commit 64197a43 authored by Thomas Albrecht's avatar Thomas Albrecht

- catch exceptions in simplify and roll_inner_nodes

- new param CLUSTER_MIN_OBJECTS
parent 56e3a58a
......@@ -320,8 +320,12 @@ def analyse(buildings, static_objects, transform, elev, facades, roofs):
# - simplify
# - compute edge lengths
tools.stats.nodes_simplified += b.simplify(parameters.BUILDING_SIMPLIFY_TOLERANCE)
b.roll_inner_nodes()
try:
tools.stats.nodes_simplified += b.simplify(parameters.BUILDING_SIMPLIFY_TOLERANCE)
b.roll_inner_nodes()
except Exception, reason:
print "simplify or roll_inner_nodes failed (OSM ID %i, %s)" % (b.osm_id, reason)
continue
# -- array of local outer coordinates
Xo = np.array(b.X_outer)
......
......@@ -162,6 +162,7 @@ class Building(object):
#print ">> outer nodes", b.nnodes_outer
#print ">> inner nodes", len(b.X_inner)
nnodes_simplified = original_nodes - (self.nnodes_outer + len(self.X_inner))
# FIXME: simplifiy interiors
#print "now", simple_nodes
#print "--------------------"
return nnodes_simplified
......@@ -306,7 +307,7 @@ class wayExtract(object):
return False
self.buildings.append(Building(osm_id, tags, outer_ring, _name, _height, _levels, inner_rings_list = inner_rings_list))
tools.stats.objects += 1
if tools.stats.objects % 70 == 0: print tools.stats.objects
else: sys.stdout.write(".")
......@@ -316,7 +317,7 @@ class wayExtract(object):
for osm_id, tags, members in relations:
if tools.stats.objects >= parameters.MAX_OBJECTS:
return
if 'building' in tags:
outer_ways = []
inner_ways = []
......@@ -654,6 +655,13 @@ if __name__ == "__main__":
tools.stats.objects = len(buildings)
# -- debug filter
# for b in buildings:
# if b.osm_id == 35336:
# new_buildings = [b]
# break
# buildings = new_buildings
# -- create (empty) clusters
lmin = vec2d(tools.transform.toLocal(cmin))
lmax = vec2d(tools.transform.toLocal(cmax))
......@@ -710,7 +718,7 @@ if __name__ == "__main__":
for cl in clusters:
nb = len(cl.objects)
if nb < 5: continue # skip almost empty clusters
if nb < parameters.CLUSTER_MIN_OBJECTS: continue # skip almost empty clusters
# -- get cluster center
offset = cl.center
......
......@@ -86,9 +86,11 @@ OBSTRUCTION_LIGHT_MIN_LEVELS = 15 # -- put obstruction lights on buildings wit
EXPERIMENTAL_USE_SKEL = 0 # -- generate complex roofs with pySkeleton?
SKEL_MAX_NODES = 10 # -- max number of nodes for which we generate complex roofs
SKEL_MAX_HEIGHT_RATIO = 0.7 # --
SKEL_MAX_HEIGHT_RATIO = 0.7 # --
EXPERIMENTAL_INNER = 0
CLUSTER_MIN_OBJECTS = 5 # -- discard cluster if to little objects
def set_parameters(paramDict):
for k in paramDict:
if k in globals():
......
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