FIX: fixed a issue where copied positions are alway valid
This commit is contained in:
@@ -63,7 +63,7 @@ namespace SimCore {
|
||||
|
||||
mutable std::mutex mx;
|
||||
|
||||
std::atomic_bool valid_;
|
||||
std::atomic_bool valid_ = false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -6,33 +6,38 @@ namespace SimCore {
|
||||
|
||||
Position::Position():mx()
|
||||
{
|
||||
valid_ = false;
|
||||
earth_ = std::make_unique<GeographicLib::Geocentric>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
geod_ = std::make_unique<GeographicLib::Geodesic>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
wgs84_ = std::make_unique<GeographicLib::Ellipsoid>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
|
||||
valid_ = false;
|
||||
}
|
||||
Position::Position(double X, double Y, double Z):mx()
|
||||
{
|
||||
valid_ = false;
|
||||
earth_ = std::make_unique<GeographicLib::Geocentric>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
geod_ = std::make_unique<GeographicLib::Geodesic>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
wgs84_ = std::make_unique<GeographicLib::Ellipsoid>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
setGeocentricPos( X, Y, Z);
|
||||
|
||||
valid_ = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Position::Position(const Position& other){
|
||||
std::lock_guard<std::mutex> lock(other.mx);
|
||||
GeocentricPos_ = other.GeocentricPos_;
|
||||
GeodesicPos_ = other.GeodesicPos_;
|
||||
std::lock_guard<std::mutex> lock(other.mx);
|
||||
|
||||
earth_ = std::make_unique<GeographicLib::Geocentric>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
geod_ = std::make_unique<GeographicLib::Geodesic>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
wgs84_ = std::make_unique<GeographicLib::Ellipsoid>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
valid_ = true;
|
||||
valid_ = false;
|
||||
if (other.valid_ == true)
|
||||
{
|
||||
this->setGeocentricPos(other.GeocentricPos_[X],other.GeocentricPos_[Y],other.GeocentricPos_[Z]);
|
||||
}
|
||||
// GeocentricPos_ = other.GeocentricPos_;
|
||||
// GeodesicPos_ = other.GeodesicPos_;
|
||||
|
||||
earth_ = std::make_unique<GeographicLib::Geocentric>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
geod_ = std::make_unique<GeographicLib::Geodesic>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
wgs84_ = std::make_unique<GeographicLib::Ellipsoid>(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||
}
|
||||
|
||||
Eigen::Vector3d Position::getGeocentricPos()
|
||||
@@ -129,9 +134,15 @@ namespace SimCore {
|
||||
Position& Position::operator=(const Position other)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(other.mx);
|
||||
GeocentricPos_ = other.GeocentricPos_;
|
||||
GeodesicPos_ = other.GeodesicPos_;
|
||||
valid_ = true;
|
||||
if (other.valid_ == true)
|
||||
{
|
||||
this->setGeocentricPos(other.GeocentricPos_[X],other.GeocentricPos_[Y],other.GeocentricPos_[Z]);
|
||||
}
|
||||
|
||||
// GeocentricPos_ = other.GeocentricPos_;
|
||||
|
||||
// GeodesicPos_ = other.GeodesicPos_;
|
||||
// valid_ = true;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user