From 8dc89f8ee9de289a6eb31b29ad283a318eb11e25 Mon Sep 17 00:00:00 2001 From: Mark Eastwood <20169086+measty@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:39:37 +0000 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Remove=20`POWER`=20from=20?= =?UTF-8?q?sqlite-dist=20Calculations=20(#769)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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> --- tiatoolbox/annotation/storage.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tiatoolbox/annotation/storage.py b/tiatoolbox/annotation/storage.py index 59388777b..85f783512 100644 --- a/tiatoolbox/annotation/storage.py +++ b/tiatoolbox/annotation/storage.py @@ -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