ADD: added source to track
This commit is contained in:
@@ -29,9 +29,10 @@ namespace SimCore {
|
||||
const SimCore::Identifier ID_;
|
||||
|
||||
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:
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,10 +84,24 @@ 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];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,6 +36,12 @@ namespace SimCore {
|
||||
{
|
||||
return SourceType_;
|
||||
}
|
||||
|
||||
const SimCore::ObjectSource Track::getObjectSource()
|
||||
{
|
||||
return ObjectSource_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -83,8 +83,8 @@ namespace SimCore {
|
||||
valid_ = true;
|
||||
}
|
||||
|
||||
|
||||
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};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user