From ea1f43bec7f531bb2d79aac6d717fcdda92e866f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Wed, 11 Dec 2019 11:02:31 +0100 Subject: [PATCH] Fix query to make the proper transformations --- lib/models/filter/circle.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/models/filter/circle.js b/lib/models/filter/circle.js index 5dcd35db..bfc66aa1 100644 --- a/lib/models/filter/circle.js +++ b/lib/models/filter/circle.js @@ -9,12 +9,15 @@ function filterQueryTpl ({ sql, column, srid, lng, lat, radius } = {}) { WHERE ST_Intersects( ${column}, - ST_Buffer( - ST_Transform( - ST_SetSRID(ST_Point(${lng},${lat}), 4326), - ${srid} - ), - ${radius} + ST_Transform( + ST_Buffer( + ST_Transform( + ST_SetSRID(ST_Point(${lng},${lat}), ${srid}), + 4326 + )::geography, + ${radius} + )::geometry, + ${srid} ) ) `;