Skip to content

Commit 8dc89f8

Browse files
meastyshaneahmed
andauthored
♻️ Remove POWER from sqlite-dist Calculations (#769)
- Remove the use of POWER from distance calculations to address issue #692 - Replace use of POWER with explicit multiplication. --------- Co-authored-by: Shan E Ahmed Raza <[email protected]>
1 parent 3fb5686 commit 8dc89f8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tiatoolbox/annotation/storage.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,8 +2588,10 @@ def _initialize_query_string_parameters(
25882588
if geometry_predicate == "centers_within_k":
25892589
# Use rtree index to check distance between points
25902590
query_string += (
2591-
"AND (POWER((:min_x + :max_x)/2 - (min_x + max_x)/2, 2) + "
2592-
" POWER((:min_y + :max_y)/2 - (min_y + max_y)/2, 2)) < :distance2 "
2591+
"AND (((:min_x + :max_x)/2 - (min_x + max_x)/2)*"
2592+
"((:min_x + :max_x)/2 - (min_x + max_x)/2) + "
2593+
" ((:min_y + :max_y)/2 - (min_y + max_y)/2)*"
2594+
"((:min_y + :max_y)/2 - (min_y+ max_y)/2)) < :distance2 "
25932595
)
25942596
query_parameters["distance2"] = distance**2
25952597
# Otherwise, perform a regular bounding box intersection

0 commit comments

Comments
 (0)