Merge branch 'main' of ssh://dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/SimCore
This commit is contained in:
@@ -30,9 +30,10 @@ namespace SimCore {
|
|||||||
|
|
||||||
const SimCore::TrackKind TrackKind_ = UNKNOWN_TRACK;
|
const SimCore::TrackKind TrackKind_ = UNKNOWN_TRACK;
|
||||||
|
|
||||||
|
|
||||||
const WHISPER::SourceType SourceType_;
|
const WHISPER::SourceType SourceType_;
|
||||||
|
|
||||||
|
const SimCore::ObjectSource ObjectSource_;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -44,7 +45,7 @@ namespace SimCore {
|
|||||||
*
|
*
|
||||||
* @return
|
* @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 WHISPER::SourceType getSourceType();
|
||||||
|
|
||||||
|
const SimCore::ObjectSource getObjectSource();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,14 @@ namespace SimCore {
|
|||||||
|
|
||||||
bool isValid();
|
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);
|
bool operator== ( Position &lhs);
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ namespace SimCore {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<K, V> store;
|
std::map<K, V> store;
|
||||||
mutable std::mutex mx;
|
mutable std::mutex mx_;
|
||||||
std::condition_variable c;
|
std::condition_variable c_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -26,31 +26,31 @@ namespace SimCore {
|
|||||||
|
|
||||||
void addValue(K key, V value )
|
void addValue(K key, V value )
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mx);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
store.emplace(key,value);
|
store.emplace(key,value);
|
||||||
c.notify_one();
|
c_.notify_one();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void removePair(K key)
|
void removePair(K key)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mx);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
auto search = store.find(key);
|
auto search = store.find(key);
|
||||||
if (search != store.end()) {
|
if (search != store.end()) {
|
||||||
search = store.erase(search);
|
search = store.erase(search);
|
||||||
}
|
}
|
||||||
c.notify_one();
|
c_.notify_one();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void overRideValue(K key, V newValue)
|
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);
|
auto search = store.find(key);
|
||||||
if (search != store.end()) {
|
if (search != store.end()) {
|
||||||
store[key] = newValue;
|
store[key] = newValue;
|
||||||
}
|
}
|
||||||
c.notify_one();
|
c_.notify_one();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ namespace SimCore {
|
|||||||
|
|
||||||
V getValue(K key)
|
V getValue(K key)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mx);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
V value;
|
V value;
|
||||||
auto search = store.find(key);
|
auto search = store.find(key);
|
||||||
if (search != store.end()) {
|
if (search != store.end()) {
|
||||||
@@ -70,7 +70,7 @@ namespace SimCore {
|
|||||||
|
|
||||||
bool hasKey(K key)
|
bool hasKey(K key)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mx);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
auto search = store.find(key);
|
auto search = store.find(key);
|
||||||
if (search != store.end()) {
|
if (search != store.end()) {
|
||||||
return true;
|
return true;
|
||||||
@@ -84,12 +84,26 @@ namespace SimCore {
|
|||||||
long size()
|
long size()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(std::mutex);
|
std::lock_guard<std::mutex> lock(mx_);
|
||||||
|
|
||||||
return store.size();
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +37,12 @@ namespace SimCore {
|
|||||||
return SourceType_;
|
return SourceType_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SimCore::ObjectSource Track::getObjectSource()
|
||||||
|
{
|
||||||
|
return ObjectSource_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ namespace SimCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double Position::distanceToPosition(Position &p2)
|
std::tuple<double, double> Position::distanceBearingToPosition(Position &p2)
|
||||||
{
|
{
|
||||||
if (valid_) {
|
if (valid_) {
|
||||||
std::lock_guard<std::mutex> lock(mx);
|
std::lock_guard<std::mutex> lock(mx);
|
||||||
@@ -93,12 +93,12 @@ namespace SimCore {
|
|||||||
this->GeodesicPos_[LONGITUDE],
|
this->GeodesicPos_[LONGITUDE],
|
||||||
p2.GeodesicPos_[LATITUDE],
|
p2.GeodesicPos_[LATITUDE],
|
||||||
p2.GeodesicPos_[LONGITUDE],
|
p2.GeodesicPos_[LONGITUDE],
|
||||||
s12);
|
s12,azi1,azi2);
|
||||||
|
|
||||||
return s12;
|
return {s12,azi1};
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
return 0;
|
return {0,0};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user