LCOV - code coverage report
Current view: directory - frmts/pcidsk/sdk - pcidsk_gcp.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 76 0 0.0 %
Date: 2011-12-18 Functions: 22 0 0.0 %

       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               0 :     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                 :             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 :         }
      84                 :         
      85               0 :         GCP(GCP const& gcp)
      86               0 :         {
      87               0 :             Copy(gcp);
      88               0 :         }
      89                 :         
      90               0 :         GCP& operator=(GCP const& gcp)
      91                 :         {
      92               0 :             Copy(gcp);
      93               0 :             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                 :         
     110               0 :         void SetElevationUnit(EElevationUnit unit)
     111                 :         {
     112               0 :             elevation_unit_ = unit;
     113               0 :         }
     114                 :         
     115               0 :         void SetElevationDatum(EElevationDatum datum)
     116                 :         {
     117               0 :             elevation_datum_ = datum;
     118               0 :         }
     119                 :         
     120               0 :         void GetElevationInfo(EElevationDatum& datum, EElevationUnit& unit) const
     121                 :         {
     122               0 :             unit = elevation_unit_;
     123               0 :             datum = elevation_datum_;
     124               0 :         }
     125                 :         
     126               0 :         void SetCheckpoint(bool is_checkpoint)
     127                 :         {
     128               0 :             iscp_ = is_checkpoint;
     129               0 :         }
     130                 :         
     131               0 :         bool IsCheckPoint(void) const
     132                 :         {
     133               0 :             return iscp_;
     134                 :         }
     135                 :         
     136               0 :         double GetX() const { return ground_point_[0]; }
     137               0 :         double GetXErr() const { return ground_error_[0]; }
     138               0 :         double GetY() const { return ground_point_[1]; }
     139               0 :         double GetYErr() const { return ground_error_[1]; }
     140               0 :         double GetZ() const { return ground_point_[2]; }
     141               0 :         double GetZErr() const { return ground_error_[2]; }
     142                 :         
     143               0 :         double GetPixel() const { return raster_point_[0]; }
     144               0 :         double GetPixelErr() const { return raster_error_[0]; }
     145               0 :         double GetLine() const { return raster_point_[1]; }
     146               0 :         double GetLineErr() const { return raster_error_[1]; }
     147                 :         
     148               0 :         void GetMapUnits(std::string& map_units, std::string& proj_parms) const 
     149               0 :         { map_units = map_units_; proj_parms = 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                 :         
     154               0 :         const char* GetIDString(void) const { return gcp_id_; }
     155                 :     private:
     156               0 :         void Copy(GCP const& gcp)
     157                 :         {
     158               0 :             ground_point_[0] = gcp.ground_point_[0];
     159               0 :             ground_point_[1] = gcp.ground_point_[1];
     160               0 :             ground_point_[2] = gcp.ground_point_[2];
     161                 :             
     162               0 :             ground_error_[0] = gcp.ground_error_[0];
     163               0 :             ground_error_[1] = gcp.ground_error_[1];
     164               0 :             ground_error_[2] = gcp.ground_error_[2];
     165                 :             
     166               0 :             raster_point_[0] = gcp.raster_point_[0];
     167               0 :             raster_point_[1] = gcp.raster_point_[1];
     168                 :             
     169               0 :             raster_error_[0] = gcp.raster_error_[0];
     170               0 :             raster_error_[1] = gcp.raster_error_[1];
     171                 :             
     172               0 :             this->map_units_ = gcp.map_units_;
     173               0 :             this->proj_parms_ = gcp.proj_parms_;
     174               0 :             this->iscp_ = gcp.iscp_;
     175                 :             
     176               0 :             std::strncpy(this->gcp_id_, gcp.gcp_id_, 64);
     177                 :             
     178               0 :             this->gcp_id_[64] = '\0';
     179                 :             
     180               0 :             this->elevation_unit_ = gcp.elevation_unit_;
     181               0 :             this->elevation_datum_ = gcp.elevation_datum_;
     182               0 :         }
     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                 : 

Generated by: LCOV version 1.7