| 125 | * For testing purposes it is desirable to provide a binding around the GDAL transformer API. The following planned binding is based loosely on OGRCoordinateTransformation API binding. So far I have only found the TransformPoint( bDstToSrc, x, y, z ) entry point to be useful in Python and even that ends up returning a (bSuccess, (x, y, z)) result which is somewhat ackward. Is there a better way of doing this? |
| 126 | |
| 127 | {{{ |
| 128 | /************************************************************************/ |
| 129 | /* Transformer */ |
| 130 | /************************************************************************/ |
| 131 | |
| 132 | %rename (Transformer) GDALTransformerInfoShadow; |
| 133 | class GDALTransformerInfoShadow { |
| 134 | private: |
| 135 | GDALTransformerInfoShadow(); |
| 136 | public: |
| 137 | %extend { |
| 138 | |
| 139 | GDALTransformerInfoShadow( GDALDatasetShadow *src, GDALDatasetShadow *dst, |
| 140 | char **options ) { |
| 141 | GDALTransformerInfoShadow *obj = (GDALTransformerInfoShadow*) |
| 142 | GDALCreateGenImgProjTransformer2( (GDALDatasetH)src, (GDALDatasetH)dst, |
| 143 | options ); |
| 144 | return obj; |
| 145 | } |
| 146 | |
| 147 | ~GDALTransformerInfoShadow() { |
| 148 | GDALDestroyTransformer( self ); |
| 149 | } |
| 150 | |
| 151 | // Need to apply argin typemap second so the numinputs=1 version gets applied |
| 152 | // instead of the numinputs=0 version from argout. |
| 153 | %apply (double argout[ANY]) {(double inout[3])}; |
| 154 | %apply (double argin[ANY]) {(double inout[3])}; |
| 155 | int TransformPoint( int bDstToSrc, double inout[3] ) { |
| 156 | int nRet, nSuccess = TRUE; |
| 157 | |
| 158 | nRet = GDALUseTransformer( self, bDstToSrc, |
| 159 | 1, &inout[0], &inout[1], &inout[2], |
| 160 | &nSuccess ); |
| 161 | |
| 162 | return nRet && nSuccess; |
| 163 | } |
| 164 | %clear (double inout[3]); |
| 165 | |
| 166 | int TransformPoint( double argout[3], int bDstToSrc, |
| 167 | double x, double y, double z = 0.0 ) { |
| 168 | int nRet, nSuccess = TRUE; |
| 169 | |
| 170 | argout[0] = x; |
| 171 | argout[1] = y; |
| 172 | argout[2] = z; |
| 173 | nRet = GDALUseTransformer( self, bDstToSrc, |
| 174 | 1, &argout[0], &argout[1], &argout[2], |
| 175 | &nSuccess ); |
| 176 | |
| 177 | return nRet && nSuccess; |
| 178 | } |
| 179 | |
| 180 | #ifdef SWIGCSHARP |
| 181 | %apply (double *inout) {(double*)}; |
| 182 | %apply (double *inout) {(int*)}; |
| 183 | #endif |
| 184 | int TransformPoints( int bDstToSrc, |
| 185 | int nCount, double *x, double *y, double *z, |
| 186 | int *panSuccess ) { |
| 187 | int nRet; |
| 188 | |
| 189 | nRet = GDALUseTransformer( self, bDstToSrc, nCount, x, y, z, panSuccess ); |
| 190 | |
| 191 | return nRet; |
| 192 | } |
| 193 | #ifdef SWIGCSHARP |
| 194 | %clear (double*); |
| 195 | %clear (int*); |
| 196 | #endif |
| 197 | |
| 198 | } /*extend */ |
| 199 | }; |
| 200 | |
| 201 | }}} |