Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove used std::mutex
Browse files Browse the repository at this point in the history
MichaelKutzner committed Dec 12, 2024
1 parent bbcbb23 commit 97f0432
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions include/osr/preprocessing/elevation/hgt_def.h
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ struct hgt<RasterSize>::hgt::impl {
impl(std::string const& filename,
std::int8_t const lat,
std::int16_t const lng)
: filename_{filename},
: file_{cista::mmap{filename.data(), cista::mmap::protection::READ}},
sw_lat_(lat),
sw_lng_(lng),
blx_{lng - kStepWidth / 2},
@@ -71,25 +71,15 @@ struct hgt<RasterSize>::hgt::impl {

elevation_t get(std::size_t const offset) {
assert(0 <= offset && offset < RasterSize * RasterSize);
{
auto const l = std::lock_guard{m_};
if (!file_) {
std::cout << "Using HGT file " << filename_ << "\n";
file_ = std::make_optional(
cista::mmap{filename_.data(), cista::mmap::protection::READ});
}
}
auto const byte_ptr = file_->data() + offset;
auto const byte_ptr = file_.data() + offset;
return *reinterpret_cast<std::int16_t const*>(byte_ptr);
}

constexpr step_size get_step_size() const {
return {.x_ = kStepWidth, .y_ = kStepWidth};
}

std::string filename_;
std::optional<cista::mmap> file_{};
std::mutex m_{};
cista::mmap file_{};
// south west
std::int8_t sw_lat_;
std::int16_t sw_lng_;

0 comments on commit 97f0432

Please sign in to comment.