计算 50 英里外的点(北,45% NE,45% SW)

Caculate point 50 miles away (North, 45% NE, 45% SW)

在 PostGIS 中,有没有办法计算不同方向 50 英里外的另一个点?

给定一个点,('New York',-74.00,40.71),我如何计算以下点?

1) 50 miles directly North
2) 50 miles 45% North East
4) 50 miles directly East
3) 50 miles 45% South West

更新: 看来 http://postgis.net/docs/ST_Project.html 可能是解决方案。

ST_Project('POINT(-74.00 40.71)'::geography, 80467.2, radians(45.0))

但是,我需要引用数据库记录才能做到这一点。不是硬编码。

尝试组合 ST_Project with a CTE - 将 radians 的值调整为您需要的方位角。

WITH j AS (
  SELECT poi::geography AS poi FROM t
)
SELECT 
  ST_AsText(ST_Project(j.poi, 80467.2, radians(90.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(45.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(180.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(135.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(270.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(225.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(360.0)),2),
  ST_AsText(ST_Project(j.poi, 80467.2, radians(315.0)),2)
FROM j;

      st_astext      |      st_astext      |    st_astext     |     st_astext      |      st_astext      |     st_astext      |    st_astext     |      st_astext      
---------------------+---------------------+------------------+--------------------+---------------------+--------------------+------------------+---------------------
 POINT(-73.05 40.71) | POINT(-73.32 41.22) | POINT(-74 39.99) | POINT(-73.33 40.2) | POINT(-74.95 40.71) | POINT(-74.67 40.2) | POINT(-74 41.43) | POINT(-74.68 41.22)
(1 Zeile)

注意:图中的缓冲区(圆圈)只是为了说明。