Changeset 2442
- Timestamp:
- Feb 22, 2006, 6:36:40 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/utilities/test_polygon.py
r2375 r2442 241 241 assert not inside_polygon( (0.5, 0.5), polygon ) 242 242 243 244 245 def test_duplicate_points_being_ok(self): 246 247 248 #Simplest case: Polygon is the unit square 249 polygon = [[0,0], [1,0], [1,0], [1,0], [1,1], [0,1], [0,0]] 250 251 assert inside_polygon( (0.5, 0.5), polygon ) 252 assert not inside_polygon( (0.5, 1.5), polygon ) 253 assert not inside_polygon( (0.5, -0.5), polygon ) 254 assert not inside_polygon( (-0.5, 0.5), polygon ) 255 assert not inside_polygon( (1.5, 0.5), polygon ) 256 257 #Try point on borders 258 assert inside_polygon( (1., 0.5), polygon, closed=True) 259 assert inside_polygon( (0.5, 1), polygon, closed=True) 260 assert inside_polygon( (0., 0.5), polygon, closed=True) 261 assert inside_polygon( (0.5, 0.), polygon, closed=True) 262 263 assert not inside_polygon( (0.5, 1), polygon, closed=False) 264 assert not inside_polygon( (0., 0.5), polygon, closed=False) 265 assert not inside_polygon( (0.5, 0.), polygon, closed=False) 266 assert not inside_polygon( (1., 0.5), polygon, closed=False) 267 268 #From real example 269 polygon = [[20,20], [40,20], [40,40], [20,40]] 270 points = [ [40, 50] ] 271 res = inside_polygon(points, polygon) 272 assert len(res) == 0 273 274 275 243 276 def test_inside_polygon_vector_version(self): 244 277 #Now try the vector formulation returning indices
Note: See TracChangeset
for help on using the changeset viewer.