1 : #ifndef __INCLUDE_PCIDSK_SRC_GCP_H
2 : #define __INCLUDE_PCIDSK_SRC_GCP_H
3 :
4 : #include "pcidsk_config.h"
5 :
6 : #include <string>
7 : #include <cstring>
8 :
9 : namespace PCIDSK {
10 : /**
11 : * \brief PCIDSK Generic GCP Structure
12 : *
13 : * The PCIDSK::GCP class encompases all the possible field
14 : * combinations in the last two revisions of PCI's GCP segment
15 : * type.
16 : *
17 : * If a legacy GCP type is used, the additional information fields
18 : * will return empty values.
19 : */
20 0 : class PCIDSK_DLL GCP {
21 : public:
22 : GCP(double x, double y, double z,
23 : double line, double pix,
24 : std::string const& gcp_id,
25 : std::string const& map_units, // TODO: Add ProjParms?
26 : double xerr = 0.0, double yerr = 0.0, double zerr = 0.0,
27 0 : double line_err = 0.0, double pix_err = 0.0)
28 0 : {
29 0 : ground_point_[0] = x;
30 0 : ground_point_[1] = y;
31 0 : ground_point_[2] = z;
32 :
33 0 : ground_error_[0] = xerr;
34 0 : ground_error_[1] = yerr;
35 0 : ground_error_[2] = zerr;
36 :
37 0 : raster_point_[1] = line;
38 0 : raster_point_[0] = pix;
39 :
40 0 : raster_error_[1] = line_err;
41 0 : raster_error_[0] = pix_err;
42 :
43 : std::strncpy(gcp_id_, gcp_id.c_str(),
44 0 : gcp_id.size() > 64 ? 64 : gcp_id.size());
45 0 : gcp_id_[64] = '\0';
46 :
47 0 : this->map_units_ = map_units;
48 :
49 0 : elevation_unit_ = EMetres;
50 0 : elevation_datum_ = EEllipsoidal;
51 0 : iscp_ = false; // default to GCPs
52 0 : }
53 :
54 0 : GCP(GCP const& gcp)
55 0 : {
56 0 : Copy(gcp);
57 0 : }
58 :
59 0 : GCP& operator=(GCP const& gcp)
60 : {
61 0 : Copy(gcp);
62 0 : return *this;
63 : }
64 :
65 : enum EElevationDatum
66 : {
67 : EMeanSeaLevel = 0,
68 : EEllipsoidal
69 : };
70 :
71 : enum EElevationUnit
72 : {
73 : EMetres = 0,
74 : EAmericanFeet,
75 : EInternationalFeet,
76 : EUnknown
77 : };
78 :
79 0 : void SetElevationUnit(EElevationUnit unit)
80 : {
81 0 : elevation_unit_ = unit;
82 0 : }
83 :
84 0 : void SetElevationDatum(EElevationDatum datum)
85 : {
86 0 : elevation_datum_ = datum;
87 0 : }
88 :
89 0 : void GetElevationInfo(EElevationDatum& datum, EElevationUnit& unit) const
90 : {
91 0 : unit = elevation_unit_;
92 0 : datum = elevation_datum_;
93 0 : }
94 :
95 0 : void SetCheckpoint(bool is_checkpoint)
96 : {
97 0 : iscp_ = is_checkpoint;
98 0 : }
99 :
100 0 : bool IsCheckPoint(void) const
101 : {
102 0 : return iscp_;
103 : }
104 :
105 0 : double GetX() const { return ground_point_[0]; }
106 0 : double GetXErr() const { return ground_error_[0]; }
107 0 : double GetY() const { return ground_point_[1]; }
108 0 : double GetYErr() const { return ground_error_[1]; }
109 0 : double GetZ() const { return ground_point_[2]; }
110 0 : double GetZErr() const { return ground_error_[2]; }
111 :
112 0 : double GetPixel() const { return raster_point_[0]; }
113 0 : double GetPixelErr() const { return raster_error_[0]; }
114 0 : double GetLine() const { return raster_point_[1]; }
115 0 : double GetLineErr() const { return raster_error_[1]; }
116 :
117 0 : std::string const& GetMapUnits(void) const { return map_units_; }
118 : void SetMapUnits(std::string const& map_units) { map_units_ = map_units; }
119 :
120 0 : const char* GetIDString(void) const { return gcp_id_; }
121 : private:
122 0 : void Copy(GCP const& gcp)
123 : {
124 0 : ground_point_[0] = gcp.ground_point_[0];
125 0 : ground_point_[1] = gcp.ground_point_[1];
126 0 : ground_point_[2] = gcp.ground_point_[2];
127 :
128 0 : ground_error_[0] = gcp.ground_error_[0];
129 0 : ground_error_[1] = gcp.ground_error_[1];
130 0 : ground_error_[2] = gcp.ground_error_[2];
131 :
132 0 : raster_point_[0] = gcp.raster_point_[0];
133 0 : raster_point_[1] = gcp.raster_point_[1];
134 :
135 0 : raster_error_[0] = gcp.raster_error_[0];
136 0 : raster_error_[1] = gcp.raster_error_[1];
137 :
138 0 : this->map_units_ = gcp.map_units_;
139 0 : this->iscp_ = gcp.iscp_;
140 :
141 0 : std::strncpy(this->gcp_id_, gcp.gcp_id_, 64);
142 :
143 0 : this->gcp_id_[64] = '\0';
144 :
145 0 : this->elevation_unit_ = gcp.elevation_unit_;
146 0 : this->elevation_datum_ = gcp.elevation_datum_;
147 0 : }
148 :
149 : bool iscp_; // true = checkpoint, false = GCP
150 :
151 : EElevationUnit elevation_unit_;
152 : EElevationDatum elevation_datum_;
153 :
154 : // Point information
155 : double ground_point_[3];
156 : double ground_error_[3]; // variances
157 :
158 : double raster_point_[2];
159 : double raster_error_[2];
160 :
161 : char gcp_id_[65];
162 :
163 : std::string map_units_;
164 : };
165 : } // end namespace PCIDSK
166 :
167 : #endif // __INCLUDE_PCIDSK_SRC_GCP_H
168 :
|