Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update strtree.py Add GEOSSTRtree_nearest_generic function from GEOS * Update ctypes_declarations.py Add GEOSSTRtree_nearest_generic function from GEOS * Add files via upload * Update test_strtree_nearest.py
- Loading branch information
1 parent
d7b8417
commit 4f41e54
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from . import unittest | ||
|
||
from shapely.geometry import Point, Polygon | ||
from shapely.geos import geos_version | ||
from shapely.strtree import STRtree | ||
|
||
@unittest.skipIf(geos_version < (3, 6, 0), 'GEOS 3.6.0 required') | ||
class STRTreeNearest(unittest.TestCase): | ||
def test_nearest(self): | ||
tree = STRtree([ | ||
Polygon([(1,0),(2,0),(2,1),(1,1)]), | ||
Polygon([(0,2),(1,2),(1,3),(0,3)]), | ||
Point(0,0.5)]) | ||
result = tree.nearest(Point(0,0)) | ||
self.assertEqual(result, Point(0,0.5)) | ||
result = tree.nearest(Point(0,4)) | ||
self.assertEqual(result, Polygon([(0,2),(1,2),(1,3),(0,3)])) | ||
result = tree.nearest(Polygon([(-0.5,-0.5),(0.5,-0.5),(0.5,0.5),(-0.5,0.5)])) | ||
self.assertEqual(result, Point(0,0.5)) | ||
|
||
|
||
def test_suite(): | ||
return unittest.TestLoader().loadTestsFromTestCase(STRTreeNearest) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|