VR-Forces Development_Version 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  struct LineSegment
74  {
75  LineSegment(const DtPoint& p1, const DtPoint& p2)
76  : point1(p1), point2(p2) { }
77 
78  DtPoint point1, point2;
79  };
80 
81  Bounds();
82 
83  Bounds(const DtProj& proj, double xmin, double ymin, double xmax, double ymax);
84  Bounds(const DtProj& proj);
85 
86  bool isValid() const;
87 
88  double xmin() const;
89  double ymin() const;
90  double xmax() const;
91  double ymax() const;
92 
93  const DtProj& projection() const;
94 
95  bool intersects(const DtPoint&) const;
96  bool intersects(const LineSegment&, bool* contained = 0) const;
97 
98  Bounds makeSubBounds(unsigned x, unsigned y, unsigned xgrid, unsigned ygrid) const;
99  Bounds makeSubBounds(unsigned n, unsigned xgrid, unsigned ygrid) const;
100 
101  private:
102  double myXmin;
103  double myYmin;
104  double myXmax;
105  double myYmax;
107  };
108 
110  static DtProj::CPtr Make(
111  std::string projString, boost::optional<AngleUnits> = boost::optional<AngleUnits>());
112  static DtProj::CPtr Make(const Coordinate_System*);
113  static DtProj::CPtr Make(std::auto_ptr<Coordinate_System>);
114  static DtProj::CPtr Make(const OGRSpatialReference*);
115  static DtProj::CPtr Make(const osgEarth::SpatialReference*);
116 
117  static DtProj::Ptr MakeCopy(const DtProj&);
118 
119  static DtProj::CPtr LocalTopo(const DtProj &, DtPoint localposition);
120 
121  static DtProj::CPtr Geocentric();
122  static DtProj::CPtr FlatEarth();
123  static DtProj::CPtr Geodetic();
124  static DtProj::CPtr GeodeticInDegrees();
125 
126  std::string projString() const;
127 
128  std::string print() const;
129  std::string printDetailed() const;
130 
131  const Coordinate_System* coordinateSystem() const;
132  const DtCoordTransform* transform() const;
133 
135  bool is2D() const;
136 
138  bool isLocal2D() const;
139 
141  bool isRectangular() const;
142 
143  bool isLocalTopo() const;
144 
145  bool inRadians() const;
146  bool inDegrees() const;
147  bool isLatLong() const;
148  bool isLongLat() const;
149 
150  bool isGeodetic() const;
151  bool isGeocentric() const;
152  bool isFlatEarth() const;
153  bool isUTM() const;
154 
155  void setAngleUnits(AngleUnits);
156 
160  bool operator==(const DtProj &) const;
161  bool operator!=(const DtProj & p) const { return !(*this == p); }
163 
167  static void Convert(
168  const DtProj & from, const DtProj & to,
169  long count, int offset, double* x, double* y, double* z);
170 
171  static void Convert(const DtProj & from, const DtProj & to, long count, DtPoint* points);
172  static void Convert(const DtProj & from, const DtProj & to, DtPoint & point);
173  static void Convert(const DtProj & from, const DtProj & to, std::vector<DtPoint> & points);
174  static void Convert(const DtProj & from, const DtProj & to, std::list<DtPoint> & points);
176 
178  static void ConvertToSame2DProjection(DtFeatureGeometry &, DtFeatureGeometry &);
179 
180  struct ProjData
181  {
182  mutable DtMutex mutex;
183  std::string projString;
184  void* context;
185  void* proj;
186 
187  static ProjData* Make(const Coordinate_System*);
188 
189  ProjData();
190  ProjData(std::string);
191  ~ProjData();
192 
193  bool operator==(const ProjData&) const;
194  bool operator!=(const ProjData&) const;
195  };
196 
197 private:
198  //Create a proj from a proj string
199  explicit DtProj(std::string projString, boost::optional<AngleUnits>);
200 
201  //Create a proj from a Coordinate_System object
202  explicit DtProj(std::auto_ptr<Coordinate_System> cs);
203 
204  //Create a topo proj from a reference point
205  explicit DtProj(const DtProj&, DtPoint);
206 
207  //Copy constructor
208  explicit DtProj(const DtProj&);
209 
210  boost::shared_ptr<ProjData> myProjData;
211  boost::shared_ptr<Coordinate_System> myCS;
212  boost::optional<AngleUnits> myAngleUnits;
213  boost::optional<AngleOrder> myAngleOrder;
214  boost::optional<DtCoordTransform> myTransform;
215 };
216 
217 DT_DLL_features std::ostream& operator<<(std::ostream&, const DtProj&);
218 DT_DLL_features std::ostream& operator<<(std::ostream&, const DtProj::Bounds&);
219 
220 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)