Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Name: gdal_gcp.h 4 : * Project: GDAL Core 5 : * Purpose: Declaration of gdal::GCP class 6 : * Author: Even Rouault, <even.rouault@spatialys.com> 7 : * 8 : ****************************************************************************** 9 : * Copyright (c) 2024, Even Rouault, <even.rouault@spatialys.com> 10 : * 11 : * SPDX-License-Identifier: MIT 12 : ****************************************************************************/ 13 : 14 : #ifndef GDALGCP_H_INCLUDED 15 : #define GDALGCP_H_INCLUDED 16 : 17 : #include "cpl_port.h" 18 : #include "gdal.h" 19 : 20 : #include <vector> 21 : 22 : /* ******************************************************************** */ 23 : /* gdal::GCP */ 24 : /* ******************************************************************** */ 25 : 26 : namespace gdal 27 : { 28 : /** C++ wrapper over the C GDAL_GCP structure. 29 : * 30 : * It has the same binary layout, and thus a gdal::GCP pointer can be cast as a 31 : * GDAL_GCP pointer. 32 : * 33 : * @since 3.9 34 : */ 35 : class CPL_DLL GCP 36 : { 37 : public: 38 : explicit GCP(const char *pszId = "", const char *pszInfo = "", 39 : double dfPixel = 0, double dfLine = 0, double dfX = 0, 40 : double dfY = 0, double dfZ = 0); 41 : ~GCP(); 42 : GCP(const GCP &); 43 : explicit GCP(const GDAL_GCP &other); 44 : GCP &operator=(const GCP &); 45 : GCP(GCP &&); 46 : GCP &operator=(GCP &&); 47 : 48 : /** Returns the "id" member. */ 49 21898 : inline const char *Id() const 50 : { 51 21898 : return gcp.pszId; 52 : } 53 : 54 : void SetId(const char *pszId); 55 : 56 : /** Returns the "info" member. */ 57 43778 : inline const char *Info() const 58 : { 59 43778 : return gcp.pszInfo; 60 : } 61 : 62 : void SetInfo(const char *pszInfo); 63 : 64 : /** Returns the "pixel" member. */ 65 21917 : inline double Pixel() const 66 : { 67 21917 : return gcp.dfGCPPixel; 68 : } 69 : 70 : /** Returns a reference to the "pixel" member. */ 71 24689 : inline double &Pixel() 72 : { 73 24689 : return gcp.dfGCPPixel; 74 : } 75 : 76 : /** Returns the "line" member. */ 77 21917 : inline double Line() const 78 : { 79 21917 : return gcp.dfGCPLine; 80 : } 81 : 82 : /** Returns a reference to the "line" member. */ 83 24689 : inline double &Line() 84 : { 85 24689 : return gcp.dfGCPLine; 86 : } 87 : 88 : /** Returns the "X" member. */ 89 21917 : inline double X() const 90 : { 91 21917 : return gcp.dfGCPX; 92 : } 93 : 94 : /** Returns a reference to the "X" member. */ 95 24631 : inline double &X() 96 : { 97 24631 : return gcp.dfGCPX; 98 : } 99 : 100 : /** Returns the "Y" member. */ 101 21917 : inline double Y() const 102 : { 103 21917 : return gcp.dfGCPY; 104 : } 105 : 106 : /** Returns a reference to the "Y" member. */ 107 24631 : inline double &Y() 108 : { 109 24631 : return gcp.dfGCPY; 110 : } 111 : 112 : /** Returns the "Z" member. */ 113 43745 : inline double Z() const 114 : { 115 43745 : return gcp.dfGCPZ; 116 : } 117 : 118 : /** Returns a reference to the "Z" member. */ 119 24528 : inline double &Z() 120 : { 121 24528 : return gcp.dfGCPZ; 122 : } 123 : 124 : /** Casts as a C GDAL_GCP pointer */ 125 440 : inline const GDAL_GCP *c_ptr() const 126 : { 127 440 : return &gcp; 128 : } 129 : 130 : static const GDAL_GCP *c_ptr(const std::vector<GCP> &asGCPs); 131 : 132 : static std::vector<GCP> fromC(const GDAL_GCP *pasGCPList, int nGCPCount); 133 : 134 : private: 135 : GDAL_GCP gcp; 136 : }; 137 : 138 : } /* namespace gdal */ 139 : 140 : #endif