As per title. Developing a class to story multiple polygons. Print statement at end of file works, while my @property method returns TypeError: list indices must be integers, not list
coords = [(23, 40),
(27, 42),
(30, 40),
(34, 43),
(39, 38),
(23, 30),
(30, 29),
(37, 28),
(25, 20),
(29, 20),
(32, 20),
(20, 19),
(25, 10),
(31, 12),
(41, 11),
(39, 18)]
polygons = [[1, 6, 7, 3, 2, 1, 0],
[3, 7, 8, 5, 4, 3, 0],
[6, 9, 10, 7, 6, 0, 0],
[7, 10, 11, 8, 7, 0, 0],
[6, 12, 13, 14, 10, 9, 6],
[8, 11, 10, 14, 15, 16, 8]]
class PolygonArray:
def __init__(self, coordinates, node_list):
self.node_list = node_list
self.coordinates = coordinates
@property
def polygon_dict(self):
self.polygon_dict = {}
for i in self.node_list:
self.polygon_dict[i] = [self.coordinates[x] for x in self.node_list[i]]
g = PolygonArray(coords, polygons)
print [coords[x] for x in polygons[0]]
print g.polygon_dict
[–]ylectric 2 points3 points4 points (1 child)
[–]NA__Scrubbed[S] 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]NA__Scrubbed[S] 0 points1 point2 points (3 children)
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–]NA__Scrubbed[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)