PostgreSQL计算浮点坐标和geom之间的距离(以米为单位)

我要查询,一个人试图计算浮点坐标(x1,y1,x2,y2)之间的距离, 另一个尝试计算geom和float坐标之间的距离,两者都应以米为单位返回距离。</ p>

我对2个浮点数使用以下查询:</ p>

  ST_Distance_Sphere(st_setsrid(st_makepoint(经度,纬度),4326),st_setsrid(st_makepoint(?,?),4326))AS距离
</ code> </ pre>

geom和float的querty是:</ p>

  ST_Distance_Sphere(geom,st_setsrid(st_makepoint(?,?),4326))AS距离
</ 代码> </ pre>

我无法完全理解SRID概念,我感觉我的数字因此而无法理解。</ p>

有人可以帮助以米为单位输出距离吗?</ p>

谢谢,
Itay。</ p>
</ div>

展开原文

原文

I have to queries, one tries to calculate the distance between floats coordinates (x1,y1,x2,y2), and the other tries to calculate the distance between a geom and an float coordinate, both should return distance in meters.

I'm using the following query for the 2 floats:

ST_Distance_Sphere(st_setsrid(st_makepoint(longitude, latitude),4326), st_setsrid(st_makepoint(?,?),4326)) AS distance

And The querty for geom and float is:

ST_Distance_Sphere(geom, st_setsrid(st_makepoint(?,?),4326)) AS distance

I can't to fully understand the SRID concept, and I'm having the feeling that my numbers are incorrects because of it.

Can someone help to output a distance in meters?

Thanks, Itay.

duanmen2189
duanmen2189 实际上我不知道,由于缺乏我的距离经验和SAID我想听听更有经验的开发人员
大约 3 年之前 回复
dsa88886666
dsa88886666 你是不是必须使用带有SRID的ST_Distance_sphere,我不使用postgis,但它看起来与ST_Distance_sphere你必须使用点,而不是SRID
大约 3 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐