从UTM(纬度,经度)计算方位

时间:2011-12-01 14:58:33

标签: geolocation gps coordinates coordinate-transformation utm

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

说点1是我的位置44.4N,-97.7W 和point2是我想得到的相对位置:44.4N,-103.3W

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

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

3 个答案:

答案 0 :(得分:1)

仅供参考 - 目前,我正在使用SQL Server 2008空间数据类型,空间函数和我在网络上找到的一些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)

答案 1 :(得分:0)

请查看here我与开源coordinates converter相关的答案。根据您的需要,它可能对您有所帮助。

答案 2 :(得分:0)

我在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]);