【问题标题】:Calculate new gps coordinates from 1 set of coordinates and distance?从一组坐标和距离计算新的gps坐标?
【发布时间】:2016-10-01 20:10:09
【问题描述】:

所以我想知道是否存在允许我计算一对新的 gps 坐标的现有代码/库:距离、一对纬度和经度以及方位。

希望大家多多指教

干杯!

【问题讨论】:

  • Here's a link 到以前的答案。您可以使用那里提到的库(如果许可证没问题),或者只是抓住基本想法并编写自己的代码。
  • 嘿,谢谢伙计!我在找什么

标签: java android google-maps distance android-maps-v2


【解决方案1】:

给我的答案来自这个链接:stackoverflow.com/questions/37348207/find-location-1-km-away-in-180-degree-south-from-my-location/37349396#37349396

使用以下库:https://github.com/JavadocMD/simplelatlng 但计算方法如下:

/**
     * <p>
     * Calculate the end point of traveling along a great-circle path from a
     * given starting point with a given intitial bearing for a known distance.
     * </p>
     * 
     * @param start
     *            the starting point.
     * @param initialBearing
     *            the initial bearing.
     * @param distance
     *            the distance to travel.
     * @param unit
     *            the unit in which distance is measured.
     * @return the end point.
     */
    public static LatLng travel(LatLng start, double initialBearing, double distance,
            LengthUnit unit) {
        double bR = Math.toRadians(initialBearing);
        double lat1R = Math.toRadians(start.getLatitude());
        double lon1R = Math.toRadians(start.getLongitude());
        double dR = distance / LatLngConfig.getEarthRadius(unit);

        double a = Math.sin(dR) * Math.cos(lat1R);
        double lat2 = Math.asin(Math.sin(lat1R) * Math.cos(dR) + a * Math.cos(bR));
        double lon2 = lon1R
                + Math.atan2(Math.sin(bR) * a, Math.cos(dR) - Math.sin(lat1R) * Math.sin(lat2));
        return new LatLng(Math.toDegrees(lat2), Math.toDegrees(lon2));
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-26
    • 1970-01-01
    相关资源
    最近更新 更多