mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 16:43:34 +08:00
geo: Moved the map_projection_* functions and state into a self-contained C++ class
This commit is contained in:
committed by
Matthias Grob
parent
fe23718e2c
commit
8db7a6225b
@@ -447,13 +447,13 @@ bool Geofence::insideCircle(const PolygonInfo &polygon, double lat, double lon,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!map_projection_initialized(&_projection_reference)) {
|
||||
map_projection_init(&_projection_reference, lat, lon);
|
||||
if (!_projection_reference.isInitialized()) {
|
||||
_projection_reference.initReference(lat, lon);
|
||||
}
|
||||
|
||||
float x1, y1, x2, y2;
|
||||
map_projection_project(&_projection_reference, lat, lon, &x1, &y1);
|
||||
map_projection_project(&_projection_reference, circle_point.lat, circle_point.lon, &x2, &y2);
|
||||
_projection_reference.project(lat, lon, x1, y1);
|
||||
_projection_reference.project(circle_point.lat, circle_point.lon, x2, y2);
|
||||
float dx = x1 - x2, dy = y1 - y2;
|
||||
return dx * dx + dy * dy < circle_point.circle_radius * circle_point.circle_radius;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user