矩形地理围栏代码 [英] rectangular geo fence code

查看:203
本文介绍了矩形地理围栏代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试实现矩形的地理围栏.

我正在从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.

推荐答案

矩形或圆形围栏与编程相似.

不规则形状的围栏会更坚固.

怎么样....

A rectangular or circular fence would be of similar ease to program.

A fence of an irregular shape would be tougher.

How about....

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.


这篇关于矩形地理围栏代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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