地图相关问题

作者: Android戴勤学 | 来源:发表于2019-01-04 11:54 被阅读0次

1.获取两个点的航向角

public static double getAngle1(double latA, double lngA, double latB, double lngB) {
        double y = Math.sin(lngB - lngA) * Math.cos(latB);
        double x = Math.cos(latA) * Math.sin(latB) - Math.sin(latA) * Math.cos(latB) * Math.cos(lngB - lngA);
        double bearing = Math.atan2(y, x);
        bearing = Math.toDegrees(bearing);
        if (bearing < 0) {
            bearing = bearing + 360;
        }
        return bearing;
    }

2.获取两点的距离

 /**
     * 得到两点间距离
     * 返回单位是米
     */
    public static double getDistance(double longitude1, double latitude1,
                                     double longitude2, double latitude2) {
        double lat1 = rad(latitude1);
        double lat2 = rad(latitude2);
        double a = lat1 - lat2;
        double b = rad(longitude1) - rad(longitude2);
        double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
                + Math.cos(lat1) * Math.cos(lat2)
                * Math.pow(Math.sin(b / 2), 2)));
        s = s * EARTH_RADIUS;
        s = Math.round(s * 10000) / 10000;
        TagUtils.aLog("两点间距离" + s);
        return s;
    }

    private static double rad(double d) {
        return d * Math.PI / 180.0;
    }

相关文章

  • 地图相关问题

    1.获取两个点的航向角 2.获取两点的距离

  • MKMapView地图相关问题总结

    前段时间,在项目上做了一些地图相关的功能,解决了三个特殊需求,在此总结一下,以备日后使用: 1. MKOverla...

  • 小O地图 - 解决地图KEY无效的问题

    问题现象 用户过多导致软件内置地图KEY失效,此时地图上会出现【地图KEY无效】的提示,同时部分地图相关功能将不可...

  • "invalid Region <center:

    问题 昨天在使用地图时,一直崩溃...关键特么不报具体错误...and 这段地图相关代码之前用过,一直没有问题.....

  • 百度地图使用-大头针的自定义

    最近老看到iOS开发群里有人问有关百度地图的问题,正好研究过百度地图,今天我就把自己集成百度地图相关功能和遇到问题...

  • 地图相关

    https://www.jianshu.com/p/45c33e567aec MapKit框架https://ww...

  • 地图相关

  • 地图相关

    SurfaceView 开发 60 帧地图InDoorView万物RxJava(1):封装高德地图APIAndro...

  • 地图相关

    #import "ViewController.h" #import 《CoreLocation/CoreLoca...

  • 地图相关

网友评论

    本文标题:地图相关问题

    本文链接:https://www.haomeiwen.com/subject/skyhrqtx.html