VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
proj.h
Go to the documentation of this file.
1 
5 #pragma once
6 
8 
9 #include <geometry/point.h>
10 
11 #include <matrix/coordTransform.h>
12 
13 #include <vlutil/vlMutex.h>
14 
16 
18 #include <boost/noncopyable.hpp>
19 #include <boost/optional.hpp>
20 #include <boost/tuple/tuple.hpp>
21 
23 #include <iosfwd>
24 #include <list>
25 
26 
27 class Coordinate_System;
28 class OGRSpatialReference;
29 struct pj_ctx;
30 typedef struct pj_ctx PJ_CONTEXT;
31 struct PJconsts;
32 typedef struct PJconsts PJ;
33 
34 namespace osgEarth {
35  class SpatialReference;
36 }
37 
38 namespace MAKVRinTerra
39 {
40 
41 class DtFeatureGeometry;
42 
52 class DT_DLL_features DtProj : public std::enable_shared_from_this<DtProj>
53 {
54 public:
55  typedef std::shared_ptr<DtProj> Ptr;
56  typedef std::shared_ptr<const DtProj> CPtr;
57 
59  typedef boost::error_info<DtProj, DtProj::CPtr> ErrorInfo;
60  typedef boost::tuple<ErrorInfo,ErrorInfo> ConvertErrorInfo;
62  friend class DtTaggedException<DtProj>;
63 
65  {
67  Radians
68  };
69 
71  {
73  LongLat
74  };
75 
77  {
78  public:
79  static Bounds Make(const DtProj& proj);
80 
81  struct LineSegment
82  {
83  LineSegment(const DtPoint& p1, const DtPoint& p2)
84  : point1(p1), point2(p2) { }
85 
86  DtPoint point1, point2;
87  };
88 
89  Bounds();
90 
91  Bounds(const DtProj& proj, double xmin, double ymin, double xmax, double ymax);
92  Bounds(const DtProj& proj);
93 
94  bool isValid() const;
95 
96  double xmin() const;
97  double ymin() const;
98  double xmax() const;
99  double ymax() const;
100 
101  const DtProj& projection() const;
102 
103  bool intersects(const DtPoint&) const;
104  bool intersects(const LineSegment&, bool* contained = 0) const;
105 
106  Bounds makeSubBounds(unsigned x, unsigned y, unsigned xgrid, unsigned ygrid) const;
107  Bounds makeSubBounds(unsigned n, unsigned xgrid, unsigned ygrid) const;
108 
109  private:
110  double myXmin;
111  double myYmin;
112  double myXmax;
113  double myYmax;
115  };
116 
118  static DtProj::CPtr Make(
119  std::string wktString, boost::optional<AngleUnits> = boost::optional<AngleUnits>());
120  static DtProj::CPtr Make(const Coordinate_System*);
121  static DtProj::CPtr Make(std::unique_ptr<Coordinate_System>);
122  static DtProj::CPtr Make(const OGRSpatialReference*);
123  static DtProj::CPtr Make(const osgEarth::SpatialReference*);
124 
125  static DtProj::Ptr MakeCopy(const DtProj&);
126 
127  static DtProj::CPtr LocalTopo(const DtProj &, DtPoint localposition);
128 
129  static DtProj::CPtr Geocentric();
130  static DtProj::CPtr FlatEarth();
131  static DtProj::CPtr Geodetic();
132  static DtProj::CPtr GeodeticInDegrees();
133 
134  std::string wktString() const;
135 
136  std::string print() const;
137  std::string printDetailed() const;
138 
139  const Coordinate_System* coordinateSystem() const;
140  const DtCoordTransform* transform() const;
141 
143  bool is2D() const;
144 
146  bool isLocal2D() const;
147 
149  bool isRectangular() const;
150 
151  bool isLocalTopo() const;
152 
153  bool inRadians() const;
154  bool inDegrees() const;
155  bool isLatLong() const;
156  bool isLongLat() const;
157 
158  bool isGeodetic() const;
159  bool isGeocentric() const;
160  bool isFlatEarth() const;
161  bool isUTM() const;
162 
163  void setAngleUnits(AngleUnits);
164 
168  bool operator==(const DtProj &) const;
169  bool operator!=(const DtProj & p) const { return !(*this == p); }
171 
175  static void Convert(
176  const DtProj & from, const DtProj & to,
177  long count, int offset, double* x, double* y, double* z);
178 
179  static void Convert(const DtProj & from, const DtProj & to, long count, DtPoint* points);
180  static void Convert(const DtProj & from, const DtProj & to, DtPoint & point);
181  static void Convert(const DtProj & from, const DtProj & to, std::vector<DtPoint> & points);
182  static void Convert(const DtProj & from, const DtProj & to, std::list<DtPoint> & points);
184 
186  static void ConvertToSame2DProjection(DtFeatureGeometry &, DtFeatureGeometry &);
187 
188  struct ProjData
189  {
190  mutable DtMutex mutex;
191  std::string wktString;
193 
194  static ProjData* Make(const Coordinate_System*);
195 
196  ProjData();
197  ProjData(std::string);
198  ~ProjData();
199 
200  bool operator==(const ProjData&) const;
201  bool operator!=(const ProjData&) const;
202  };
203 
204 protected:
205  //Create a proj from a proj string
206  explicit DtProj(std::string wktString, boost::optional<AngleUnits>);
207 
208  //Create a proj from a Coordinate_System object
209  explicit DtProj(std::unique_ptr<Coordinate_System> cs);
210 
211  //Create a topo proj from a reference point
212  explicit DtProj(const DtProj&, DtPoint);
213 
214  //Copy constructor
215  explicit DtProj(const DtProj&);
216 
217  std::shared_ptr<ProjData> myProjData;
218  std::shared_ptr<Coordinate_System> myCS;
219  boost::optional<AngleUnits> myAngleUnits;
220  boost::optional<AngleOrder> myAngleOrder;
221  boost::optional<DtCoordTransform> myTransform;
222 };
223 
224 DT_DLL_features std::ostream& operator<<(std::ostream&, const DtProj&);
225 DT_DLL_features std::ostream& operator<<(std::ostream&, const DtProj::Bounds&);
226 
227 }
#define DT_DLL_features
stop complaining about multiple independent base classes for boost::noncopyable this should probably ...
Definition: featuresDefines.h:41
DtPoint point2
Definition: proj.h:86
AngleUnits
Definition: proj.h:64
Definition: proj.h:188
struct PJconsts PJ
Definition: proj.h:32
DtTaggedException< DtProj > Exception
Definition: proj.h:61
double myXmax
Definition: proj.h:112
std::shared_ptr< const DtProj > CPtr
Definition: proj.h:56
std::shared_ptr< ProjData > myProjData
Definition: proj.h:217
struct pj_ctx PJ_CONTEXT
Definition: proj.h:30
double myYmax
Definition: proj.h:113
Definition: proj.h:72
DT_DLL_terrainCS bool operator==(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
DT_DLL_features std::ostream & operator<<(std::ostream &, const DtFeatureTransform &)
std::ostream output.
Definition: proj.h:76
AngleOrder
Definition: proj.h:70
boost::optional< DtCoordTransform > myTransform
Definition: proj.h:221
boost::tuple< ErrorInfo, ErrorInfo > ConvertErrorInfo
Definition: proj.h:60
PJ * proj
Definition: proj.h:192
void print(double **a, int r, int c, const char *str)
Definition: coordSystem.h:54
double myYmin
Definition: proj.h:111
boost::error_info< DtProj, DtProj::CPtr > ErrorInfo
Exception stuff.
Definition: proj.h:59
boost::optional< AngleUnits > myAngleUnits
Definition: proj.h:219
Represents some coordinate system. The terms &quot;coordinate system&quot;, &quot;projection&quot;, &quot;spatial reference&quot;...
Definition: proj.h:52
std::shared_ptr< DtProj > Ptr
Definition: proj.h:55
std::shared_ptr< Coordinate_System > myCS
Definition: proj.h:218
Create a new MAK exception type that inherits from boost::exception. Tag is what differentiates this ...
Definition: taggedException.h:15
Definition: proj.h:66
DtMutex mutex
Definition: proj.h:190
double myXmin
Definition: proj.h:110
DtProj::CPtr myProjection
Definition: proj.h:114
bool operator!=(const DtProj &p) const
Definition: proj.h:169
DT_DLL_vrfutil bool intersects(const DtVector &localPoint1, const DtVector &localPoint2, const DtLocalVertexList &localVertexList, const Coordinate_System &coordinateSystem)
Returns true if the line segment localPoint1-localPoint2 intersects any line segment in localVert...
DT_DLL_terrainCS bool operator!=(const DtDegMinSec &lhs, const DtDegMinSec &rhs)
std::string wktString
Definition: proj.h:191
voidpf uLong offset
Definition: ioapi.h:42
boost::optional< AngleOrder > myAngleOrder
Definition: proj.h:220
Represents a feature geometry.
Definition: featureGeometry.h:40
Definition: point.h:34
LineSegment(const DtPoint &p1, const DtPoint &p2)
Definition: proj.h:83

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)