【问题标题】:postgresql polygon location querypostgresql 多边形位置查询
【发布时间】:2015-09-24 06:54:26
【问题描述】:

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

所以我不能提供纬度/经度,我想找到所有最近的多边形。

这是我目前所拥有的:

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。有人知道如何执行此查询吗?

【问题讨论】:

    标签: postgresql cartodb


    【解决方案1】:

    我自己想出来的=)

    这是我用的:

    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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-19
      • 1970-01-01
      • 1970-01-01
      • 2021-10-13
      • 1970-01-01
      • 2016-08-05
      • 1970-01-01
      • 2016-06-11
      相关资源
      最近更新 更多