2011-09-28 56 views
0

我想找到这是从当前点一些X公里比如说A点, Example如何查找给定点的经度和纬度,给定两个点之间的距离?

如果我知道中心点的纬度和经度我怎样才能获得的纬度,在周边四个点的经度。 ...我正在寻找相当长的时间,但无法使用JavaScript或Java获得解决方案......距离在我的情况下将会在几公里内,因此不能将地球视为平坦的表面,所以PLZ不建议这样的解决方案...

感谢

+0

是它只有四个你想圆随机点? – Atheist

+0

在上面的示例行中没有点触及圆周....在0,90,180,270度 – aProgrammer

+0

有几点供您考虑 - 圆上的所有点将是距离中心所需的距离,而不仅仅是4.-每度变化的公里数是经度/纬度不是一个常数 - 一旦确定了应使用什么因子将公里转换为纬度/经度的度数变化,这应该很容易,如果您还知道一个圆的方程,给定它的半径和中心坐标。 – amal

回答

5

看看at this page这很详细解释了距离c球状模型用JavaScript代码示例:

给定起点,初始方位和距离,这将计算沿着(最短距离)大圆弧行进的目标点和最终方位。

的JavaScript:

var lat2 = Math.asin(Math.sin(lat1)*Math.cos(d/R) + 
         Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng)); 
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1), 
          Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2)); 
+0

感谢您的快速回复@Andrey ...我正在尝试遵循这个标准的时间长达几个小时......我感到困惑的地方仅仅是您在回答中提到的代码片段的上面一行......'d/R是角度距离(以弧度为单位),其中d是行进距离,R是地球半径.. ..我有Kms的距离,我可以如何将其改变为指定的格式....帮助! – aProgrammer

+0

你看过http://www.movable-type.co.uk/scripts/latlon.js吗? LatLon.prototype.destinationPoint =函数(brng,dist)? dist = dist/this._radius; ? –

2

我被砸伤以上直到我并没有意识到这两个纬度和经度是弧度值的代码! 你必须将它们转换回度数,你会看到真正的价值。

下面是代码

public class cal 
{   
    public static void main(String []args){ 
     double R = 6371.0; 
     double d = 0.100; 
     double lat1 = 42.873, lon1 = 74.568; 
     double Radlat1 = Math.toRadians(42.873); 
     double Radlon1 = Math.toRadians(74.568); 
     double brng = Math.toRadians(225); 
     double lat2,lon2; 

     System.out.println("Hello World"); 
     //lat2 = Math.sin(); 

     lat2 = Math.asin(Math.sin(Radlat1)*Math.cos(d/R) + 
         Math.cos(Radlat1)*Math.sin(d/R)*Math.cos(brng)); 



     System.out.println("Lat2degree"+"="+Math.toDegrees(lat2)+"\n"+"Lat2="+lat2); 

     double NewRadLat2 = Math.toRadians(Math.toDegrees(lat2)); 


     lon2 = Radlon1+Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(Radlat1), 
          Math.cos(d/R)-Math.sin(Radlat1)*Math.sin(lat2)); 

     System.out.println("Lon2"+"="+Math.toDegrees(lon2)); 

    } 
} 
相关问题