加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgresql – ST_DWithin以参数为度,不是米,为什么?

发布时间:2020-12-13 16:27:58 所属栏目:百科 来源:网络整理
导读:ST_DWithin文件说,第三个参数(距离)是米.但是当我执行一些查询时,似乎将第三个参数作为’degree’? 这是我简化的表格结构: d+ theuser; Table "public.theuser" Column | Type | Modifiers | Storage | Description ----------+------------------------+
ST_DWithin文件说,第三个参数(距离)是米.但是当我执行一些查询时,似乎将第三个参数作为’degree’?

这是我简化的表格结构:

> d+ theuser;
                         Table "public.theuser"
  Column  |          Type          | Modifiers | Storage  | Description 
----------+------------------------+-----------+----------+-------------
 id       | bigint                 | not null  | plain    | 
 point    | geometry               |           | main     | 
Indexes:
    "theuser_pkey" PRIMARY KEY,btree (id)
    "point_index" gist (point)
Referenced by:
    ...
Has OIDs: no

所有点都存储在SRID = 4326中.

这是查询:

> select * from theuser where ST_DWithin(point,ST_GeomFromText('POINT(120.9982 24.788)',4326),100 );

它将第三个参数(100)作为“度”,所以它返回所有数据,我必须缩小到0.001以找到附近的点.

但是如何直接通过米作为第三参数(我不想做米/度变换)?查询有什么问题?为什么PostgreSQL不像文档那样把它当成米?

环境:

> select version();
                                                  version                                                  
-----------------------------------------------------------------------------------------------------------
 PostgreSQL 8.4.9 on i486-pc-linux-gnu,compiled by GCC gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3,32-bit

> SELECT postgis_lib_version();
 postgis_lib_version 
---------------------
 1.4.0

如果是导致此问题的SRID,什么SRID直接使用“米”作为单位? (我尝试转换为SRID = 2163,但仍然在程度)谢谢.

从 docs:

For Geometries: The distance is specified in units defined by the
spatial reference system of the geometries.

如果您的数据在SRID = 4326中,则您指定的距离为度.

您必须使用ST_Transform和基于仪表的坐标系,或两个功能之一:ST_Distance_Sphere(更快,更不准确)或ST_Distance_Spheroid.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读