本文介绍了矩形地理围栏代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试实现矩形的地理围栏.
我正在从GPS模块获取纬度和经度坐标,该坐标给出了车辆的当前位置.
停车时,将激活虚拟围栏.该程序应通过定期更新位置来检查车辆是否在边界内,并在发生围栏破坏时提醒用户.
用于上述实现的任何C代码都将非常有帮助.
Hi,
I am trying to implement a rectangular geo fence.
I am getting the latitude and longitude co-ordinates from GPS module which gives the current position of the vehicle.
When the vehicle is parked, a virtual fence is activated. The program should check if the vehicle is within the boundary through regular position updates and alert the user in case of fence breach.
Any C code for the above implementation would be very helpful.
推荐答案
bool IsInFence(double CurrentX, double CurrentY, double ParkedX, double ParkedY, double FenceDistance)
{
double dX = CurrentX - ParkedX;
double dY = CurrentY - ParkedY;
double Distance = sqrt((dX * dX) + (dY * dY));
if (Distance > FenceDistance)
return true;
return false;
}
我会把剩下的功课交给你.
I''ll leave it up to you to finish the rest of your homework.
这篇关于矩形地理围栏代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!