Skip to content

Commit a241e8f

Browse files
MichelleRostridge
authored andcommitted
map: Show grid spacing
1 parent dbfe12f commit a241e8f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

MAVProxy/modules/mavproxy_map/mp_slipmap_ui.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ def __init__(self, parent, state):
355355
self.last_click_pos = None
356356
self.last_click_pos_used_for_text = None
357357
self.last_terrain_height = None
358+
self.grid_spacing = None
358359
if state.elevation != "None":
359360
state.ElevationMap = mp_elevation.ElevationModel(database=state.elevation)
360361

@@ -479,6 +480,10 @@ def update_position(self):
479480
alt = state.ElevationMap.GetElevation(lat, lon)
480481
if alt is not None:
481482
newtext += ' %.1fm %uft' % (alt, alt*3.28084)
483+
484+
if self.grid_spacing is not None:
485+
newtext += f" Grid Spacing: {self.grid_spacing:.0f}m"
486+
482487
state.mt.set_download(state.download)
483488
pending = 0
484489
if state.download:
@@ -594,7 +599,9 @@ def redraw_map(self):
594599

595600
# possibly draw a grid
596601
if state.grid:
597-
SlipGrid('grid', layer=3, linewidth=1, colour=(255,255,0)).draw(img, self.pixmapper, bounds)
602+
self.grid_spacing = SlipGrid('grid', layer=3, linewidth=1, colour=(255,255,0)).draw(img, self.pixmapper, bounds)
603+
else:
604+
self.grid_spacing = None
598605

599606
# draw layer objects
600607
keys = state.layers.keys()

MAVProxy/modules/mavproxy_map/mp_slipmap_util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def draw_line(self, img, pixmapper, pt1, pt2, colour, linewidth):
357357
def draw(self, img, pixmapper, bounds):
358358
'''draw a polygon on the image'''
359359
if self.hidden:
360-
return
360+
return None
361361
(lat,lon,w,h) = bounds
362362
# note that w and h are in degrees
363363
spacing = 1000
@@ -387,6 +387,8 @@ def draw(self, img, pixmapper, bounds):
387387
pos1 = mp_util.gps_newpos(start[0], start[1], 0, i*spacing)
388388
pos3 = (pos1[0], pos1[1]+w*2)
389389
self.draw_line(img, pixmapper, pos1, pos3, self.colour, self.linewidth)
390+
391+
return spacing
390392

391393

392394
class SlipFlightModeLegend(SlipObject):

0 commit comments

Comments
 (0)