Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tumic0 committed Nov 1, 2024
1 parent 244a767 commit b721a82
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/map/dem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,9 @@ DEM::Entry *DEM::loadTile(const Tile &tile)
}
}

double DEM::elevation(const Coordinates &c)
double DEM::elevationLockFree(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;

Expand All @@ -158,23 +152,17 @@ double DEM::elevation(const Coordinates &c)
} else
ele = height(c, e);

_lock.unlock();

return ele;
}

double DEM::elevationLockFree(const Coordinates &c)
double DEM::elevation(const Coordinates &c)
{
Tile tile(floor(c.lon()), floor(c.lat()));
Entry *e = _data.object(tile);
double ele;
if (_dir.isEmpty())
return NAN;

if (!e) {
e = loadTile(tile);
ele = height(c, e);
_data.insert(tile, e, e->data().size() / 1024);
} else
ele = height(c, e);
_lock.lock();
double ele = elevationLockFree(c);
_lock.unlock();

return ele;
}
Expand Down

0 comments on commit b721a82

Please sign in to comment.