Mercurial Hosting > traffic-intelligence
changeset 116:2bf5b76320c0
moved intersection plotting and added markers for scatter plots
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 08 Aug 2011 14:47:30 -0400 |
parents | 550556378466 |
children | fea680fb03ee |
files | python/cvutils.py python/traffic_engineering.py python/utils.py |
diffstat | 3 files changed, 27 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/python/cvutils.py Sat Jul 23 02:18:16 2011 -0400 +++ b/python/cvutils.py Mon Aug 08 14:47:30 2011 -0400 @@ -127,24 +127,3 @@ return [median(deltaX), median(deltaY)] else: return None - -class FourWayIntersection: - '''Simple class for simple intersection outline''' - def __init__(self, dimension, coordX, coordY): - self.dimension = dimension - self.coordX = coordX - self.coordY = coordY - - def plot(self, options = 'k'): - from matplotlib.pyplot import plot, axis - - minX = min(self.dimension[0]) - maxX = max(self.dimension[0]) - minY = min(self.dimension[1]) - maxY = max(self.dimension[1]) - - plot([minX, self.coordX[0], self.coordX[0]], [self.coordY[0], self.coordY[0], minY],options) - plot([self.coordX[1], self.coordX[1], maxX], [minY, self.coordY[0], self.coordY[0]],options) - plot([minX, self.coordX[0], self.coordX[0]], [self.coordY[1], self.coordY[1], maxY],options) - plot([self.coordX[1], self.coordX[1], maxX], [maxY, self.coordY[1], self.coordY[1]],options) - axis('equal')
--- a/python/traffic_engineering.py Sat Jul 23 02:18:16 2011 -0400 +++ b/python/traffic_engineering.py Mon Aug 08 14:47:30 2011 -0400 @@ -65,6 +65,31 @@ return self.qmax ######################### +# intersection +######################### + +class FourWayIntersection: + '''Simple class for simple intersection outline''' + def __init__(self, dimension, coordX, coordY): + self.dimension = dimension + self.coordX = coordX + self.coordY = coordY + + def plot(self, options = 'k'): + from matplotlib.pyplot import plot, axis + + minX = min(self.dimension[0]) + maxX = max(self.dimension[0]) + minY = min(self.dimension[1]) + maxY = max(self.dimension[1]) + + plot([minX, self.coordX[0], self.coordX[0]], [self.coordY[0], self.coordY[0], minY],options) + plot([self.coordX[1], self.coordX[1], maxX], [minY, self.coordY[0], self.coordY[0]],options) + plot([minX, self.coordX[0], self.coordX[0]], [self.coordY[1], self.coordY[1], maxY],options) + plot([self.coordX[1], self.coordX[1], maxX], [maxY, self.coordY[1], self.coordY[1]],options) + axis('equal') + +######################### # traffic signals #########################
--- a/python/utils.py Sat Jul 23 02:18:16 2011 -0400 +++ b/python/utils.py Mon Aug 08 14:47:30 2011 -0400 @@ -165,10 +165,11 @@ def __init__(self, values): self.values = values - def get(self,i): + def __getitem__(self, i): return self.values[i%len(self.values)] markers = PlottingPropertyValues(['+', '*', ',', '.', 'x', 'D', 's', 'o']) +scatterMarkers = PlottingPropertyValues(['s','o','^','>','v','<','d','p','h','8','+','x']) linestyles = PlottingPropertyValues(['-', '--', '-.', ':'])