-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.py
88 lines (65 loc) · 2.39 KB
/
classes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from shapely.geometry import Polygon, Point
class Group:
def __init__(self, id):
self.id = id
self.blds = []
self.points = []
self.cablePnts = []
self.subgroups = []
self.street = None
def setStreet(self, i):
self.street = i
def setBlds(self, buildings):
self.blds = buildings
def setPoints(self, points):
self.points = points
def setCablePoints(self, points):
self.cablePnts = points
def addSubgroups(self, subgroup):
self.subgroups.append(subgroup)
def hasSubgroup(self):
if self.subgroups:
print "{} {} contains {} subgroups".format(self.__class__.__name__, self.id, len(self.subgroups))
else:
return None
def __str__(self):
if self.blds and self.points:
return "{} {} contains {} buildings and {} points".format(self.__class__.__name__, self.id, len(self.blds), len(self.points))
elif self.blds and self.points == []:
return "{} {} contains {} buildings but no points yet".format(self.__class__.__name__, self.id, len(self.blds))
elif self.blds == [] and self.points:
return "{} {} contains no buildings yet, but {} points".format(self.__class__.__name__, self.id, len(self.points))
else:
return "{} {} contains no buildings and no points yet".format(self.__class__.__name__, self.id)
class Subgroup(Group):
def __init__(self, id, street=None):
Group.__init__(self, id)
self.id = id
self.blds = []
self.street = street
self.streetindex = None
self.cable = None
def addBuilding(self, b):
self.blds.append(b)
class Building:
def __init__(self, id, groupID, geom=Polygon):
self.groupID = groupID
self.id = id
self.geom = geom
self.bldpnt = Point
self.cablePoint = None
self.neighbors = []
self.attributes = {}
self.concable = None
def setGeom(self, poly):
self.geom = poly
def setPnt(self, point):
self.bldpnt = point
def setCablePoint(self, cablepoint):
self.cablePoint = cablepoint
def setNeighbors(self, neighbors):
self.neighbors = neighbors
def display(self):
return self.geom.wkt
def __str__(self):
return "Building {} belonging to group {}".format(self.id, self.groupID)