将距离添加到特定的纬度/经度位置 [英] Add distance to a particular latitude/longitude position

查看:144
本文介绍了将距离添加到特定的纬度/经度位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails 4 + Postgres.地理空间新手.很高兴接受涉及RGeo,Geokit,Geocoder或任何其他可帮助解决此问题的宝石的解决方案.

Rails 4 + Postgres. New to geospatial. Happy to accept solutions that involve RGeo, Geokit, Geocoder, or any other gem that helps solve this issue.

模型包含两个字段latitudelongitude.

我有一个offset属性,它包含一个以米为单位的距离,一个orientation属性,它包含四个基本方向(N,E,W,S)之一.

I have an offset attribute that contains a distance in meters and an orientation attribute that contains one of the 4 cardinal directions (N, E, W, S).

示例: offset: 525.5 orientation: W

Example: offset: 525.5 orientation: W

offset距离加到lat-long位置上的标准方法是什么,以便通过距离相加得到一个新的lat-long对?

What's a standard way of adding the offset distance to the lat-long position, to give me a new lat-long pair as the result of the distance addition?

推荐答案

进行了一些挖掘,结果发现存在一个奇异的库函数(考虑了曲率,几何,投影,位置和位置).数学假设),这有助于增加到特定表面位置的距离.

It took a little bit of digging, and it turns out that there is a singular-ish library function (accounting for curvature, geometric, projection, location & mathematical assumptions) that helps add a distance to a specific surface position.

功能:ST_Project

在以下使用:

SELECT ST_AsGeoJSON(ST_Project('POINT(longitude latitude)'::geography, offset, radians(orientation)))

SELECT ST_AsGeoJSON(ST_Project('POINT(longitude latitude)'::geography, offset, radians(orientation)))

它来自PostGIS,因此可以在Ruby/Rails中使用,尽管还不能作为本机Ruby对象(宝石还没有包装它),但是可以作为PostGIS查询.

It's from PostGIS and therefore useable in Ruby/Rails, although not yet as native Ruby objects (gems haven't wrapped it yet), but as a PostGIS query instead.

offset以米为单位. orientation以度为单位("N" = 0,"E" = 90,等等)

offset is in meters. orientation is in degrees ('N'=0, 'E'=90, etc.)

希望这种解决方案可以帮助其他人寻找相同的东西.

Hopefully, this solution helps others looking for the same thing.

这篇关于将距离添加到特定的纬度/经度位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆