diff --git a/plz_draw b/plz_draw index 90e33ad..1ab6ad9 100755 --- a/plz_draw +++ b/plz_draw @@ -219,7 +219,9 @@ def draw_voronoi(ctx, geoitems, options): plzlines = {} for (l, p1, p2) in edges: - x1 = y1 = x2 = y2 = None + # l ist der Index der Original Daten in lines[] + # p1 und p2 sind der Index der Endpunkte in points[p2] + x1 = y1 = x2 = y2 = None # Endpunkte der zu zeichnenen Linie a, b, c, plz1, plz2 = lines[l] if p1 > -1: x1, y1 = points[p1] diff --git a/pygeodb/voronoi.py b/pygeodb/voronoi.py index e5a849c..41e542f 100644 --- a/pygeodb/voronoi.py +++ b/pygeodb/voronoi.py @@ -102,7 +102,7 @@ def usage(): import math import sys import getopt -TOLERANCE = 1e-9 +TOLERANCE = 1e-15 BIG_FLOAT = 1e38 #------------------------------------------------------------------ @@ -405,11 +405,15 @@ def bisect(s1, s2): newedge.a = 1.0 newedge.b = dy/dx newedge.c /= dx - else: + elif dy: # set formula of line, with y fixed to 1 newedge.b = 1.0 - newedge.a = dx/(dy+0.000001) - newedge.c /= (dy+0.000001) + newedge.a = dx/dy + newedge.c /= dy + else: + newedge.b = 1.0 + newedge.a = dx/(dy+0.0000001) + newedge.c /= (dy+0.0000001) newedge.edgenum = Edge.EDGE_NUM Edge.EDGE_NUM += 1