postgresql多边形位置查询

postgresql多边形位置查询,postgresql,cartodb,Postgresql,Cartodb,有人能帮我写一个查询来查找到一个多边形最近的所有多边形吗 经纬度 因此,我将提供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=5

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

因此,我将提供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
这可用于查询距离用户位置最近的点和多边形。只需提供纬度、经度和距离(以米为单位),即可执行查询并完成查询。它相当快。希望这能帮助任何想要执行一些很酷的地理空间查询的人=