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