From b76abf35c4461d17260a1886f498c5f01ca5ad76 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 3 Jun 2023 06:55:33 +0000 Subject: [PATCH] fix: bound is wrong to limit the neearest request --- server/infra/database/GisRepository.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/infra/database/GisRepository.ts b/server/infra/database/GisRepository.ts index e0d3580..c934c32 100644 --- a/server/infra/database/GisRepository.ts +++ b/server/infra/database/GisRepository.ts @@ -42,6 +42,9 @@ export default class GisRepository { `; } else if (zoom_level >= 15) { sql = ` + WITH box AS ( + SELECT ST_Extent(ST_MakeLine(ST_Project(ST_SetSRID(ST_MakePoint(${lng}, ${lat}),4326), 10000, radians(45))::geometry, ST_Project(ST_SetSRID(ST_MakePoint(${lng}, ${lat}),4326), 10000, radians(225))::geometry)) AS geom + ) SELECT ST_ASGeoJson(estimated_geometric_location) FROM @@ -67,6 +70,7 @@ export default class GisRepository { ? `and planter.organization_id in ( SELECT entity_id from getEntityRelationshipChildren(${params.organization_id}))` : '' } + and estimated_geometric_location && (select geom from box) ORDER BY estimated_geometric_location <-> ST_SetSRID(ST_MakePoint(${lng}, ${lat}),4326)