【问题标题】:Increment meters to Latitude and Longitude将米增加到纬度和经度
【发布时间】:2013-11-17 04:33:08
【问题描述】:

我正在使用 Google 地图 v2 开发 Android 应用程序。在我的情况下,我有几个点具有相同的 LA/LO,这会产生一些 UX 问题,一个是在地图上选择点……所以我需要用相同的 LA/LO 获得这些点,并为每个点添加一些米,例如50m有一个很好的距离,它可以避免这些问题。如何进行此计算以增加 LA/LO 上的仪表?

非常感谢!

【问题讨论】:

标签: java android google-maps


【解决方案1】:

这是一个方法,它采用坐标、距离(米)和方位角(度)并返回 新坐标。

public static Coordinate calcEndPoint(Coordinate center , int distance, double  bearing)
  {
      Coordinate gp=null;

      double R = 6371000; // meters , earth Radius approx
      double PI = 3.1415926535;
      double RADIANS = PI/180;
      double DEGREES = 180/PI;

      double lat2;
      double lon2;

      double lat1 = center.getDoubleLat() * RADIANS;
      double lon1 = center.getDoubleLon() * RADIANS;
      double radbear = bearing * RADIANS;

     // System.out.println("lat1="+lat1 + ",lon1="+lon1);

      lat2 = Math.asin( Math.sin(lat1)*Math.cos(distance / R) +
              Math.cos(lat1)*Math.sin(distance/R)*Math.cos(radbear) );
      lon2 = lon1 + Math.atan2(Math.sin(radbear)*Math.sin(distance / R)*Math.cos(lat1),
                     Math.cos(distance/R)-Math.sin(lat1)*Math.sin(lat2));

     // System.out.println("lat2="+lat2*DEGREES + ",lon2="+lon2*DEGREES);

      gp = new Coordinate( lon2*DEGREES, lat2*DEGREES);

      return(gp);
  }

【讨论】:

    猜你喜欢
    • 2013-02-21
    • 2022-12-05
    • 1970-01-01
    • 2011-07-06
    • 2011-08-16
    • 2010-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多