ADD: added source to track

This commit is contained in:
Henry Winkel
2023-03-30 10:24:29 +02:00
parent 2f1d67b17a
commit f53fa3e32d
5 changed files with 54 additions and 22 deletions

View File

@@ -30,8 +30,9 @@ namespace SimCore {
const SimCore::TrackKind TrackKind_ = UNKNOWN_TRACK;
const WHISPER::SourceType SourceType_;
const WHISPER::SourceType SourceType_;
const SimCore::ObjectSource ObjectSource_;
@@ -44,7 +45,7 @@ namespace SimCore {
*
* @return
*/
Track( WHISPER::SourceType src,SimCore::Identifier id, SimCore::TrackKind trackkind);
Track( WHISPER::SourceType src,SimCore::Identifier id, SimCore::TrackKind trackkind,SimCore::ObjectSource ObjectSource = EXTERNAL);
@@ -54,6 +55,9 @@ namespace SimCore {
const WHISPER::SourceType getSourceType();
const SimCore::ObjectSource getObjectSource();
protected:

View File

@@ -37,7 +37,14 @@ namespace SimCore {
bool isValid();
double distanceToPosition(Position &p2);
/**
* @brief calculates the disatance and the bearing from this->position to the other position
*
* @param Position
*
* @return std::tuple<double distance, double bearing>
*/
std::tuple<double, double> distanceBearingToPosition(Position &p2);
bool operator== ( Position &lhs);

View File

@@ -12,8 +12,8 @@ namespace SimCore {
private:
std::map<K, V> store;
mutable std::mutex mx;
std::condition_variable c;
mutable std::mutex mx_;
std::condition_variable c_;
protected:
@@ -26,31 +26,31 @@ namespace SimCore {
void addValue(K key, V value )
{
std::lock_guard<std::mutex> lock(mx);
std::lock_guard<std::mutex> lock(mx_);
store.emplace(key,value);
c.notify_one();
c_.notify_one();
}
void removePair(K key)
{
std::lock_guard<std::mutex> lock(mx);
std::lock_guard<std::mutex> lock(mx_);
auto search = store.find(key);
if (search != store.end()) {
search = store.erase(search);
}
c.notify_one();
c_.notify_one();
}
void overRideValue(K key, V newValue)
{
std::lock_guard<std::mutex> lock(mx);
std::lock_guard<std::mutex> lock(mx_);
auto search = store.find(key);
if (search != store.end()) {
store[key] = newValue;
}
c.notify_one();
c_.notify_one();
}
@@ -58,7 +58,7 @@ namespace SimCore {
V getValue(K key)
{
std::lock_guard<std::mutex> lock(mx);
std::lock_guard<std::mutex> lock(mx_);
V value;
auto search = store.find(key);
if (search != store.end()) {
@@ -70,7 +70,7 @@ namespace SimCore {
bool hasKey(K key)
{
std::lock_guard<std::mutex> lock(mx);
std::lock_guard<std::mutex> lock(mx_);
auto search = store.find(key);
if (search != store.end()) {
return true;
@@ -84,12 +84,26 @@ namespace SimCore {
long size()
{
std::lock_guard<std::mutex> lock(std::mutex);
std::lock_guard<std::mutex> lock(mx_);
return store.size();
}
const V& operator[](const K& key) const
{
std::lock_guard<std::mutex> lock(mx_);
return store.at(key);
}
V& operator[](const K& key)
{
std::lock_guard<std::mutex> lock(mx_);
return store[key];
}
};

View File

@@ -17,7 +17,8 @@ namespace SimCore {
Track::Track( WHISPER::SourceType src,SimCore::Identifier id, SimCore::TrackKind trackkind):ID_(id),TrackKind_(trackkind),SourceType_(src)
Track::Track( WHISPER::SourceType src,SimCore::Identifier id, SimCore::TrackKind trackkind,SimCore::ObjectSource ObjectSource )
:ID_(id),TrackKind_(trackkind),SourceType_(src),ObjectSource_(ObjectSource)
{
}
@@ -36,6 +37,12 @@ namespace SimCore {
return SourceType_;
}
const SimCore::ObjectSource Track::getObjectSource()
{
return ObjectSource_;
}
}

View File

@@ -84,7 +84,7 @@ namespace SimCore {
}
double Position::distanceToPosition(Position &p2)
std::tuple<double, double> Position::distanceBearingToPosition(Position &p2)
{
if (valid_) {
std::lock_guard<std::mutex> lock(mx);
@@ -93,12 +93,12 @@ namespace SimCore {
this->GeodesicPos_[LONGITUDE],
p2.GeodesicPos_[LATITUDE],
p2.GeodesicPos_[LONGITUDE],
s12);
s12,azi1,azi2);
return s12;
return {s12,azi1};
}else
{
return 0;
return {0,0};
}
}