From aaef0b04757061e0260f1e63cca948be71d7bea9 Mon Sep 17 00:00:00 2001 From: "Marek S. Lukasiewicz" Date: Wed, 17 Dec 2025 15:36:43 +0100 Subject: [PATCH] Wrap horizontal aircraft position to map extents --- src/marshconnector.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/marshconnector.cpp b/src/marshconnector.cpp index d43e511..591cf11 100644 --- a/src/marshconnector.cpp +++ b/src/marshconnector.cpp @@ -282,6 +282,10 @@ Vector2 MarshConnector::local_meters_from_global_degrees(double latitude, // Y East is just length along the circle of latitude double y = (lon - lon0) * (EARTH_RADIUS * cos(lat0)); + const double map_size = 3000.0; + x = (Math::fract(x / map_size + 0.5) - 0.5) * map_size; + y = (Math::fract(y / map_size + 0.5) - 0.5) * map_size; + return Vector2(x, y); } void MarshConnector::handle_sim_state(mavlink_message_t message) {