Mercurial Hosting > traffic-intelligence
comparison trafficintelligence/moving.py @ 1115:cef7aa2f9931
minor shorthand method
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sat, 22 Jun 2019 23:33:01 -0400 |
parents | 7135b5eaa6b4 |
children | a3982d591a61 |
comparison
equal
deleted
inserted
replaced
1114:7135b5eaa6b4 | 1115:cef7aa2f9931 |
---|---|
877 return self.distances[i] | 877 return self.distances[i] |
878 else: | 878 else: |
879 print('Index {} beyond trajectory length {}-1'.format(i, self.length())) | 879 print('Index {} beyond trajectory length {}-1'.format(i, self.length())) |
880 | 880 |
881 def getCumulativeDistance(self, i): | 881 def getCumulativeDistance(self, i): |
882 '''Return the cumulative distance between the beginning and point i''' | 882 '''Returns the cumulative distance between the beginning and point i''' |
883 if i < self.length(): | 883 if i < self.length(): |
884 return self.cumulativeDistances[i] | 884 return self.cumulativeDistances[i] |
885 else: | 885 else: |
886 print('Index {} beyond trajectory length {}'.format(i, self.length())) | 886 print('Index {} beyond trajectory length {}'.format(i, self.length())) |
887 | 887 |
888 def getTotalDistance(self): | |
889 '''Returns the total distance (shorthand for cumulative distance [-1]''' | |
890 return self.getCumulativeDistance(-1) | |
891 | |
888 def getMaxDistance(self, metric): | 892 def getMaxDistance(self, metric): |
889 'Returns the maximum distance between points in the trajectory' | 893 'Returns the maximum distance between points in the trajectory' |
890 positions = self.getPositions().asArray().T | 894 positions = self.getPositions().asArray().T |
891 return cdist(positions, positions, metric = metric).max() | 895 return cdist(positions, positions, metric = metric).max() |
892 | 896 |