Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
NOCSurfaceProcesses
GeoSpatialTools
Commits
53b36e8a
Commit
53b36e8a
authored
5 months ago
by
Joseph Siddons
Browse files
Options
Download
Email Patches
Plain Diff
test(kdtree): Test neighbours over pole
parent
85e6d8af
main
v0.11.2
v0.11.1
v0.11.0
v0.10.1
v0.10.0
v0.9.0
v0.8.0
v0.7.1
v0.7.0
v0.6.0
v0.5.0
1 merge request
!8
Fix Rectangle query for QuadTree and OctTree classes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
test/test_kdtree.py
test/test_kdtree.py
+30
-1
No files found.
test/test_kdtree.py
View file @
53b36e8a
import
unittest
import
random
from
numpy
import
min
,
argmin
from
GeoSpatialTools
import
haversine
,
KDTree
,
Record
...
...
@@ -91,12 +93,39 @@ class TestKDTree(unittest.TestCase):
def
test_wrap
(
self
):
# TEST: Accounts for wrap at -180, 180
kt
=
KDTree
(
self
.
records
)
kt
.
insert
(
Record
(
-
160
,
-
64
,
uid
=
"G"
))
bad_rec
=
Record
(
-
160
,
-
64
,
uid
=
"G"
)
kt
.
insert
(
bad_rec
)
query_rec
=
Record
(
-
178
,
-
79
,
uid
=
"E"
)
r
,
_
=
kt
.
query
(
query_rec
)
assert
len
(
r
)
==
1
assert
r
[
0
].
uid
==
"C"
def
test_near_pole_query
(
self
):
test_records
=
[
Record
(
-
180
,
89.5
,
uid
=
"1"
),
Record
(
-
90
,
89.9
,
uid
=
"2"
),
Record
(
0
,
89.5
,
uid
=
"3"
),
]
N_others
=
50
test_records
.
extend
(
[
Record
(
random
.
choice
(
range
(
-
180
,
180
)),
random
.
choice
(
range
(
80
,
90
)),
)
for
_
in
range
(
N_others
)
]
)
kt
=
KDTree
(
test_records
,
max_depth
=
3
)
query_rec
=
Record
(
90
,
89.8
,
uid
=
"4"
)
r
,
d
=
kt
.
query
(
query_rec
)
assert
len
(
r
)
==
1
print
(
r
[
0
])
print
(
d
)
assert
r
[
0
].
uid
==
"2"
if
__name__
==
"__main__"
:
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment