USe a common default geodesic object instead of duplicate copies.

All used functions are constant, and don't require unique instantiations for thread safety.
This commit is contained in:
Dan Paulat 2023-02-19 15:16:34 -06:00
parent 4a31cf6d3e
commit 90c8c0183a
10 changed files with 89 additions and 47 deletions

View file

@ -2,6 +2,7 @@
#include <scwx/qt/config/county_database.hpp>
#include <scwx/qt/manager/text_event_manager.hpp>
#include <scwx/qt/types/qt_types.hpp>
#include <scwx/qt/util/geographic_lib.hpp>
#include <scwx/common/geographic.hpp>
#include <scwx/util/logger.hpp>
#include <scwx/util/strings.hpp>
@ -9,7 +10,6 @@
#include <format>
#include <GeographicLib/Geodesic.hpp>
#include <QApplication>
#include <QFontMetrics>
@ -47,7 +47,7 @@ public:
QList<types::TextEventKey> textEventKeys_;
GeographicLib::Geodesic geodesic_;
const GeographicLib::Geodesic& geodesic_;
std::unordered_map<types::TextEventKey,
common::Coordinate,
@ -357,8 +357,7 @@ void AlertModel::HandleMapUpdate(double latitude, double longitude)
AlertModelImpl::AlertModelImpl() :
textEventManager_ {manager::TextEventManager::Instance()},
textEventKeys_ {},
geodesic_(GeographicLib::Constants::WGS84_a(),
GeographicLib::Constants::WGS84_f()),
geodesic_(util::GeographicLib::DefaultGeodesic()),
distanceMap_ {},
distanceDisplay_ {scwx::common::DistanceType::Miles},
previousPosition_ {}
@ -381,7 +380,7 @@ std::string AlertModelImpl::GetCounties(const types::TextEventKey& key)
}
std::sort(counties.begin(), counties.end());
return util::ToString(counties);
return scwx::util::ToString(counties);
}
std::string AlertModelImpl::GetState(const types::TextEventKey& key)
@ -390,7 +389,7 @@ std::string AlertModelImpl::GetState(const types::TextEventKey& key)
auto& lastMessage = messageList.back();
size_t segmentCount = lastMessage->segment_count();
auto lastSegment = lastMessage->segment(segmentCount - 1);
return util::ToString(lastSegment->header_->ugc_.states());
return scwx::util::ToString(lastSegment->header_->ugc_.states());
}
std::chrono::system_clock::time_point
@ -404,7 +403,7 @@ AlertModelImpl::GetStartTime(const types::TextEventKey& key)
std::string AlertModelImpl::GetStartTimeString(const types::TextEventKey& key)
{
return util::TimeString(GetStartTime(key));
return scwx::util::TimeString(GetStartTime(key));
}
std::chrono::system_clock::time_point
@ -419,7 +418,7 @@ AlertModelImpl::GetEndTime(const types::TextEventKey& key)
std::string AlertModelImpl::GetEndTimeString(const types::TextEventKey& key)
{
return util::TimeString(GetEndTime(key));
return scwx::util::TimeString(GetEndTime(key));
}
} // namespace model

View file

@ -1,13 +1,12 @@
#include <scwx/qt/model/radar_site_model.hpp>
#include <scwx/qt/config/radar_site.hpp>
#include <scwx/qt/types/qt_types.hpp>
#include <scwx/qt/util/geographic_lib.hpp>
#include <scwx/common/geographic.hpp>
#include <scwx/util/logger.hpp>
#include <format>
#include <GeographicLib/Geodesic.hpp>
namespace scwx
{
namespace qt
@ -36,7 +35,7 @@ public:
QList<std::shared_ptr<config::RadarSite>> radarSites_;
GeographicLib::Geodesic geodesic_;
const GeographicLib::Geodesic& geodesic_;
std::unordered_map<std::string, double> distanceMap_;
scwx::common::DistanceType distanceDisplay_;
@ -186,8 +185,7 @@ void RadarSiteModel::HandleMapUpdate(double latitude, double longitude)
RadarSiteModelImpl::RadarSiteModelImpl() :
radarSites_ {},
geodesic_(GeographicLib::Constants::WGS84_a(),
GeographicLib::Constants::WGS84_f()),
geodesic_(util::GeographicLib::DefaultGeodesic()),
distanceMap_ {},
distanceDisplay_ {scwx::common::DistanceType::Miles},
previousPosition_ {}