1 /****************************************************************************** 2 * 3 * Purpose: Declaration of the PCIDSK::GCP class. 4 * 5 ****************************************************************************** 6 * Copyright (c) 2009 7 * PCI Geomatics, 50 West Wilmot Street, Richmond Hill, Ont, Canada 8 * 9 * Permission is hereby granted, free of charge, to any person obtaining a 10 * copy of this software and associated documentation files (the "Software"), 11 * to deal in the Software without restriction, including without limitation 12 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13 * and/or sell copies of the Software, and to permit persons to whom the 14 * Software is furnished to do so, subject to the following conditions: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 * DEALINGS IN THE SOFTWARE. 26 ****************************************************************************/ 27 28 #ifndef __INCLUDE_PCIDSK_SRC_GCP_H 29 #define __INCLUDE_PCIDSK_SRC_GCP_H 30 31 #include "pcidsk_config.h" 32 33 #include <string> 34 #include <cstring> 35 36 namespace PCIDSK { 37 /** 38 * \brief PCIDSK Generic GCP Structure 39 * 40 * The PCIDSK::GCP class encompases all the possible field 41 * combinations in the last two revisions of PCI's GCP segment 42 * type. 43 * 44 * If a legacy GCP type is used, the additional information fields 45 * will return empty values. 46 */ 47 class PCIDSK_DLL GCP { 48 public: 49 GCP(double x, double y, double z, 50 double line, double pix, 51 std::string const& gcp_id, 52 std::string const& map_units, 53 std::string const& proj_parms = "", 54 double xerr = 0.0, double yerr = 0.0, double zerr = 0.0, 55 double line_err = 0.0, double pix_err = 0.0) 56 { 57 ground_point_[0] = x; 58 ground_point_[1] = y; 59 ground_point_[2] = z; 60 61 ground_error_[0] = xerr; 62 ground_error_[1] = yerr; 63 ground_error_[2] = zerr; 64 65 raster_point_[1] = line; 66 raster_point_[0] = pix; 67 68 raster_error_[1] = line_err; 69 raster_error_[0] = pix_err; 70 71 std::memset(gcp_id_, ' ', 64); 72 73 std::strncpy(gcp_id_, gcp_id.c_str(), 74 gcp_id.size() > 64 ? 64 : gcp_id.size()); 75 gcp_id_[gcp_id.size() > 64 ? 64 : gcp_id.size()] = '\0'; 76 77 this->map_units_ = map_units; 78 this->proj_parms_ = proj_parms; 79 80 elevation_unit_ = EMetres; 81 elevation_datum_ = EEllipsoidal; 82 iscp_ = false; // default to GCPs 83 } 84 GCP(GCP const & gcp)85 GCP(GCP const& gcp) 86 { 87 Copy(gcp); 88 } 89 90 GCP& operator=(GCP const& gcp) 91 { 92 Copy(gcp); 93 return *this; 94 } 95 96 enum EElevationDatum 97 { 98 EMeanSeaLevel = 0, 99 EEllipsoidal 100 }; 101 102 enum EElevationUnit 103 { 104 EMetres = 0, 105 EAmericanFeet, 106 EInternationalFeet, 107 EUnknown 108 }; 109 SetElevationUnit(EElevationUnit unit)110 void SetElevationUnit(EElevationUnit unit) 111 { 112 elevation_unit_ = unit; 113 } 114 SetElevationDatum(EElevationDatum datum)115 void SetElevationDatum(EElevationDatum datum) 116 { 117 elevation_datum_ = datum; 118 } 119 GetElevationInfo(EElevationDatum & datum,EElevationUnit & unit)120 void GetElevationInfo(EElevationDatum& datum, EElevationUnit& unit) const 121 { 122 unit = elevation_unit_; 123 datum = elevation_datum_; 124 } 125 SetCheckpoint(bool is_checkpoint)126 void SetCheckpoint(bool is_checkpoint) 127 { 128 iscp_ = is_checkpoint; 129 } 130 IsCheckPoint(void)131 bool IsCheckPoint(void) const 132 { 133 return iscp_; 134 } 135 GetX()136 double GetX() const { return ground_point_[0]; } GetXErr()137 double GetXErr() const { return ground_error_[0]; } GetY()138 double GetY() const { return ground_point_[1]; } GetYErr()139 double GetYErr() const { return ground_error_[1]; } GetZ()140 double GetZ() const { return ground_point_[2]; } GetZErr()141 double GetZErr() const { return ground_error_[2]; } 142 GetPixel()143 double GetPixel() const { return raster_point_[0]; } GetPixelErr()144 double GetPixelErr() const { return raster_error_[0]; } GetLine()145 double GetLine() const { return raster_point_[1]; } GetLineErr()146 double GetLineErr() const { return raster_error_[1]; } 147 GetMapUnits(std::string & map_units,std::string & proj_parms)148 void GetMapUnits(std::string& map_units, std::string& proj_parms) const 149 { map_units = map_units_; proj_parms = proj_parms_;} SetMapUnits(std::string const & map_units,std::string const & proj_parms)150 void SetMapUnits(std::string const& map_units, 151 std::string const& proj_parms) { map_units_ = map_units; 152 proj_parms_ = proj_parms;} 153 GetIDString(void)154 const char* GetIDString(void) const { return gcp_id_; } 155 private: Copy(GCP const & gcp)156 void Copy(GCP const& gcp) 157 { 158 ground_point_[0] = gcp.ground_point_[0]; 159 ground_point_[1] = gcp.ground_point_[1]; 160 ground_point_[2] = gcp.ground_point_[2]; 161 162 ground_error_[0] = gcp.ground_error_[0]; 163 ground_error_[1] = gcp.ground_error_[1]; 164 ground_error_[2] = gcp.ground_error_[2]; 165 166 raster_point_[0] = gcp.raster_point_[0]; 167 raster_point_[1] = gcp.raster_point_[1]; 168 169 raster_error_[0] = gcp.raster_error_[0]; 170 raster_error_[1] = gcp.raster_error_[1]; 171 172 this->map_units_ = gcp.map_units_; 173 this->proj_parms_ = gcp.proj_parms_; 174 this->iscp_ = gcp.iscp_; 175 176 std::strncpy(this->gcp_id_, gcp.gcp_id_, 64); 177 178 this->gcp_id_[64] = '\0'; 179 180 this->elevation_unit_ = gcp.elevation_unit_; 181 this->elevation_datum_ = gcp.elevation_datum_; 182 } 183 184 bool iscp_; // true = checkpoint, false = GCP 185 186 EElevationUnit elevation_unit_; 187 EElevationDatum elevation_datum_; 188 189 // Point information 190 double ground_point_[3]; 191 double ground_error_[3]; // variances 192 193 double raster_point_[2]; 194 double raster_error_[2]; 195 196 char gcp_id_[65]; 197 198 std::string map_units_; ///< PCI mapunits string 199 std::string proj_parms_; ///< PCI projection parameters string 200 }; 201 } // end namespace PCIDSK 202 203 #endif // __INCLUDE_PCIDSK_SRC_GCP_H 204 205