Mercurial > hg > nsaunier > traffic-intelligence
comparison python/moving.py @ 688:f2b52355a286 dev
made length a STObject method
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 26 Jun 2015 23:49:44 -0400 |
| parents | 94b291a5f933 |
| children | 463150a8e129 |
comparison
equal
deleted
inserted
replaced
| 687:de278c5e65f6 | 688:f2b52355a286 |
|---|---|
| 120 | 120 |
| 121 def length(self): | 121 def length(self): |
| 122 '''Returns the length of the interval''' | 122 '''Returns the length of the interval''' |
| 123 return float(max(0,self.last-self.first+1)) | 123 return float(max(0,self.last-self.first+1)) |
| 124 | 124 |
| 125 def __len__(self): | |
| 126 return self.length() | |
| 127 | |
| 125 # class BoundingPolygon: | 128 # class BoundingPolygon: |
| 126 # '''Class for a polygon bounding a set of points | 129 # '''Class for a polygon bounding a set of points |
| 127 # with methods to create intersection, unions... | 130 # with methods to create intersection, unions... |
| 128 # ''' | 131 # ''' |
| 129 # We will use the polygon class of Shapely | 132 # We will use the polygon class of Shapely |
| 139 self.num = num | 142 self.num = num |
| 140 self.timeInterval = timeInterval | 143 self.timeInterval = timeInterval |
| 141 self.boundingPolygon = boundingPolygon | 144 self.boundingPolygon = boundingPolygon |
| 142 | 145 |
| 143 def empty(self): | 146 def empty(self): |
| 144 return self.timeInterval.empty() or not self.boudingPolygon | 147 return self.timeInterval.empty()# or not self.boudingPolygon |
| 145 | 148 |
| 146 def getNum(self): | 149 def getNum(self): |
| 147 return self.num | 150 return self.num |
| 151 | |
| 152 def __len__(self): | |
| 153 return self.timeInterval.length() | |
| 154 | |
| 155 def length(self): | |
| 156 return self.timeInterval.length() | |
| 148 | 157 |
| 149 def getFirstInstant(self): | 158 def getFirstInstant(self): |
| 150 return self.timeInterval.first | 159 return self.timeInterval.first |
| 151 | 160 |
| 152 def getLastInstant(self): | 161 def getLastInstant(self): |
| 1051 obj.velocities = self.velocities.getTrajectoryInInterval(trajectoryInterval) | 1060 obj.velocities = self.velocities.getTrajectoryInInterval(trajectoryInterval) |
| 1052 return obj | 1061 return obj |
| 1053 else: | 1062 else: |
| 1054 print 'The object does not exist at '+str(inter) | 1063 print 'The object does not exist at '+str(inter) |
| 1055 return None | 1064 return None |
| 1056 | |
| 1057 def length(self): | |
| 1058 return self.timeInterval.length() | |
| 1059 | 1065 |
| 1060 def getPositions(self): | 1066 def getPositions(self): |
| 1061 return self.positions | 1067 return self.positions |
| 1062 | 1068 |
| 1063 def getVelocities(self): | 1069 def getVelocities(self): |
