Postgresql多边形位置查询



有人能帮我写一个查询找到所有最近的多边形到a经度。

所以我提供了lat/long,我想找到所有最近的多边形。

这是我目前所拥有的:

SELECT name
FROM questions_radius
WHERE mdsys.sdo_within_distance(
the_geom, 
mdsys.sdo_geometry(2001, 8307, mdsys.sdo_point_type( 
-120, 43, null), null, null), 'distance=500 unit=FOOT')= 'TRUE' 

,但这给了我一个错误:模式"mdsys"不存在。我用的是cartoDB。有人知道如何执行这个查询吗?

我自己弄明白了=)

下面是我使用的:

SELECT * FROM questions_radius 
WHERE ST_DWithin(the_geom::geography,
ST_SetSRID(ST_MakePoint([user_latitude], [user_longitude]), 4326)::geography, [distance_in_meters])
ORDER BY the_geom <-> ST_SetSRID(ST_MakePoint([user_latitude],[user_longitude]),4326) ASC
LIMIT 100

可以查询离用户位置最近的点和多边形。只需提供以米为单位的纬度、经度和距离来执行查询并完成。它非常快。希望这能帮助任何想要执行一些很酷的地理空间查询的人。div =)

最新更新