Skip to content

Commit

Permalink
mavproxy_map/mavproxy_elevation: fix behaviour when no terrain module
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Aug 7, 2023
1 parent f4b3b62 commit 1dd5fc6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions MAVProxy/modules/lib/mp_elevation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ElevationModel():
def __init__(self, database='SRTM3', offline=0, debug=False, cachedir=None):
'''Use offline=1 to disable any downloading of tiles, regardless of whether the
tile exists'''
if database.lower() == 'srtm':
if database is not None and database.lower() == 'srtm':
# compatibility with the old naming
database = "SRTM3"
self.database = database
Expand All @@ -40,7 +40,7 @@ def __init__(self, database='SRTM3', offline=0, debug=False, cachedir=None):
self.mappy = GAreader.ERMap()
self.mappy.read_ermapper(os.path.join(os.environ['HOME'], './Documents/Elevation/Canberra/GSNSW_P756demg'))
else:
print("Error: Bad terrain source " + database)
print("Error: Bad terrain source " + str(database))
self.database = None

def GetElevation(self, latitude, longitude, timeout=0):
Expand Down
6 changes: 5 additions & 1 deletion MAVProxy/modules/mavproxy_map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ def __init__(self, mpstate):
title = "Map"
if self.instance > 1:
title += str(self.instance)
self.map = mp_slipmap.MPSlipMap(service=service, elevation=self.module('terrain').ElevationModel.database, title=title)
elevation = None
terrain_module = self.module('terrain')
if terrain_module is not None:
elevation = terrain_module.ElevationModel.database
self.map = mp_slipmap.MPSlipMap(service=service, elevation=elevation, title=title)
if self.instance == 1:
self.mpstate.map = self.map
mpstate.map_functions = { 'draw_lines' : self.draw_lines }
Expand Down

0 comments on commit 1dd5fc6

Please sign in to comment.