From b721a829b26d576f86b4357e36daf8ab4d48d5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 1 Nov 2024 09:16:32 +0100 Subject: [PATCH] Code cleanup --- src/map/dem.cpp | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/map/dem.cpp b/src/map/dem.cpp index 28e45ba5..0f8f0beb 100644 --- a/src/map/dem.cpp +++ b/src/map/dem.cpp @@ -139,30 +139,6 @@ DEM::Entry *DEM::loadTile(const Tile &tile) } } -double DEM::elevation(const Coordinates &c) -{ - if (_dir.isEmpty()) - return NAN; - - Tile tile(floor(c.lon()), floor(c.lat())); - - _lock.lock(); - - Entry *e = _data.object(tile); - double ele; - - if (!e) { - e = loadTile(tile); - ele = height(c, e); - _data.insert(tile, e, e->data().size() / 1024); - } else - ele = height(c, e); - - _lock.unlock(); - - return ele; -} - double DEM::elevationLockFree(const Coordinates &c) { Tile tile(floor(c.lon()), floor(c.lat())); @@ -179,6 +155,18 @@ double DEM::elevationLockFree(const Coordinates &c) return ele; } +double DEM::elevation(const Coordinates &c) +{ + if (_dir.isEmpty()) + return NAN; + + _lock.lock(); + double ele = elevationLockFree(c); + _lock.unlock(); + + return ele; +} + MatrixD DEM::elevation(const MatrixC &m) { if (_dir.isEmpty())