Skip to content

Commit

Permalink
GmMultiPolyIntersector for python - added test for polygon_from_point
Browse files Browse the repository at this point in the history
  • Loading branch information
mkennard-aquaveo committed Jan 4, 2024
1 parent 30e18dc commit f5af8c0
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,36 @@ def test_traverse_line_segment_1_out_in(self):
expected_points = ((0.0, 5.0, 0.0), (8.0, 5.0, 0.0))
self._run_test(-1, 5, 8, 5, pts, polys, expected_ids, expected_t_vals, expected_points)

def test_polygon_from_point(self):
r"""A test.
(0,20)
3-------------2
| |
| |
| *1 | *
| |
| |
0------*-----*1------*------6
| |
| |
| |
* | *2 |
| |
4-------------5
(0,0) (20,0)
"""
pts = [[0, 10, 0], [10, 10, 0], [10, 20, 0], [0, 20, 0], [10, 0, 0], [20, 0, 0], [20, 10, 0]]
polys = [[0, 1, 2, 3], [4, 5, 6, 1]]
mpi = grid.geometry.MultiPolyIntersector(pts, polys)
assert mpi.polygon_from_point((5, 5, 0)) == -1
assert mpi.polygon_from_point((5, 10, 0)) == 1
assert mpi.polygon_from_point((5, 15, 0)) == 1
assert mpi.polygon_from_point((10, 10, 0)) == 1
assert mpi.polygon_from_point((15, 15, 0)) == -1
assert mpi.polygon_from_point((15, 10, 0)) == 2
assert mpi.polygon_from_point((15, 5, 0)) == 2


if __name__ == '__main__':
unittest.main()

0 comments on commit f5af8c0

Please sign in to comment.