def main(self): pts_segs = ToPointsAndSegments() pts_segs.add_polygon([[(0, 0), (10, 0), (5, 10), (0, 0)], [(0, 0), (8, 2), (6, 4), (5, 7), (0, 0)]], ) #pts_segs.add_polygon([[(10,0), (15,10), (5,10), (10,0)], #[(2,2), (8,2), (6,4), (5,7), (2,2)] #], #) dt = triangulate(pts_segs.points, pts_segs.infos, pts_segs.segments) with open("/tmp/all_tris.wkt", "w") as fh: output_triangles(dt.triangles, fh) with open("/tmp/path.wkt", "w") as fh: fh.write("i;group;depth;wkt\n") it = RegionatedTriangleIterator(dt) for i, (g, d, t) in enumerate(it, start=1): fh.write("{0};{1};{2};{3}\n".format(i, g, d, t)) with open("/tmp/later.wkt", "w") as fh: fh.write("wkt\n") for t in it.later: fh.write("{0}\n".format(t))
def test_T_capital_T(self): """Capital T, has more than one triangle in parallel fan """ # T ring = [(15.5055, 28.7004), (20.8063, 28.7004), (20.8063, 44.1211), (26.7445, 44.1211), (26.7445, 47.8328), (9.5668, 47.8328), (9.5668, 44.1211), (15.5055, 44.1211), (15.5055, 28.7004)] conv = ToPointsAndSegments() conv.add_polygon([ring]) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) # check the amount of segments in the skeleton assert len(skel.segments()) == 21, len(skel.segments()) # check the amount of skeleton nodes assert len(skel.sk_nodes) == 14, len(skel.sk_nodes) # check the amount of kinetic vertices that are (not) stopped not_stopped = filter(lambda v: v.stops_at is None, skel.vertices) stopped = filter(lambda v: v.stops_at is not None, skel.vertices) assert len(not_stopped) == 8, len(not_stopped) assert len(stopped) == 13, len(stopped) # check cross relationship between kinetic vertices and skeleton nodes for v in skel.vertices: assert at_same_location((v.start_node, v), v.starts_at) if v.stops_at is not None and not v.inf_fast: assert at_same_location((v.stop_node, v), v.stops_at), \ "{} {} {}".format(id(v), v.stop_node.pos, v.position_at(v.stops_at) )
def test_L_2(self): poly = [[(5, 0), (5, -1), (5, -2), (5, -3), (5, -4), (5, -5), (7, -5), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (11, 1), (5, 1), (5, 0)]] # convert to triangulation input conv = ToPointsAndSegments() conv.add_polygon(poly) # skeletonize / offset skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) # check the amount of segments in the skeleton assert len(skel.segments()) == 40, len(skel.segments()) # check the amount of skeleton nodes assert len(skel.sk_nodes) == 27, len(skel.sk_nodes) # check the amount of kinetic vertices that are (not) stopped assert len(filter(lambda v: v.stops_at is None, skel.vertices)) == 11 assert len(filter(lambda v: v.stops_at is not None, skel.vertices)) == 29 # check cross relationship between kinetic vertices and skeleton nodes for v in skel.vertices: assert at_same_location((v.start_node, v), v.starts_at) if v.stops_at is not None and not v.inf_fast: assert at_same_location((v.stop_node, v), v.stops_at), \ "{} {} {}".format(id(v), v.stop_node.pos, v.position_at(v.stops_at) )
def test_half_U(self): """Misses event, and has disconnected vertex""" polys = [ [(38.3852, 32.0156), (39.2659501953, 32.0912681641), (42.1678701172, 35.1549208984), (42.2309, 35.9922), (42.2309, 47.834), (47.5316, 47.834), (47.5316, 35.7273), (47.4732092773, 34.7657740479), (47.3213726562, 33.8784173828), (38.3852, 32.0156)], ] conv = ToPointsAndSegments() for ring in polys: conv.add_polygon([ring]) skel = calc_skel(conv, pause=True, output=True) #, pause=False, output=False)
def test_triangulate(): logging.basicConfig(level=logging.DEBUG) from tri.delaunay.helpers import ToPointsAndSegments # polygon = [ # [(256.0, 760.0), (518.0, 760.0), (518.0, 630.0), (674.0, 630.0), (674.0, 239.0), (673.0, 239.0), (127.0, 239.0), (127.0, 240.0), (126.0, 240.0), (126.0, 513.0), (127.0, 513.0), (127.0, 514.0), (126.0, 514.0), (126.0, 630.0), (255.0, 630.0), (256.0, 630.0), (256.0, 760.0)], # [(128.0, 629.0), (128.0, 423.0), (270.0, 423.0), (270.0, 422.0), (271.0, 422.0), (271.0, 240.0), (672.0, 240.0), (672.0, 629.0), (128.0, 629.0)], # [(258.0, 759.0), (258.0, 631.0), (516.0, 631.0), (516.0, 759.0), (258.0, 759.0)], # [(128.0, 421.0), (128.0, 240.0), (269.0, 240.0), (269.0, 421.0), (128.0, 421.0)] # ] ln = [(0, 0), (2, 0), (3, 0), (4, 15), (5, 0), (7, 0), (8, 15), (9, 0), (12, 0), (12, 50), (11, 50), (10, 35), (9, 50), (7, 50), (6, 35), (5, 50), (3, 50), (2, 35), (1, 50), (0, 50), (0, 0)] helper = ToPointsAndSegments() # helper.add_polygon(polygon) helper.add_linestring(ln) triangulate(helper.points, None, helper.segments, output=True)
def test_another_parallel3(self): j = """{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } }, "features": [ { "type": "Feature", "properties": { "id": 19 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.481125224325, 0.5 ], [ 0.288675134595, 0.5 ] ] } }, { "type": "Feature", "properties": { "id": 20 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.288675134595, 0.5 ], [ 0.19245008973, 0.666666666667 ] ] } }, { "type": "Feature", "properties": { "id": 24 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.19245008973, 0.666666666667 ], [ 0.288675134595, 0.833333333333 ] ] } }, { "type": "Feature", "properties": { "id": 44 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.57735026919, 0.666666666667 ], [ 0.481125224325, 0.5 ] ] } } ] }""" import json x = json.loads(j) # parse segments from geo-json segments = [] for y in x['features']: segments.append(tuple(map(tuple, y['geometry']['coordinates']))) # convert to triangulation input conv = ToPointsAndSegments() for line in segments: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) # skeletonize / offset skel = calc_skel(conv, pause=True, output=True)
def test_another_parallel1(self): j = """{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } }, "features": [ { "type": "Feature", "properties": { "id": 21 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.673575314055, 0.166666666667 ], [ 0.866025403784, 0.166666666667 ] ] } }, { "type": "Feature", "properties": { "id": 25 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.673575314055, -0.166666666667 ], [ 0.5, -0.0 ] ] } }, { "type": "Feature", "properties": { "id": 27 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.866025403784, -0.166666666667 ], [ 0.673575314055, -0.166666666667 ] ] } }, { "type": "Feature", "properties": { "id": 32 }, "geometry": { "type": "LineString", "coordinates": [ [ 0.5, -0.0 ], [ 0.673575314055, 0.166666666667 ] ] } } ] }""" import json x = json.loads(j) # parse segments from geo-json segments = [] for y in x['features']: segments.append(tuple(map(tuple, y['geometry']['coordinates']))) # convert to triangulation input conv = ToPointsAndSegments() for line in segments: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) # skeletonize / offset skel = calc_skel(conv, pause=True, output=True)
def test_cshape(self): """Parallel c-shape wavefront""" conv = ToPointsAndSegments() l0 = [(0.0, 0.0), (0.0, 3)] l1 = [(0, 3), (5, 3)] l2 = [(0, 0), (5, 0)] for line in l0, l1, l2: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=True, output=True) assert len(skel.segments()) == 10 assert len(skel.sk_nodes) == 6, len(skel.sk_nodes)
def test_infinite2(self): """2 segments with terminal vertices at convex hull """ conv = ToPointsAndSegments() l1 = [(5.86602540378, 0.5), (3.36602540378, 4.83012701892)] l2 = [(1.63397459622, 4.83012701892), (-0.866025403784, 0.5)] for line in l1, l2: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) assert len(skel.segments()) == 11 assert len(skel.sk_nodes) == 6
def test_cocirculair_2(self): """2 segments with terminal vertices at convex hull """ conv = ToPointsAndSegments() l1 = [(0, 0.5), (1, 1)] l2 = [(1, 1), (0.5, 0)] l3 = [(2.5, 3), (2, 2)] l4 = [(2, 2), (3, 2.5)] for line in l1, l2, l3, l4: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) assert len(skel.segments()) == 16 assert len(skel.sk_nodes) == 9
def test_sharp_v(self): """Sharp V-shaped polyline Tests collapse of 2 triangle and handling of collapse of spoke """ conv = ToPointsAndSegments() l1 = [(0, 0.5), (1, 1)] l2 = [(1, 1), (0.5, 0)] for line in l1, l2: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) assert len(skel.segments()) == (3 + 4) assert len(skel.sk_nodes) == 4
def test_wrong_offsets(self): """Resulting segments do not form a planar graph """ # FIXME this has wrong offsets generated # also the skeleton segments do not form a planar straight line graph import json s = """{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28992" } }, "features": [ { "type": "Feature", "properties": { "id": 139664900038544.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51043.725310399997397, 391507.68993699998828 ], [ 51042.455319, 391516.15654599998379 ] ] } }, { "type": "Feature", "properties": { "id": 139664900067600.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51038.632411799997499, 391542.760162 ], [ 51039.83351180000318, 391542.923948 ] ] } }, { "type": "Feature", "properties": { "id": 139664900067600.000000, "side": 2 }, "geometry": { "type": "LineString", "coordinates": [ [ 51039.83351180000318, 391542.923948 ], [ 51039.671322499998496, 391544.167399 ] ] } }, { "type": "Feature", "properties": { "id": 139664900067728.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51039.671322499998496, 391544.167399 ], [ 51041.540670499998669, 391544.37510499998461 ] ] } }, { "type": "Feature", "properties": { "id": 139664900067728.000000, "side": 2 }, "geometry": { "type": "LineString", "coordinates": [ [ 51041.540670499998669, 391544.37510499998461 ], [ 51041.69552799999656, 391544.839677 ] ] } }, { "type": "Feature", "properties": { "id": 139664900067856.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51041.69552799999656, 391544.839677 ], [ 51046.507679299997108, 391545.34621899999911 ] ] } }, { "type": "Feature", "properties": { "id": 139664900069712.000000, "side": 2 }, "geometry": { "type": "LineString", "coordinates": [ [ 51047.918327300001692, 391507.107457 ], [ 51044.982255199996871, 391506.68801799998619 ] ] } }, { "type": "Feature", "properties": { "id": 139664900069840.000000, "side": 0 }, "geometry": { "type": "LineString", "coordinates": [ [ 51044.982255199996871, 391506.68801799998619 ], [ 51044.826051600000937, 391507.83351199998287 ] ] } }, { "type": "Feature", "properties": { "id": 139664900069840.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51044.826051600000937, 391507.83351199998287 ], [ 51043.725310399997397, 391507.68993699998828 ] ] } }, { "type": "Feature", "properties": { "id": 139664900070160.000000, "side": 2 }, "geometry": { "type": "LineString", "coordinates": [ [ 51042.455319, 391516.15654599998379 ], [ 51042.565606500000285, 391516.170332 ] ] } }, { "type": "Feature", "properties": { "id": 139664900070288.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51042.473354800000379, 391516.453288 ], [ 51041.308878199997707, 391524.99278299999423 ] ] } }, { "type": "Feature", "properties": { "id": 139664900070416.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51041.308878199997707, 391524.99278299999423 ], [ 51042.464014700002735, 391525.14345299999695 ] ] } }, { "type": "Feature", "properties": { "id": 139664900070480.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51042.464014700002735, 391525.14345299999695 ], [ 51042.389055500003451, 391525.69883299997309 ] ] } }, { "type": "Feature", "properties": { "id": 139664900070480.000000, "side": 2 }, "geometry": { "type": "LineString", "coordinates": [ [ 51042.389055500003451, 391525.69883299997309 ], [ 51041.245075500002713, 391525.5081699999864 ] ] } }, { "type": "Feature", "properties": { "id": 139664900070800.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51041.245075500002713, 391525.5081699999864 ], [ 51040.449382300001162, 391530.812791 ] ] } }, { "type": "Feature", "properties": { "id": 139664900070800.000000, "side": 2 }, "geometry": { "type": "LineString", "coordinates": [ [ 51040.449382300001162, 391530.812791 ], [ 51040.220387200002733, 391530.78416699997615 ] ] } }, { "type": "Feature", "properties": { "id": 139664900071248.000000, "side": 0 }, "geometry": { "type": "LineString", "coordinates": [ [ 51040.220387200002733, 391530.78416699997615 ], [ 51039.75987090000126, 391535.619588 ] ] } }, { "type": "Feature", "properties": { "id": 139664900071248.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51039.75987090000126, 391535.619588 ], [ 51038.632411799997499, 391542.760162 ] ] } }, { "type": "Feature", "properties": { "id": 139664900144272.000000, "side": 1 }, "geometry": { "type": "LineString", "coordinates": [ [ 51042.565606500000285, 391516.170332 ], [ 51042.535010500003409, 391516.46099499997217 ] ] } }, { "type": "Feature", "properties": { "id": 139664900144272.000000, "side": 2 }, "geometry": { "type": "LineString", "coordinates": [ [ 51042.535010500003409, 391516.46099499997217 ], [ 51042.473354800000379, 391516.453288 ] ] } } ] }""" x = json.loads(s) # parse segments from geo-json segments = [] for y in x['features']: segments.append(tuple(map(tuple, y['geometry']['coordinates']))) # convert to triangulation input conv = ToPointsAndSegments() for line in segments: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) # skeletonize / offset skel = calc_skel(conv, pause=True, output=True)
def test_cocirculair_3(self): """ """ conv = ToPointsAndSegments() l = [ [(0, 0.5), (1, 1)], [(1, 1), (0.5, 0)], [(2.5, 3), (2, 2)], [(2, 2), (3, 2.5)], [(0, 2.5), (1, 2)], [(1, 2), (0.5, 3)], ] for line in l: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) assert len(skel.segments()) == 26
def test_segments(self): segments = [[(0.74919661115900005, 0.28708369850999998), (0.84596844872900001, 0.25202673093900002)], [(0.84596844872900001, 0.25202673093900002), (0.86338737949099997, 0.27726044405599998)], [(0.89132340052500003, 0.25797911189200001), (0.86338737949099997, 0.27726044405599998)], [(0.89132340052500003, 0.25797911189200001), (0.87101957347299996, 0.22858238387499999)], [(0.87101957347299996, 0.22858238387499999), (0.94226555652900001, 0.15090929009699999)]] conv = ToPointsAndSegments() for line in segments: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) assert len(skel.segments()) == 15, len(skel.segments()) assert len(skel.sk_nodes) == 9, len(skel.sk_nodes)
def test_cocirculair_4(self): """ """ conv = ToPointsAndSegments() l = [ [(0, 0.5), (1, 1)], [(1, 1), (0.5, 0)], [(2.5, 3), (2, 2)], [(2, 2), (3, 2.5)], [(0, 2.5), (1, 2)], [(1, 2), (0.5, 3)], [(2.5, 0), (2, 1)], [(2, 1), (3, 0.5)], ] for line in l: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv) assert len(skel.sk_nodes) == 21 assert len(skel.segments()) == 36
def test_2_vshape(self): from math import cos, sin, pi # misses event N = 20 inc = 2 * pi / N pts = [] for i in range(N): if i % 2: pt = cos(i * inc), sin(i * inc) else: pt = 2 * cos(i * inc), 2 * sin(i * inc) pts.append(pt) l = [] for n in (0, 1, 4, 5): l.append((pts[n], pts[(n + 1) % len(pts)])) conv = ToPointsAndSegments() for line in l: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) assert len(skel.segments()) == 17 assert len(skel.sk_nodes) == 10
def test_inf(self): """Contains 1 triangle that is only witnessed by infinite triangle event (edge collapse) """ segments = [[(0.713628396143, 0.28492915571299998), (0.605791703184, 0.27382778264800001)], [(0.71037832310799998, 0.31648042652800001), (0.713628396143, 0.28492915571299998)], [(0.74580046742600004, 0.32013219398300002), (0.71037832310799998, 0.31648042652800001)], [(0.74919661115900005, 0.28708369850999998), (0.74580046742600004, 0.32013219398300002)], [(0.74919661115900005, 0.28708369850999998), (0.84596844872900001, 0.25202673093900002)], [(0.84596844872900001, 0.25202673093900002), (0.86338737949099997, 0.27726044405599998)], [(0.89132340052500003, 0.25797911189200001), (0.86338737949099997, 0.27726044405599998)], [(0.89132340052500003, 0.25797911189200001), (0.87101957347299996, 0.22858238387499999)], [(0.87101957347299996, 0.22858238387499999), (0.94226555652900001, 0.15090929009699999)], [(0.94226555652900001, 0.15090929009699999), (0.98031697341500001, 0.16547984224500001)], [(0.98689015483499998, 0.13283304119200001), (0.98031697341500001, 0.16547984224500001)], [(0.98689015483499998, 0.13283304119200001), (0.954279871457, 0.118518112767)], [(0.954279871457, 0.118518112767), (0.96435874963400003, 0.0207237803098)]] conv = ToPointsAndSegments() for line in segments: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv, pause=PAUSE, output=OUTPUT) assert len(skel.segments()) == 47, len(skel.segments()) assert len(skel.sk_nodes) == 33, len(skel.sk_nodes)
def test_star_cocircular(self): """4 v-shape lines pointing towards center """ from math import cos, sin, pi N = 20 inc = 2 * pi / N pts = [] for i in range(N): if i % 2: pt = cos(i * inc), sin(i * inc) else: pt = 2 * cos(i * inc), 2 * sin(i * inc) pts.append(pt) l = [] for n in (0, 1, 4, 5, 8, 9, 12, 13, 16, 17): l.append((pts[n], pts[(n + 1) % len(pts)])) conv = ToPointsAndSegments() for line in l: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) skel = calc_skel(conv) assert len(skel.segments()) == 45 assert len(skel.sk_nodes) == 26, len(skel.sk_nodes)
wkt = fh.readline() from simplegeom.wkt import loads poly = loads(wkt) poly = poly[0] # -- small sample # import json # with open('bug8.geojson') as fh: # j = fh.read() # x = json.loads(j) # print x # ## parse segments from geo-json # y = x['features'][0] # poly = map(tuple, y['geometry']['coordinates'][0]) conv = ToPointsAndSegments() for start, end in zip(poly[:-1], poly[1:]): conv.add_point(start) conv.add_point(end) conv.add_segment(start, end) # # -- add first / last point # #conv.add_point(poly[0]) # #conv.add_point(poly[-1]) # #conv.add_segment(poly[-1], poly[0]) # start = timeit.default_timer() # skeletonize / offset print(start) skel = calc_skel(conv, pause=False,
# original # if True: # ring = [(74029.47599999999511056,445622.80800000001909211),(74022.8169999999954598,445622.11400000000139698),(74023.09900000000197906,445619.97800000000279397),(74021.96000000000640284,445619.86800000001676381),(74022.06500000000232831,445618.78100000001722947),(74023.11100000000442378,445618.88199999998323619),(74024.28500000000349246,445606.70799999998416752),(74024.5,445606.72899999999208376),(74024.98399999999674037,445601.71000000002095476),(74025.26700000000710133,445601.7370000000228174),(74025.43099999999685679,445600.02799999999115244),(74033.13599999999860302,445600.77100000000791624),(74033.26799999999639113,445599.39600000000791624),(74034.29600000000209548,445599.49499999999534339),(74034.16400000000430737,445600.86300000001210719),(74037.91899999999441206,445601.22499999997671694),(74038.05199999999604188,445599.84600000001955777),(74039.09900000000197906,445599.9469999999855645),(74038.96700000000419095,445601.32099999999627471),(74042.68099999999685679,445601.67999999999301508),(74042.8120000000053551,445600.32099999999627471),(74043.87600000000384171,445600.42300000000977889),(74043.74499999999534339,445601.78100000001722947),(74047.73099999999976717,445602.16499999997904524),(74048.09600000000500586,445598.37599999998928979),(74047.09299999999348074,445598.27899999998044223),(74047.19999999999708962,445597.1720000000204891),(74048.21899999999732245,445597.27100000000791624),(74048.31600000000617001,445596.2629999999771826),(74049.39500000000407454,445596.36700000002747402),(74049.29700000000593718,445597.38000000000465661),(74055.42600000000675209,445597.97100000001955777),(74055.52499999999417923,445596.94300000002840534),(74056.61999999999534339,445597.04899999999906868),(74056.52099999999336433,445598.0719999999855645),(74057.59600000000500586,445598.17599999997764826),(74057.4940000000060536,445599.23300000000745058),(74056.38800000000628643,445599.12599999998928979),(74056.05599999999685679,445602.56800000002840534),(74057.1190000000060536,445602.66999999998370185),(74056.9980000000068685,445603.92099999997299165),(74055.94000000000232831,445603.81800000002840534),(74055.66300000000046566,445606.68599999998696148),(74058.68499999999767169,445606.97700000001350418),(74058.76900000000023283,445606.09999999997671694),(74059.74599999999918509,445606.19400000001769513),(74059.65799999999580905,445607.106000000028871),(74062.35899999999674037,445607.36599999997997656),(74062.44800000000395812,445606.4469999999855645),(74063.42299999999522697,445606.54100000002654269),(74063.32499999999708962,445607.5590000000083819),(74066.11000000000058208,445607.9340000000083819),(74066.59100000000034925,445603.26099999999860302),(74065.60700000000360887,445603.15999999997438863),(74065.71199999999953434,445602.1379999999771826),(74066.66800000000512227,445602.2370000000228174),(74066.77300000000104774,445601.21600000001490116),(74067.73299999999289867,445601.31500000000232831),(74067.62900000000081491,445602.31900000001769513),(74070.46400000000721775,445602.61099999997531995),(74070.57499999999708962,445601.54200000001583248),(74071.51300000000628643,445601.63900000002468005),(74071.40799999999580905,445602.65799999999580905),(74072.27300000000104774,445602.74699999997392297),(74072.16599999999743886,445603.78999999997904524),(74071.26700000000710133,445603.6969999999855645),(74071.0059999999939464,445606.231000000028871),(74071.77899999999499414,445607.34999999997671694),(74071.67900000000372529,445608.32900000002700835),(74073.66300000000046566,445609.20000000001164153),(74074.42100000000209548,445608.67599999997764826),(74074.96000000000640284,445609.45699999999487773),(74074.32899999999790452,445609.93900000001303852),(74075.64800000000104774,445612.22700000001350418),(74076.4940000000060536,445611.94199999998090789),(74076.72800000000279397,445612.91399999998975545),(74075.7519999999931315,445613.26799999998183921),(74075.47599999999511056,445615.94599999999627471),(74076.3690000000060536,445616.33799999998882413),(74076.1889999999984866,445617.23200000001816079),(74075.14699999999720603,445616.83299999998416752),(74073.19599999999627471,445618.96000000002095476),(74073.7519999999931315,445619.76500000001396984),(74072.98699999999371357,445620.29300000000512227),(74072.50999999999476131,445619.60200000001350418),(74069.86000000000058208,445620.56199999997625127),(74069.76700000000710133,445621.46700000000419095),(74068.79700000000593718,445621.36700000002747402),(74068.88599999999860302,445620.50300000002607703),(74065.9330000000045402,445620.19900000002235174),(74065.84299999999348074,445621.07500000001164153),(74064.97999999999592546,445620.98599999997531995),(74065.07099999999627471,445620.09700000000884756),(74062.14100000000325963,445619.79399999999441206),(74062.04799999999522697,445620.69500000000698492),(74061.05299999999988358,445620.59299999999348074),(74061.14500000000407454,445619.69799999997485429),(74059.73399999999674037,445619.55200000002514571),(74059.3120000000053551,445623.64199999999254942),(74060.21499999999650754,445623.73499999998603016),(74060.11699999999837019,445624.68800000002374873),(74059.3129999999946449,445624.60499999998137355),(74059.24099999999452848,445625.31099999998696148),(74058.32000000000698492,445625.21600000001490116),(74058.38999999999941792,445624.54100000002654269),(74053.94599999999627471,445624.08199999999487773),(74053.65700000000651926,445626.89000000001396984),(74054.60099999999511056,445626.98800000001210719),(74054.48200000000360887,445628.143999999971129),(74053.52400000000488944,445628.04499999998370185),(74053.41199999999662396,445629.1379999999771826),(74052.39999999999417923,445629.03399999998509884),(74052.51099999999860302,445627.95400000002700835),(74046.24300000000221189,445627.30800000001909211),(74046.1220000000030268,445628.4870000000228174),(74045.08000000000174623,445628.38000000000465661),(74045.19899999999324791,445627.22100000001955777),(74044.29799999999522697,445627.12800000002607703),(74044.42200000000593718,445625.92599999997764826),(74045.34900000000197906,445626.02199999999720603),(74045.74199999999837019,445622.09999999997671694),(74041.92200000000593718,445621.73200000001816079),(74041.8139999999984866,445622.84999999997671694),(74040.81900000000314321,445622.75400000001536682),(74040.92500000000291038,445621.65500000002793968),(74036.96499999999650754,445621.27299999998649582),(74036.86199999999371357,445622.34499999997206032),(74035.79399999999441206,445622.24200000002747402),(74035.89599999999336433,445621.1840000000083819),(74032.09600000000500586,445620.81800000002840534),(74031.98900000000139698,445621.91800000000512227),(74030.92900000000372529,445621.8159999999916181),(74031.03399999999965075,445620.72499999997671694),(74029.6889999999984866,445620.59499999997206032),(74029.47599999999511056,445622.80800000001909211)] # conv = ToPointsAndSegments() # conv.add_polygon([ring]) # skel = calc_skel(conv, pause=True, output=True) with open( "/home/martijn/Documents/work/archive/2016-01_grassfire_for_building_generalization/data/naaldwijk_church/in_out/in.geojson" ) as fh: s = fh.read() import json x = json.loads(s) # parse segments from geo-json segments = [] for y in x['features']: segments.append(tuple(map(tuple, y['geometry']['coordinates']))) # convert to triangulation input conv = ToPointsAndSegments() for line in segments: conv.add_point(line[0]) conv.add_point(line[1]) conv.add_segment(*line) # skeletonize / offset skel = calc_skel(conv, pause=False, output=True, shrink=False, internal_only=False)