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.