Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Location.h
1 //
2 // Location classes
3 //
4 // Copyright (c) 2002-2007 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef LOCATION_H
9 #define LOCATION_H
10 
11 #include "vtdata/vtString.h"
12 #include "vtdata/Projections.h"
13 #include "vtdata/LocalConversion.h"
14 
15 #if SUPPORT_WSTRING
16  #define LocNameString wstring2
17 #else
18  #define LocNameString std::string
19 #endif
20 
23 
38 {
39 public:
40  vtLocation() {}
41  vtLocation(const vtLocation &v) { *this = v; }
42  vtLocation &operator=(const vtLocation &v)
43  {
44  m_strName = v.m_strName;
45  m_pos1 = v.m_pos1;
46  m_fElevation1 = v.m_fElevation1;
47  m_pos2 = v.m_pos2;
48  m_fElevation2 = v.m_fElevation2;
49  return *this;
50  }
51 
52  LocNameString m_strName;
53 
54  // The two points: "look from" and "look at"
55  DPoint2 m_pos1;
56  float m_fElevation1;
57  DPoint2 m_pos2;
58  float m_fElevation2;
59 };
60 
69 {
70  friend class LocationVisitor;
71 public:
73  vtLocationSaver(const vtString &fname);
74  ~vtLocationSaver();
75 
77  bool Read(const vtString &fname);
78 
80  bool Write(const vtString &fname = "");
81 
82  const vtString &GetFilename() { return m_strFilename; }
83 
85  void Remove(int num);
86 
88  int GetNumLocations() { return m_loc.GetSize(); }
89 
91  vtLocation *GetLocation(int num) const { return m_loc[num]; }
92 
94  int FindLocation(const char *locname);
95 
96  void Empty();
97 
98  // you must call these methods before this class is useful for vtTerrain:
100  void SetTransform(vtTransform *trans) { m_pTransform = trans; }
102  vtTransform *GetTransform() { return m_pTransform; }
103 
105  void SetConversion(const vtLocalConversion &conv) { m_conv = conv; }
106 
108  void SetProjection(const vtProjection &proj);
109  const vtProjection &GetAtProjection() const { return m_proj; }
110 
112  bool StoreTo(uint num, const LocNameString &name = "");
113 
115  bool RecallFrom(int num);
116  bool RecallFrom(const char *name);
117 
118 protected:
119  // Implementation
120  // Store information necessary to convert from global earth CS
121  // to the local CS
122  vtLocalConversion m_conv;
123  vtProjection m_proj;
124  vtTransform *m_pTransform;
125 
126  vtString m_strFilename;
127  OCT *m_pConvertToWGS;
128  OCT *m_pConvertFromWGS;
129 
130  vtArray<vtLocation*> m_loc;
131 };
132  // nav
134 
135 #endif // LOCATION_H