Mercurial Hosting > traffic-intelligence
changeset 19:5a21d2cfee44
added polygon plotting
author | Nicolas Saunier <nico@confins.net> |
---|---|
date | Fri, 27 Nov 2009 19:16:12 -0500 |
parents | ef35d5f111e4 |
children | ef0d7caf8e91 |
files | python/moving.py python/utils.py |
diffstat | 2 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/python/moving.py Fri Nov 27 00:21:18 2009 -0500 +++ b/python/moving.py Fri Nov 27 19:16:12 2009 -0500 @@ -121,6 +121,11 @@ # return sqrt(sq) return [hypot(x,y) for x,y in zip(self.positions[0], self.positions[1])] + def getTrajectoryInPolygon(self, polygon): + 'Returns the set of points inside the polygon' + # use shapely polygon contains + pass + class MovingObject(STObject): '''Class for moving objects i.e. with a trajectory and a geometry (volume)
--- a/python/utils.py Fri Nov 27 00:21:18 2009 -0500 +++ b/python/utils.py Fri Nov 27 19:16:12 2009 -0500 @@ -85,6 +85,14 @@ def printPoint(x,y): return '(%f,%f)'%(x,y) +def plotPolygon(poly, options = ''): + from numpy.core.multiarray import array + from matplotlib.pyplot import plot + from shapely.geometry import Polygon + + tmp = array(poly.exterior) + plot(tmp[:,0], tmp[:,1], options) + if __name__ == "__main__": import doctest import unittest