[英]Postgis ST_DWithin match a certain radius AND points on the right
I'm using postgis 9.1 and rgeo to develop an map application. 我正在使用postgis 9.1和rgeo开发地图应用程序。
One of the features implies that I find all points that are XXX kms from the current point, and are also on the right of the Point. 其中一项功能意味着我找到了距当前点XXX公里,并且也在该点右侧的所有点。
I tried with the following query: 我尝试使用以下查询:
Environment.where{ st_dwithin(location, factory.point(170.0, 0), 300000 ) }.where('ST_X(location::geometry) > 170')
The corresponding SQL for the query: [EDITED] SELECT "environments".* FROM "environments" WHERE (st_dwithin("environments"."location", ST_PointFromText('POINT(170 0)', 4326), 300000)) AND (ST_X(location::geometry) > 170 );
查询的相应SQL:[EDITED]
SELECT "environments".* FROM "environments" WHERE (st_dwithin("environments"."location", ST_PointFromText('POINT(170 0)', 4326), 300000)) AND (ST_X(location::geometry) > 170 );
Here I hardcoded the point to be in the 170 longitude. 在这里,我将点硬编码为170度。
The problem with this is that I can't match points in the [-170,-180] longitudes. 问题是我无法匹配[-170,-180]经度中的点。
Is there a way to solve this using only postgis functions? 有没有办法仅使用postgis函数来解决此问题?
[EDIT] This is a around the world problem with postgis. [编辑]这是Postgis的全球性问题。 In this application I'm allowed only to find points to the right and in a certain range.. I can't find a solution with pure SQL...
在此应用程序中,我只能在正确的位置和一定范围内找到点。.我找不到使用纯SQL的解决方案...
Thanks! 谢谢!
Consider using the geography
type rather than the geometry
type. 考虑使用
geography
类型而不是geometry
类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.