Skip to content

Commit

Permalink
fix: bound is wrong to limit the neearest request
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jun 3, 2023
1 parent a6bec57 commit b76abf3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/infra/database/GisRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit b76abf3

Please sign in to comment.