在Android code路线中途点 [英] Route half way point on android code

查看:106
本文介绍了在Android code路线中途点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我画线这样的,

我发现用下面code中间点,

and i've found Mid point using below code,

        public void midPoint(double lat1,double lon1,double lat2,double lon2){

        double dLon = Math.toRadians(lon2 - lon1);

        lat1 = Math.toRadians(lat1);
        lat2 = Math.toRadians(lat2);
        lon1 = Math.toRadians(lon1);

        double Bx = Math.cos(lat2) * Math.cos(dLon);
        double By = Math.cos(lat2) * Math.sin(dLon);
        finalLat= Math.toDegrees(Math.atan2(Math.sin(lat1) + Math.sin(lat2), Math.sqrt((Math.cos(lat1) + Bx) * (Math.cos(lat1) + Bx) + By * By)));
        finalLng= Math.toDegrees(lon1 + Math.atan2(By, Math.cos(lat1) + Bx));
    }

它的成功合作。

但我无法找到R - 路线中途点,如何找到在Android路线中途点。我搜索的网页,我发现<一个href=\"http://gis.stackexchange.com/questions/18584/how-to-find-a-point-half-way-between-two-other-points\">http://gis.stackexchange.com/questions/18584/how-to-find-a-point-half-way-between-two-other-points.但是,在这种方法中,哪些值被分配为X,Y,Z ..我不知道。

But i'm unable to find the "R"- Route Half Way point., How to find the route half way point on android. i've searched on web, i found the http://gis.stackexchange.com/questions/18584/how-to-find-a-point-half-way-between-two-other-points. But in this method, what values are being assigned for x,y,z.. i dont know.

或任何其他code找到路线在Android一半。

or any other code to find Route half way on android.

推荐答案

如果你是自己画的线,我假设你是例如绘制线段在第一线段在图像上会垂直(北?)和第二线段水平地将上面的图像(东?)。如果是这样,那么它应该是计算线段的总距离,发现中途距离,然后在特定的顺序中减去线段长度的一件简单的事,直到你不能 - 这是剩下的一点是对的距离中途点沿当前线段。

If you are drawing the line yourself, I'm assuming that you are drawing the line segments e.g. in the image above the first line segment going vertically (North?) on the image and the second line segment going horizontally (East?). If so, then it should be a simple matter of calculating the total distance of the line segments, finding the half-way distance and then subtracting line segment lengths in specific order until you can't - The bit that's left is the distance to the half-way point along the current line segment.

这篇关于在Android code路线中途点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆