Changes between Version 4 and Version 5 of rfc22_rpc


Ignore:
Timestamp:
Mar 30, 2008, 9:01:26 AM (16 years ago)
Author:
warmerdam
Comment:

added swig bindings for transformer api

Legend:

Unmodified
Added
Removed
Modified
  • rfc22_rpc

    v4 v5  
    123123 * The raw access is by the established metadata api, so no changes are needed for this.
    124124 * The Warp API is only bound at a high level, so there should be no changes in this regard.
     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;
     133class GDALTransformerInfoShadow {
     134private:
     135  GDALTransformerInfoShadow();
     136public:
     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}}}
    125202
    126203== Implementation ==
     
    128205This work will be implemented by Frank Warmerdam with support from the Canadian Nuclear Safety Commission.
    129206
     207== Testing ==
     208
     209 * A test script for the transformer API covering RPC, GCP_TPS, GCP_POLYNOMIAL, GEOLOC and GEOTRANSFORM methods will be implemented.
     210 * A test script for reading and writing RPB, and GeoTIFF RPC tags will be written.