LCOV - code coverage report
Current view: top level - frmts/pcidsk/sdk - pcidsk_gcp.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 86 0.0 %
Date: 2024-05-04 12:52:34 Functions: 0 23 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Purpose: Declaration of the PCIDSK::GCP class.
       4             :  *
       5             :  ******************************************************************************
       6             :  * Copyright (c) 2009
       7             :  * PCI Geomatics, 90 Allstate Parkway, Markham, Ontario, 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           0 :         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           0 :         {
      57           0 :             ground_point_[0] = x;
      58           0 :             ground_point_[1] = y;
      59           0 :             ground_point_[2] = z;
      60             : 
      61           0 :             ground_error_[0] = xerr;
      62           0 :             ground_error_[1] = yerr;
      63           0 :             ground_error_[2] = zerr;
      64             : 
      65           0 :             raster_point_[1] = line;
      66           0 :             raster_point_[0] = pix;
      67             : 
      68           0 :             raster_error_[1] = line_err;
      69           0 :             raster_error_[0] = pix_err;
      70             : 
      71           0 :             std::memset(gcp_id_, ' ', 64);
      72             : 
      73           0 :             std::strncpy(gcp_id_, gcp_id.c_str(),
      74           0 :                          gcp_id.size() > 64 ? 64 : gcp_id.size());
      75           0 :             gcp_id_[gcp_id.size() > 64 ? 64 : gcp_id.size()] = '\0';
      76             : 
      77           0 :             this->map_units_ = map_units;
      78           0 :             this->proj_parms_ = proj_parms;
      79             : 
      80           0 :             elevation_unit_ = EMetres;
      81           0 :             elevation_datum_ = EEllipsoidal;
      82           0 :             iscp_ = false; // default to GCPs
      83           0 :             isactive_ = true;
      84           0 :         }
      85             : 
      86           0 :         GCP(GCP const& gcp)
      87           0 :         {
      88           0 :             Copy(gcp);
      89           0 :         }
      90             : 
      91           0 :         GCP& operator=(GCP const& gcp)
      92             :         {
      93           0 :             Copy(gcp);
      94           0 :             return *this;
      95             :         }
      96             : 
      97             :         enum EElevationDatum
      98             :         {
      99             :             EMeanSeaLevel = 0,
     100             :             EEllipsoidal
     101             :         };
     102             : 
     103             :         enum EElevationUnit
     104             :         {
     105             :             EMetres = 0,
     106             :             EAmericanFeet,
     107             :             EInternationalFeet,
     108             :             EUnknown
     109             :         };
     110             : 
     111           0 :         void SetElevationUnit(EElevationUnit unit)
     112             :         {
     113           0 :             elevation_unit_ = unit;
     114           0 :         }
     115             : 
     116           0 :         void SetElevationDatum(EElevationDatum datum)
     117             :         {
     118           0 :             elevation_datum_ = datum;
     119           0 :         }
     120             : 
     121           0 :         void GetElevationInfo(EElevationDatum& datum, EElevationUnit& unit) const
     122             :         {
     123           0 :             unit = elevation_unit_;
     124           0 :             datum = elevation_datum_;
     125           0 :         }
     126             : 
     127           0 :         void SetCheckpoint(bool is_checkpoint)
     128             :         {
     129           0 :             if (is_checkpoint)
     130           0 :                 isactive_ = true;  // active doesn't apply to check points
     131           0 :             iscp_ = is_checkpoint;
     132           0 :         }
     133             : 
     134           0 :         bool IsCheckPoint(void) const
     135             :         {
     136           0 :             return iscp_;
     137             :         }
     138             : 
     139           0 :         void SetActive(bool is_active)
     140             :         {
     141           0 :             isactive_ = is_active;
     142           0 :             iscp_ = false; // active doesn't apply to check points
     143           0 :         }
     144             : 
     145           0 :         bool IsActive(void) const
     146             :         {
     147           0 :             return isactive_;
     148             :         }
     149             : 
     150           0 :         double GetX() const { return ground_point_[0]; }
     151           0 :         double GetXErr() const { return ground_error_[0]; }
     152           0 :         double GetY() const { return ground_point_[1]; }
     153           0 :         double GetYErr() const { return ground_error_[1]; }
     154           0 :         double GetZ() const { return ground_point_[2]; }
     155           0 :         double GetZErr() const { return ground_error_[2]; }
     156             : 
     157           0 :         double GetPixel() const { return raster_point_[0]; }
     158           0 :         double GetPixelErr() const { return raster_error_[0]; }
     159           0 :         double GetLine() const { return raster_point_[1]; }
     160           0 :         double GetLineErr() const { return raster_error_[1]; }
     161             : 
     162           0 :         void GetMapUnits(std::string& map_units, std::string& proj_parms) const
     163           0 :         { map_units = map_units_; proj_parms = proj_parms_;}
     164             :         void SetMapUnits(std::string const& map_units,
     165             :             std::string const& proj_parms) { map_units_ = map_units;
     166             :                                              proj_parms_ = proj_parms;}
     167             : 
     168           0 :         const char* GetIDString(void) const { return gcp_id_; }
     169             :     private:
     170           0 :         void Copy(GCP const& gcp)
     171             :         {
     172           0 :             ground_point_[0] = gcp.ground_point_[0];
     173           0 :             ground_point_[1] = gcp.ground_point_[1];
     174           0 :             ground_point_[2] = gcp.ground_point_[2];
     175             : 
     176           0 :             ground_error_[0] = gcp.ground_error_[0];
     177           0 :             ground_error_[1] = gcp.ground_error_[1];
     178           0 :             ground_error_[2] = gcp.ground_error_[2];
     179             : 
     180           0 :             raster_point_[0] = gcp.raster_point_[0];
     181           0 :             raster_point_[1] = gcp.raster_point_[1];
     182             : 
     183           0 :             raster_error_[0] = gcp.raster_error_[0];
     184           0 :             raster_error_[1] = gcp.raster_error_[1];
     185             : 
     186           0 :             this->map_units_ = gcp.map_units_;
     187           0 :             this->proj_parms_ = gcp.proj_parms_;
     188           0 :             this->iscp_ = gcp.iscp_;
     189           0 :             this->isactive_ = gcp.isactive_;
     190             : 
     191           0 :             std::strncpy(this->gcp_id_, gcp.gcp_id_, 64);
     192             : 
     193           0 :             this->gcp_id_[64] = '\0';
     194             : 
     195           0 :             this->elevation_unit_ = gcp.elevation_unit_;
     196           0 :             this->elevation_datum_ = gcp.elevation_datum_;
     197           0 :         }
     198             : 
     199             :         bool iscp_; // true = checkpoint, false = GCP
     200             :         bool isactive_; // true = active, false = inactive
     201             : 
     202             :         EElevationUnit elevation_unit_;
     203             :         EElevationDatum elevation_datum_;
     204             : 
     205             :         // Point information
     206             :         double ground_point_[3];
     207             :         double ground_error_[3]; // variances
     208             : 
     209             :         double raster_point_[2];
     210             :         double raster_error_[2];
     211             : 
     212             :         char gcp_id_[65];
     213             : 
     214             :         std::string map_units_; ///< PCI mapunits string
     215             :         std::string proj_parms_;  ///< PCI projection parameters string
     216             :     };
     217             : } // end namespace PCIDSK
     218             : 
     219             : #endif // INCLUDE_PCIDSK_SRC_GCP_H
     220             : 

Generated by: LCOV version 1.14