From 711a4fe0c85b379f137f2e832ab0e706dc4e16cb Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Thu, 1 Mar 2018 09:03:25 +0100 Subject: [PATCH] canvas::Map: Preserve default values without new values Ensure default values are used (instead of 0) if no values are specified. --- simgear/canvas/elements/CanvasMap.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/simgear/canvas/elements/CanvasMap.cxx b/simgear/canvas/elements/CanvasMap.cxx index 35763198..866954ac 100644 --- a/simgear/canvas/elements/CanvasMap.cxx +++ b/simgear/canvas/elements/CanvasMap.cxx @@ -199,10 +199,18 @@ namespace canvas _projection = std::make_shared(); _projection->setWorldPosition(_node->getDoubleValue(REF_LAT), - _node->getDoubleValue(REF_LON) ); - _projection->setOrientation(_node->getFloatValue(HDG)); - _projection->setScreenRange(_node->getDoubleValue(SCREEN_RANGE)); - _projection->setRange(_node->getDoubleValue(RANGE)); + _node->getDoubleValue(REF_LON)); + + // Only set existing properties to prevent using 0 instead of default values + + if( auto heading = _node->getChild(HDG) ) + _projection->setOrientation(heading->getFloatValue()); + + if( auto screen_range = _node->getChild(SCREEN_RANGE) ) + _projection->setScreenRange(screen_range->getDoubleValue()); + + if( auto range = _node->getChild(RANGE) ) + _projection->setRange(range->getDoubleValue()); _projection_dirty = true; }