Abstract:With the wide application of unmanned aerial systems (UAS), the problem of UAV flight safety is becoming more and more prominent. In order to meet the demand of UAV cloud for timely warning and efficient control of UAVs in the airspace, a UAV geofencing algorithm is proposed. The pre-processing of the algorithm adopts the ear clipping method to triangulate the horizontal fence, and constructs the triangle adjacency table; the runtime periodically detects whether the drone is inside the fence and generates boundary violation alarms; the altitude fence adopts the altitude boundary restriction detection, and the horizontal fence is based on the adjacency triangle method for the detection of boundary violations, which adopts breadth-first search to search for the triangle that contain the location of UAV, and the starting node of the search is based on the triangle in which the UAV was located in the last time; using the developed simulated UAV cloud system, the UAV horizontal uniform flight simulation is carried out; the simulation results show that: the algorithm is able to quickly and accurately describe the state of the UAV violating the boundary of the geofence, and it is applicable to the three-dimensional geofence that contains both keep-in and keep-out geofences.