From f665668e3b0ba6be44e5e7dd931bf93dffdd27b6 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 30 Sep 2024 09:18:48 +1000 Subject: [PATCH] mp_slipmap_util.py: tidy calculation of gridlines ... by moving loop invariant calculations to outside loop --- MAVProxy/modules/mavproxy_map/mp_slipmap_util.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py b/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py index 88f7e0e342..aff9d6853e 100644 --- a/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py +++ b/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py @@ -357,11 +357,10 @@ def draw(self, img, pixmapper, bounds): (lat,lon,w,h) = bounds # note that w and h are in degrees spacing = 1000 + lat2 = mp_util.constrain(lat+h*0.5,-85,85) + lon2 = mp_util.wrap_180(lon+w) + dist = mp_util.gps_distance(lat2,lon,lat2,lon2) while True: - start = mp_util.latlon_round((lat,lon), spacing) - lat2 = mp_util.constrain(lat+h*0.5,-85,85) - lon2 = mp_util.wrap_180(lon+w) - dist = mp_util.gps_distance(lat2,lon,lat2,lon2) count = int(dist / spacing) if count < 2: spacing /= 10.0 @@ -372,6 +371,8 @@ def draw(self, img, pixmapper, bounds): count += 10 + start = mp_util.latlon_round((lat,lon), spacing) + for i in range(count): # draw vertical lines of constant longitude pos1 = mp_util.gps_newpos(start[0], start[1], 90, i*spacing)