从 UTM(纬度、经度)计算方位角

发布于 2024-12-19 01:39:15 字数 288 浏览 4 评论 0原文

我想计算两个地理坐标点之间的相对方位。我已经将坐标转换为 UTM,但需要帮助来确定实际方位。我知道 UTM 仅适用于同区域计算,这很好,因为计算将在非常小的距离上完成。

假设 point1 是我的位置 44.4N,-97.7W point2 是我想要获得相对方位的位置:44.4N,-103.3W

由于点 2 直接位于点 1 的左侧,因此我将其解释为 270 度(北为 0 或 360 度) 。

我找到了这个公式:arctan((y1-y2)/(x1-x2)) 但当我绘制点并测量角度时,它的结果对我来说没有意义。

I want to calculate the relative bearing between two geo-coordinate points. I've gone ahead and converted the coordinates to UTM, but need assistance on figuring out the actual bearing. I'm aware that UTM is only good enough for same-zone calculations, which is fine as the computation will be done across very small distances.

Say point1 is my location 44.4N,-97.7W
and point2 is the location I'd like to get the relative bearing to: 44.4N, -103.3W

Since point 2 is directly to the left of point 1, I'd interpret that as 270 degrees (North being 0 or 360 degrees).

I found this formula: arctan((y1-y2)/(x1-x2))
but it's result don't make sense to me when I plot the points and measure the angles.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒浓于脸红 2024-12-26 01:39:15

仅供参考 - 目前,我正在使用 SQL Server 2008 空间数据类型、空间函数以及我在 Web 上找到的一些 T-SQL 函数。

ALTER FUNCTION dbo.GeographyBearing (
  @Point1 geography,
  @Point2 geography  )
RETURNS FLOAT
AS
BEGIN
  DECLARE @Bearing DECIMAL(18,15)
  DECLARE @Lat1 FLOAT = RADIANS(@Point1.Lat)
  DECLARE @Lat2 FLOAT = RADIANS(@Point2.Lat)
  DECLARE @dLon FLOAT = RADIANS(@Point2.Long - @Point1.Long)
  IF (@Point1.STEquals(@Point2) = 1)
    SET @Bearing = NULL
  ELSE
    SET @Bearing = ATN2(
      SIN(@dLon)*COS(@Lat2),
     (COS(@Lat1)*SIN(@Lat2)) - (SIN(@Lat1)*COS(@Lat2)*COS(@dLon))
    )
    SET @Bearing = (DEGREES(@Bearing) + 360) % 360
  RETURN ISNULL(@Bearing,0);
END
GO


DECLARE @Vienna geography = geography::Point(16.37, 48.21, 4326)
DECLARE @Moscow geography = geography::Point(37.60, 55.75, 4326)
SELECT dbo.GeographyBearing(@Vienna,@Moscow)

FYI- For now, I'm using SQL Server 2008 Spatial Data Types, Spatial Functions, and some T-SQL function I found on the web.

ALTER FUNCTION dbo.GeographyBearing (
  @Point1 geography,
  @Point2 geography  )
RETURNS FLOAT
AS
BEGIN
  DECLARE @Bearing DECIMAL(18,15)
  DECLARE @Lat1 FLOAT = RADIANS(@Point1.Lat)
  DECLARE @Lat2 FLOAT = RADIANS(@Point2.Lat)
  DECLARE @dLon FLOAT = RADIANS(@Point2.Long - @Point1.Long)
  IF (@Point1.STEquals(@Point2) = 1)
    SET @Bearing = NULL
  ELSE
    SET @Bearing = ATN2(
      SIN(@dLon)*COS(@Lat2),
     (COS(@Lat1)*SIN(@Lat2)) - (SIN(@Lat1)*COS(@Lat2)*COS(@dLon))
    )
    SET @Bearing = (DEGREES(@Bearing) + 360) % 360
  RETURN ISNULL(@Bearing,0);
END
GO


DECLARE @Vienna geography = geography::Point(16.37, 48.21, 4326)
DECLARE @Moscow geography = geography::Point(37.60, 55.75, 4326)
SELECT dbo.GeographyBearing(@Vienna,@Moscow)
魂归处 2024-12-26 01:39:15

请在此处找到我的答案相关到开源 坐标转换器。鉴于您的需要,这可能对您有帮助。

Please find here my answer related to an open source coordinates converter. It might be helpfull for you given your need.

燕归巢 2024-12-26 01:39:15

我在Javascript中的回答 http://jsfiddle.net/efwjames/NVhg6/

//stop location - the radii end point
var x1 = 44.9631;
var y1 = -93.2492;

//bus location from the southeast - the circle center
var x2 = 44.95517;
var y2 = -93.2427;

var radians = getAtan2((y1 - y2), (x1 - x2));

function getAtan2(y, x) {
    return Math.atan2(y, x);
};

$("#output").text(radians);
var newdeg = radians * (180 / Math.PI);

$("#deg").append(newdeg);

var coordNames = ["N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"];
var directionid = Math.round(newdeg / 45);
if (directionid < 0) {
    directionid = directionid + 8
};

$("#dir").append("The vehicle is moving " + coordNames[directionid]);

My answer in Javascript http://jsfiddle.net/efwjames/NVhg6/

//stop location - the radii end point
var x1 = 44.9631;
var y1 = -93.2492;

//bus location from the southeast - the circle center
var x2 = 44.95517;
var y2 = -93.2427;

var radians = getAtan2((y1 - y2), (x1 - x2));

function getAtan2(y, x) {
    return Math.atan2(y, x);
};

$("#output").text(radians);
var newdeg = radians * (180 / Math.PI);

$("#deg").append(newdeg);

var coordNames = ["N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"];
var directionid = Math.round(newdeg / 45);
if (directionid < 0) {
    directionid = directionid + 8
};

$("#dir").append("The vehicle is moving " + coordNames[directionid]);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文