nsaunier/traffic-intelligence
reorganization of moving.py and adding documentation tests
Commit 106365257da9 · Nicolas Saunier · 2024-07-09 17:44 -0400
Comments
No comments yet.
Diff
diff --git a/run-tests.sh b/run-tests.sh
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -15,3 +15,15 @@
echo "------------"
echo "Script tests"
./scripts/run-tests.sh
+echo "------------"
+echo "Documentation tests"
+TIWIKI_HOME=~/Research/Code/bb-traffic-intelligence/
+if [ -f $TIWIKI_HOME/docs/run-tests.sh ]
+then
+ cd $TIWIKI_HOME/docs/
+ ./run-tests.sh
+else
+ echo "The documentation repository (BitBucket Traffic Intelligence repository is not accessible"
+ echo "Please clone the BitBucket Traffic Intelligence repository:"
+ echo "$ git clone https://bitbucket.org/Nicolas/trafficintelligence.git"
+fi
diff --git a/trafficintelligence/moving.py b/trafficintelligence/moving.py
--- a/trafficintelligence/moving.py
+++ b/trafficintelligence/moving.py
@@ -1575,6 +1575,9 @@
obj = MovingObject(self.num, intersection, self.positions.subTrajectoryInInterval(trajectoryInterval), self.geometry, self.userType, self.nObjects)
if self.velocities is not None:
obj.velocities = self.velocities.subTrajectoryInInterval(trajectoryInterval)
+ if hasattr(self, 'curvilinearPositions'):
+ obj.curvilinearPositions = self.curvilinearPositions.subTrajectoryInInterval(trajectoryInterval)
+
return obj
else:
print('The object does not exist at {}'.format(inter))
@@ -1872,7 +1875,8 @@
if self.hasFeatures():
for f in self.getFeatures():
f.setStationary()
-
+
+ # Plotting functions
def plot(self, options = '', withOrigin = False, timeStep = 1, withFeatures = False, withOutline = False, withIds = False, **kwargs):
if withIds:
objNum = self.getNum()
@@ -2092,6 +2096,19 @@
(returns an actual value, otherwise munkres does not terminate)'''
return Point.distanceNorm2(self.getPositionAtInstant(instant), obj.getPositionAtInstant(instant))
+ @staticmethod
+ def collisionCourseDotProduct(movingObject1, movingObject2, instant):
+ 'A positive result indicates that the road users are getting closer'
+ deltap = movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant)
+ deltav = movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)
+ return Point.dot(deltap, deltav)
+
+ @staticmethod
+ def collisionCourseCosine(movingObject1, movingObject2, instant):
+ 'A positive result indicates that the road users are getting closer'
+ return Point.cosine(movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant), #deltap
+ movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)) #deltav
+
###
# User Type Classification
###
@@ -2236,19 +2253,6 @@
# what to do: threshold for most common type? self.setUserType()
return possibleUserTypes
- @staticmethod
- def collisionCourseDotProduct(movingObject1, movingObject2, instant):
- 'A positive result indicates that the road users are getting closer'
- deltap = movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant)
- deltav = movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)
- return Point.dot(deltap, deltav)
-
- @staticmethod
- def collisionCourseCosine(movingObject1, movingObject2, instant):
- 'A positive result indicates that the road users are getting closer'
- return Point.cosine(movingObject1.getPositionAtInstant(instant)-movingObject2.getPositionAtInstant(instant), #deltap
- movingObject2.getVelocityAtInstant(instant)-movingObject1.getVelocityAtInstant(instant)) #deltav
-
class Prototype(object):
'Class for a prototype'