Skip to content

Commit

Permalink
♻️ Remove POWER from sqlite-dist Calculations (#769)
Browse files Browse the repository at this point in the history
- 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 <13048456+shaneahmed@users.noreply.github.com>
  • Loading branch information
measty and shaneahmed committed Jan 19, 2024
1 parent 3fb5686 commit 8dc89f8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tiatoolbox/annotation/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,8 +2588,10 @@ def _initialize_query_string_parameters(
if geometry_predicate == "centers_within_k":
# Use rtree index to check distance between points
query_string += (
"AND (POWER((:min_x + :max_x)/2 - (min_x + max_x)/2, 2) + "
" POWER((:min_y + :max_y)/2 - (min_y + max_y)/2, 2)) < :distance2 "
"AND (((:min_x + :max_x)/2 - (min_x + max_x)/2)*"
"((:min_x + :max_x)/2 - (min_x + max_x)/2) + "
" ((:min_y + :max_y)/2 - (min_y + max_y)/2)*"
"((:min_y + :max_y)/2 - (min_y+ max_y)/2)) < :distance2 "
)
query_parameters["distance2"] = distance**2
# Otherwise, perform a regular bounding box intersection
Expand Down

0 comments on commit 8dc89f8

Please sign in to comment.