对于我的应用程序,我必须在Google地图上找到一个点的位置,只知道它位于2个其他点和坐标被捕获时的时间(以毫秒为单位) 。如何找到两个其他点之间的地理点
在我的代码,假设A和B点给出X为找点,我:A和B之间
计算距离
筑底时间我发现了的速度(以微度/ MS)从A行进到B
我发现从点A和点X的距离(使用时间和速度)
使用类似三角形的规则,我计算纬度和X点的经度从A点
此工作流程带来了错误的地图上,所以,往往在X标记不是在A和B标记之间的界线。
我该如何让它更好用?这是全球球形的问题吗?
谢谢大家。
下面是代码:
int ax = oldPoint.getLatitude();
int ay = oldPoint.getLongitude();
int bx = currentPoint.getLatitude();
int by = currentPoint.getLongitude();
long at = oldPoint.getDataRilevamento(); //get time first point
long bt = currentPoint.getDataRilevamento(); // get time second point
long xt = x.getDate(); // time of point to find
int c1 = bx-ax;
int c2 = by-ay;
double hyp = Math.sqrt(Math.pow(c1, 2) + Math.pow(c2, 2));
double vel = hyp/(bt-at);
double pos = vel*(xt - at);
int posx = (int)((pos*c1)/hyp);
int posy = (int)((pos*c2)/hyp);
x.setLatitude(ax+posx); //set the latitude of X
x.setLongitude(ay+posy); // set the longitude of X
你真棒!真的非常感谢你! –
感谢您发布此算法。我需要为我的项目做类似的事情,我相信这样做会的!你介意我把它包装起来并将它作为npm模块发布吗? –
即使超过三年:起首! – 2014-12-11 20:53:18