neic-glass3  1.4.6
Site.h
Go to the documentation of this file.
1 /*****************************************
2  * This file is documented for Doxygen.
3  * If you modify this file please update
4  * the comments so that Doxygen will still
5  * be able to work.
6  ****************************************/
7 #ifndef SITE_H
8 #define SITE_H
9 
10 #include <json.h>
11 #include <geo.h>
12 #include <set>
13 #include <string>
14 #include <vector>
15 #include <memory>
16 #include <utility>
17 #include <tuple>
18 #include <mutex>
19 #include <atomic>
20 #include "Link.h"
21 #include "Pick.h"
22 
23 namespace glasscore {
24 
25 // forward declarations
26 class CNode;
27 class CTrigger;
28 class CHypo;
29 class CPickList;
30 
38  bool operator()(const std::shared_ptr<CPick> &lhs,
39  const std::shared_ptr<CPick> &rhs) const {
40  if (lhs->getTSort() < rhs->getTSort()) {
41  return (true);
42  }
43  return (false);
44  }
45 };
46 
69 class CSite {
70  public:
77  CSite();
78 
102  CSite(std::string sta, std::string comp, std::string net, std::string loc,
103  double lat, double lon, double elv, double qual, bool enable,
104  bool useTele);
105 
114  explicit CSite(std::shared_ptr<json::Object> site);
115 
119  ~CSite();
120 
124  void clear();
125 
135  void update(CSite *site);
136 
161  bool initialize(std::string sta, std::string comp, std::string net,
162  std::string loc, double lat, double lon, double elv,
163  double qual, bool enable, bool use, bool useTele);
164 
174  void setLocation(double lat, double lon, double z);
175 
185  double getDelta(glass3::util::Geo *geo2);
186 
193  double getDistance(std::shared_ptr<CSite> site);
194 
202  void addPick(std::shared_ptr<CPick> pck);
203 
211  void removePick(std::shared_ptr<CPick> pck);
212 
226  std::vector<std::shared_ptr<CPick>> getPicks(double t1, double t2);
227 
244  void addNode(std::shared_ptr<CNode> node, double distDeg,
245  double travelTime1, std::string phase1,
246  double travelTime2 = -1, std::string phase2 = "");
247 
254  void removeNode(std::string nodeID);
255 
271  std::vector<std::shared_ptr<CTrigger>> nucleate(double tpick,
272  CPickList* parentThread);
273 
282  void addTriggerToList(std::vector<std::shared_ptr<CTrigger>> *vTrigger,
283  std::shared_ptr<CTrigger> trigger);
284 
290  int getNodeLinksCount() const;
291 
298  bool getEnable() const;
299 
306  void setEnable(bool enable);
307 
315  bool getIsUsed() const;
316 
322  bool getUse() const;
323 
331  void setUse(bool use);
332 
339  bool getUseForTeleseismic() const;
340 
347  void setUseForTeleseismic(bool useForTele);
348 
353  double getQuality() const;
354 
359  void setQuality(double qual);
360 
366  double getRawLatitude() const;
367 
373  double getRawLongitude() const;
374 
380  double getRawElevation() const;
381 
387  glass3::util::Geo &getGeo();
388 
394  const std::string& getSCNL() const;
395 
400  const std::string& getSite() const;
401 
406  const std::string& getComponent() const;
407 
412  const std::string& getNetwork() const;
413 
418  const std::string& getLocation() const;
419 
425  time_t getTLastPickAdded() const;
426 
432  double * getUnitVectors(double * vec);
433 
439  int getPickCountSinceCheck() const;
440 
446  void setPickCountSinceCheck(int count);
447 
453  int getPickCount() const;
454 
462  std::multiset<std::shared_ptr<CPick>, SitePickCompare>::iterator getLower(
463  double min);
464 
472  std::multiset<std::shared_ptr<CPick>, SitePickCompare>::iterator getUpper(
473  double max);
474 
479  std::multiset<std::shared_ptr<CPick>, SitePickCompare>::iterator getEnd();
480 
485  std::mutex & getPickMutex();
486 
492  void updatePosition(std::shared_ptr<CPick> pick);
493 
494  private:
499  void eraseFromMultiset(std::shared_ptr<CPick> pick);
500 
504  mutable std::mutex vPickMutex;
505 
510  std::multiset<std::shared_ptr<CPick>, SitePickCompare> m_msPickList;
511 
516  std::string m_sSCNL;
517 
521  std::string m_sSite;
522 
526  std::string m_sComponent;
527 
531  std::string m_sNetwork;
532 
536  std::string m_sLocation;
537 
541  glass3::util::Geo m_Geo;
542 
547  std::atomic<double> m_dRawLatitude;
548 
553  std::atomic<double> m_dRawLongitude;
554 
559  std::atomic<double> m_dRawElevation;
560 
565  double m_daUnitVectors[3];
566 
572  std::atomic<bool> m_bEnable;
573 
577  std::atomic<bool> m_bUse;
578 
583  std::atomic<bool> m_bUseForTeleseismic;
584 
588  std::atomic<double> m_dQuality;
589 
594  std::atomic<int> m_iPickCountSinceCheck;
595 
599  mutable std::mutex m_vNodeMutex;
600 
605  std::vector<NodeLink> m_vNode;
606 
614  mutable std::recursive_mutex m_SiteMutex;
615 
620  std::atomic<double> m_tLastPickAdded;
621 
626  std::shared_ptr<CPick> m_LowerValue;
627 
632  std::shared_ptr<CPick> m_UpperValue;
633 
634  // constants
638  static const int k_iUnitVectorXCoordinateIndex = 0;
639 
643  static const int k_iUnitVectorYCoordinateIndex = 1;
644 
648  static const int k_iUnitVectorZCoordinateIndex = 2;
649 };
650 } // namespace glasscore
651 #endif // SITE_H
glasscore pick list class
Definition: PickList.h:62
CSite comparison function.
Definition: Site.h:37
geographic coordinate conversion class
Definition: geo.h:25
bool operator()(const std::shared_ptr< CPick > &lhs, const std::shared_ptr< CPick > &rhs) const
Definition: Site.h:38
The namespace containing the core algorithm.
Definition: Correlation.h:17
glasscore site (station) class
Definition: Site.h:69