VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
proj.h
Go to the documentation of this file.
1 
2 
3 
4 
5 #pragma once
6 
8 
9 #include <geometry/point.h>
10 #include <matrix/coordTransform.h>
11 
12 #include <vlutil/vlMutex.h>
14 
15 #include <boost/enable_shared_from_this.hpp>
16 #include <boost/optional.hpp>
17 #include <boost/noncopyable.hpp>
18 #include <boost/tuple/tuple.hpp>
19 
20 #include <iosfwd>
21 #include <list>
22 
23 class Coordinate_System;
24 class OGRSpatialReference;
25 
26 namespace osgEarth {
27  class SpatialReference;
28 }
29 
30 namespace MAKVRinTerra
31 {
32 
33 class DtFeatureGeometry;
34 
44 class DT_DLL_features DtProj : public boost::enable_shared_from_this<DtProj>
45 {
46 public:
47  typedef boost::shared_ptr<DtProj> Ptr;
48  typedef boost::shared_ptr<const DtProj> CPtr;
49 
51  typedef boost::error_info<DtProj, DtProj::CPtr> ErrorInfo;
52  typedef boost::tuple<ErrorInfo,ErrorInfo> ConvertErrorInfo;
54  friend class DtTaggedException<DtProj>;
55 
57  {
59  Radians
60  };
61 
63  {
65  LongLat
66  };
67 
69  {
70  public:
71  static Bounds Make(const DtProj& proj);
72 
73  Bounds();
74 
75  Bounds(const DtProj& proj, double xmin, double ymin, double xmax, double ymax);
76  Bounds(const DtProj& proj);
77 
78  bool isValid() const;
79 
80  double xmin() const;
81  double ymin() const;
82  double xmax() const;
83  double ymax() const;
84 
85  const DtProj& projection() const;
86 
87  Bounds makeSubBounds(unsigned x, unsigned y, unsigned xgrid, unsigned ygrid) const;
88  Bounds makeSubBounds(unsigned n, unsigned xgrid, unsigned ygrid) const;
89 
90  private:
91  double myXmin;
92  double myYmin;
93  double myXmax;
94  double myYmax;
96  };
97 
99  static DtProj::CPtr Make(
100  std::string projString, boost::optional<AngleUnits> = boost::optional<AngleUnits>());
101  static DtProj::CPtr Make(const Coordinate_System*);
102  static DtProj::CPtr Make(std::auto_ptr<Coordinate_System>);
103  static DtProj::CPtr Make(const OGRSpatialReference*);
104  static DtProj::CPtr Make(const osgEarth::SpatialReference*);
105 
106  static DtProj::Ptr MakeCopy(const DtProj&);
107 
108  static DtProj::CPtr LocalTopo(const DtProj &, DtPoint localposition);
109 
110  static DtProj::CPtr Geocentric();
111  static DtProj::CPtr FlatEarth();
112  static DtProj::CPtr Geodetic();
113  static DtProj::CPtr GeodeticInDegrees();
114 
115  std::string projString() const;
116 
117  std::string print() const;
118  std::string printDetailed() const;
119 
120  const Coordinate_System* coordinateSystem() const;
121  const DtCoordTransform* transform() const;
122 
124  bool is2D() const;
125 
127  bool isLocal2D() const;
128 
130  bool isRectangular() const;
131 
132  bool isLocalTopo() const;
133 
134  bool inRadians() const;
135  bool inDegrees() const;
136  bool isLatLong() const;
137  bool isLongLat() const;
138 
139  bool isGeodetic() const;
140  bool isGeocentric() const;
141  bool isFlatEarth() const;
142  bool isUTM() const;
143 
144  void setAngleUnits(AngleUnits);
145 
149  bool operator==(const DtProj &) const;
150  bool operator!=(const DtProj & p) const { return !(*this == p); }
152 
156  static void Convert(
157  const DtProj & from, const DtProj & to,
158  long count, int offset, double* x, double* y, double* z);
159 
160  static void Convert(const DtProj & from, const DtProj & to, long count, DtPoint* points);
161  static void Convert(const DtProj & from, const DtProj & to, DtPoint & point);
162  static void Convert(const DtProj & from, const DtProj & to, std::vector<DtPoint> & points);
163  static void Convert(const DtProj & from, const DtProj & to, std::list<DtPoint> & points);
165 
167  static void ConvertToSame2DProjection(DtFeatureGeometry &, DtFeatureGeometry &);
168 
169  struct ProjData
170  {
171  mutable DtMutex mutex;
172  std::string projString;
173  void* context;
174  void* proj;
175 
176  static ProjData* Make(const Coordinate_System*);
177 
178  ProjData();
179  ProjData(std::string);
180  ~ProjData();
181 
182  bool operator==(const ProjData&) const;
183  bool operator!=(const ProjData&) const;
184  };
185 
186 private:
187  //Create a proj from a proj string
188  explicit DtProj(std::string projString, boost::optional<AngleUnits>);
189 
190  //Create a proj from a Coordinate_System object
191  explicit DtProj(std::auto_ptr<Coordinate_System> cs);
192 
193  //Create a topo proj from a reference point
194  explicit DtProj(const DtProj&, DtPoint);
195 
196  //Copy constructor
197  explicit DtProj(const DtProj&);
198 
199  boost::shared_ptr<ProjData> myProjData;
200  boost::shared_ptr<Coordinate_System> myCS;
201  boost::optional<AngleUnits> myAngleUnits;
202  boost::optional<AngleOrder> myAngleOrder;
203  boost::optional<DtCoordTransform> myTransform;
204 };
205 
206 DT_DLL_features std::ostream& operator<<(std::ostream&, const DtProj&);
207 DT_DLL_features std::ostream& operator<<(std::ostream&, const DtProj::Bounds&);
208 
209 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)