问题描述
我在客户端通过xhr将google / map中的lat / lng边界传递给我的php脚本。这是一个SQL查询来搜索该边界内的位置。我的表将 lat,lng
存储为不同的列。现在我该如何安排我的查询,以便只返回指定 NE,SW
边界内的点。
I am getting lat/lng bounds from google map in client side through xhr to my php script. which is making an sql query to search location within that bounds. My table stores lat, lng
as different columns. now how can I arrange my where queries such that only the points within the specified NE, SW
bounds are returned.
在数据库中,它存储为 number
,我不知道是否已经有任何postgresql特定的聚合函数来执行相同的操作。
In database its stored as number
and I don't know if there already is any postgresql specific aggregate function to do the same.
推荐答案
我错过了什么吗?这只是一个矩形边界检查。这不像你需要计算点之间的距离。
Am I missing something? It's just a rectangular bounds check. It's not like you need to calculate the distance between the points.
WHERE lat BETWEEN lat_of_corner_a AND lat_of_corner_b
AND lon BETWEEN lon_of_corner_a AND lon_of_corner_b
这篇关于内拉特,lng界限在哪里查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!