Mercurial Hosting > traffic-intelligence
annotate LICENSE @ 372:349eb1e09f45
Cleaned the methods/functions indicating if a point is in a polygon
In general, shapely should be used, especially for lots of points:
from shapely.geometry import Polygon, Point
poly = Polygon(array([[0,0],[0,1],[1,1],[1,0]]))
p = Point(0.5,0.5)
poly.contains(p) -> returns True
poly.contains(Point(-1,-1)) -> returns False
You can convert a moving.Point to a shapely point: p = moving.Point(1,2) p.asShapely() returns the equivalent shapely point
If you have several points to test, use moving.pointsInPolygon(points, polygon) where points are moving.Point and polygon is a shapely polygon.
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Tue, 16 Jul 2013 17:00:17 -0400 |
parents | 9a51372607d6 |
children |
rev | line source |
---|---|
80
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
1 Copyright (c) 2009-2011 Nicolas Saunier |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 Permission is hereby granted, free of charge, to any person obtaining a copy |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 of this software and associated documentation files (the "Software"), to deal |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 in the Software without restriction, including without limitation the rights |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 copies of the Software, and to permit persons to whom the Software is |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 furnished to do so, subject to the following conditions: |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
9 |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
10 The above copyright notice and this permission notice shall be included in |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 all copies or substantial portions of the Software. |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
12 |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
16 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
17 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
18 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
9a51372607d6
added MIT license to the project
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
19 THE SOFTWARE. |