<分区>
以下函数将从点collectLatlong 的 vector 中获取点(纬度 - 经度),并检查点 1 到点 2 之间的距离是否在 100 米到 140 米的范围内,如果是,则点 2 将被存储在一个单独的点 vector filteredpoints 中。
然后从 point2 开始计算 collectLatlong vector 中下一个点之间的距离,这样 collectLatlong 中的所有点都会被迭代。
函数组成
1) vector 中点的经纬度集合——collectLatlong
2) calculateDistance 函数用于计算两点之间的距离(lat-lon)
3) 它使用 QGIS API 。 QgsPoint表示QT中类似于两个QPoint的一个点(lat-long point)。
4) 我在 ubuntu 中使用 QT。
问题:
此函数将在运行时在 collectLatlong 中收集点后调用此函数后,如果 collectLatlong 中的点数较少,应用程序将执行良好,但如果它更多的应用程序没有响应任何其他操作最终我需要杀死应用程序来关闭它。
请随时询问有关我的问题的问题。
帮我解决这个问题。谢谢。
void filterPoints()
{
int size=collectLatlong.size()-1;
float Dis;
int A2= 0, B2 = 5;
Loop:
if(B2<=size)
{
QgsPoint a = collectLatlong[A2] ; QgsPoint b = collectLatlong[B2];
Dis = calculateDistance(a,b);
if(Dis >= 100 && Dis <= 140)
{
filteredpoint.push_back(b);
A2=B2; B2=B2+5;
goto Loop;
}
else if (Dis<100)
{
B2++;
goto Loop;
}
else
{
B2--;
goto Loop;
}
}
}
float calculateDistance(const QgsPoint& a, const QgsPoint& b)
{
double pi = 3.14/180.0;
double Ab,c,d , dLat,dLon,lat1,lat2,lon1,lon2;
int R= 6371;
lat1=a.y()*pi; lat2=b.y()*pi;
lon1=a.x()*pi; lon2=b.x()*pi;
dLat = lat2-lat1;
dLon = lon2-lon1;
Ab = sin(dLat/2)*sin(dLat/2)+sin(dLon/2)*sin(dLon/2)*cos(lat1)*cos(lat2);
c = 2*atan2(sqrt(Ab),sqrt(1-Ab));
d=R*c*1000;
return d;
}