1 /******************************************************************************
2 * $Id: Operations.i 60d13e19f89619ca16040b9a270d3837b8f0df63 2020-03-05 10:02:43 +0200 Ilmari Ayres $
3 *
4 * Name: Operations.i
5 * Project: GDAL Python Interface
6 * Purpose: GDAL Raster Operations SWIG Interface declarations.
7 * Author: Howard Butler, hobu.inc@gmail.com
8 *
9 ******************************************************************************
10 * Copyright (c) 2007, Howard Butler
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 * DEALINGS IN THE SOFTWARE.
29 *****************************************************************************/
30
31 %{
32 #include "gdalgrid.h"
33
34 #ifdef DEBUG
35 typedef struct OGRLayerHS OGRLayerShadow;
36 typedef struct OGRGeometryHS OGRGeometryShadow;
37 #else
38 typedef void OGRLayerShadow;
39 typedef void OGRGeometryShadow;
40 #endif
41 %}
42
43 /************************************************************************/
44 /* TermProgress() */
45 /************************************************************************/
46
47 #if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
48 %rename (TermProgress_nocb) GDALTermProgress_nocb;
49 %feature( "kwargs" ) GDALTermProgress_nocb;
50 %inline %{
51 static int
52 GDALTermProgress_nocb( double dfProgress, const char * pszMessage=NULL, void *pData=NULL ) {
53 return GDALTermProgress( dfProgress, pszMessage, pData);
54 }
55 %}
56
57 %rename (TermProgress) GDALTermProgress;
58 %callback("%s");
59 int GDALTermProgress( double, const char *, void * );
60 %nocallback;
61 #endif
62
63 /************************************************************************/
64 /* ComputeMedianCutPCT() */
65 /************************************************************************/
66 #ifndef SWIGJAVA
67 %feature( "kwargs" ) ComputeMedianCutPCT;
68 #endif
69 %apply Pointer NONNULL { GDALRasterBandShadow *red, GDALRasterBandShadow *green, GDALRasterBandShadow *blue, GDALRasterBandShadow *target, GDALColorTableShadow* colors };
70 %inline %{
71 int ComputeMedianCutPCT ( GDALRasterBandShadow *red,
72 GDALRasterBandShadow *green,
73 GDALRasterBandShadow *blue,
74 int num_colors,
75 GDALColorTableShadow* colors,
76 GDALProgressFunc callback = NULL,
77 void* callback_data=NULL) {
78
79 CPLErrorReset();
80
81 int err = GDALComputeMedianCutPCT( red,
82 green,
83 blue,
84 NULL,
85 num_colors,
86 colors,
87 callback,
88 callback_data);
89
90 return err;
91 }
92 %}
93
94 /************************************************************************/
95 /* DitherRGB2PCT() */
96 /************************************************************************/
97 #ifndef SWIGJAVA
98 %feature( "kwargs" ) DitherRGB2PCT;
99 #endif
100 %inline %{
101 int DitherRGB2PCT ( GDALRasterBandShadow *red,
102 GDALRasterBandShadow *green,
103 GDALRasterBandShadow *blue,
104 GDALRasterBandShadow *target,
105 GDALColorTableShadow *colors,
106 GDALProgressFunc callback = NULL,
107 void* callback_data=NULL) {
108
109 CPLErrorReset();
110 int err;
111 err = GDALDitherRGB2PCT( red,
112 green,
113 blue,
114 target,
115 colors,
116 callback,
117 callback_data);
118
119 return err;
120 }
121 %}
122 %clear GDALRasterBandShadow *red, GDALRasterBandShadow *green, GDALRasterBandShadow *blue, GDALRasterBandShadow *target, GDALColorTableShadow* colors;
123
124 /************************************************************************/
125 /* ReprojectImage() */
126 /************************************************************************/
127 %apply Pointer NONNULL {GDALDatasetShadow *src_ds, GDALDatasetShadow *dst_ds};
128 #ifndef SWIGJAVA
129 %feature( "kwargs" ) ReprojectImage;
130 #endif
131 %inline %{
132 CPLErr ReprojectImage ( GDALDatasetShadow *src_ds,
133 GDALDatasetShadow *dst_ds,
134 const char *src_wkt=NULL,
135 const char *dst_wkt=NULL,
136 GDALResampleAlg eResampleAlg=GRA_NearestNeighbour,
137 double WarpMemoryLimit=0.0,
138 double maxerror = 0.0,
139 GDALProgressFunc callback = NULL,
140 void* callback_data=NULL,
141 char** options = NULL ) {
142
143 CPLErrorReset();
144
145 GDALWarpOptions* psOptions = NULL;
146 if( options != NULL )
147 {
148 psOptions = GDALCreateWarpOptions();
149 psOptions->papszWarpOptions = CSLDuplicate(options);
150 }
151
152 CPLErr err = GDALReprojectImage( src_ds,
153 src_wkt,
154 dst_ds,
155 dst_wkt,
156 eResampleAlg,
157 WarpMemoryLimit,
158 maxerror,
159 callback,
160 callback_data,
161 psOptions);
162
163 if( psOptions != NULL )
164 GDALDestroyWarpOptions(psOptions);
165
166 return err;
167 }
168 %}
169 %clear GDALDatasetShadow *src_ds, GDALDatasetShadow *dst_ds;
170
171 /************************************************************************/
172 /* ComputeProximity() */
173 /************************************************************************/
174 #ifndef SWIGJAVA
175 %feature( "kwargs" ) ComputeProximity;
176 #endif
177 %apply Pointer NONNULL {GDALRasterBandShadow *srcBand, GDALRasterBandShadow *proximityBand};
178 %inline %{
179 int ComputeProximity( GDALRasterBandShadow *srcBand,
180 GDALRasterBandShadow *proximityBand,
181 char **options = NULL,
182 GDALProgressFunc callback=NULL,
183 void* callback_data=NULL) {
184
185 CPLErrorReset();
186
187 return GDALComputeProximity( srcBand, proximityBand, options,
188 callback, callback_data );
189 }
190 %}
191 %clear GDALRasterBandShadow *srcBand, GDALRasterBandShadow *proximityBand;
192
193 /************************************************************************/
194 /* RasterizeLayer() */
195 /************************************************************************/
196
197 %apply Pointer NONNULL {GDALDatasetShadow *dataset, OGRLayerShadow *layer};
198
199 #ifdef SWIGJAVA
200 %apply (int nList, int *pList ) { (int bands, int *band_list ) };
201 %apply (int nList, double *pList ) { (int burn_values, double *burn_values_list ) };
202 %inline %{
203 int RasterizeLayer( GDALDatasetShadow *dataset,
204 int bands, int *band_list,
205 OGRLayerShadow *layer,
206 int burn_values = 0, double *burn_values_list = NULL,
207 char **options = NULL,
208 GDALProgressFunc callback=NULL,
209 void* callback_data=NULL) {
210
211 CPLErr eErr;
212
213 CPLErrorReset();
214
215 if( burn_values == 0 )
216 {
217 burn_values_list = (double *) CPLMalloc(sizeof(double)*bands);
218 for( int i = 0; i < bands; i++ )
219 burn_values_list[i] = 255.0;
220 }
221 else if( burn_values != bands )
222 {
223 CPLError( CE_Failure, CPLE_AppDefined,
224 "Did not get the expected number of burn values in RasterizeLayer()" );
225 return CE_Failure;
226 }
227
228 eErr = GDALRasterizeLayers( dataset, bands, band_list,
229 1, &layer,
230 NULL, NULL,
231 burn_values_list, options,
232 callback, callback_data );
233
234 if( burn_values == 0 )
235 CPLFree( burn_values_list );
236
237 return eErr;
238 }
239 %}
240 #else
241 %feature( "kwargs" ) RasterizeLayer;
242 %apply (int nList, int *pList ) { (int bands, int *band_list ) };
243 %apply (int nList, double *pList ) { (int burn_values, double *burn_values_list ) };
244 %inline %{
245 int RasterizeLayer( GDALDatasetShadow *dataset,
246 int bands, int *band_list,
247 OGRLayerShadow *layer,
248 void *pfnTransformer = NULL,
249 void *pTransformArg = NULL,
250 int burn_values = 0, double *burn_values_list = NULL,
251 char **options = NULL,
252 GDALProgressFunc callback=NULL,
253 void* callback_data=NULL) {
254
255 CPLErr eErr;
256
257 CPLErrorReset();
258
259 if( burn_values == 0 )
260 {
261 burn_values_list = (double *) CPLMalloc(sizeof(double)*bands);
262 for( int i = 0; i < bands; i++ )
263 burn_values_list[i] = 255.0;
264 }
265 else if( burn_values != bands )
266 {
267 CPLError( CE_Failure, CPLE_AppDefined,
268 "Did not get the expected number of burn values in RasterizeLayer()" );
269 return CE_Failure;
270 }
271
272 eErr = GDALRasterizeLayers( dataset, bands, band_list,
273 1, &layer,
274 (GDALTransformerFunc) pfnTransformer,
275 pTransformArg,
276 burn_values_list, options,
277 callback, callback_data );
278
279 if( burn_values == 0 )
280 CPLFree( burn_values_list );
281
282 return eErr;
283 }
284 %}
285 #endif
286
287 /************************************************************************/
288 /* Polygonize() */
289 /************************************************************************/
290
291 %apply Pointer NONNULL {GDALRasterBandShadow *srcBand, OGRLayerShadow *outLayer};
292 #ifndef SWIGJAVA
293 %feature( "kwargs" ) Polygonize;
294 #endif
295 %inline %{
296 int Polygonize( GDALRasterBandShadow *srcBand,
297 GDALRasterBandShadow *maskBand,
298 OGRLayerShadow *outLayer,
299 int iPixValField,
300 char **options = NULL,
301 GDALProgressFunc callback=NULL,
302 void* callback_data=NULL) {
303
304 CPLErrorReset();
305
306 return GDALPolygonize( srcBand, maskBand, outLayer, iPixValField,
307 options, callback, callback_data );
308 }
309 %}
310
311 #ifndef SWIGJAVA
312 %feature( "kwargs" ) FPolygonize;
313 #endif
314 %inline %{
315 int FPolygonize( GDALRasterBandShadow *srcBand,
316 GDALRasterBandShadow *maskBand,
317 OGRLayerShadow *outLayer,
318 int iPixValField,
319 char **options = NULL,
320 GDALProgressFunc callback=NULL,
321 void* callback_data=NULL) {
322
323 CPLErrorReset();
324
325 return GDALFPolygonize( srcBand, maskBand, outLayer, iPixValField,
326 options, callback, callback_data );
327 }
328 %}
329
330 %clear GDALRasterBandShadow *srcBand, OGRLayerShadow *outLayer;
331
332 /************************************************************************/
333 /* FillNodata() */
334 /************************************************************************/
335
336 /* Interface method added for GDAL 1.7.0 */
337 %apply Pointer NONNULL {GDALRasterBandShadow *targetBand};
338 #ifndef SWIGJAVA
339 %feature( "kwargs" ) FillNodata;
340 #endif
341 %inline %{
342 int FillNodata( GDALRasterBandShadow *targetBand,
343 GDALRasterBandShadow *maskBand,
344 double maxSearchDist,
345 int smoothingIterations,
346 char **options = NULL,
347 GDALProgressFunc callback=NULL,
348 void* callback_data=NULL) {
349
350 CPLErrorReset();
351
352 return GDALFillNodata( targetBand, maskBand, maxSearchDist,
353 0, smoothingIterations, options,
354 callback, callback_data );
355 }
356 %}
357 %clear GDALRasterBandShadow *targetBand;
358
359 /************************************************************************/
360 /* SieveFilter() */
361 /************************************************************************/
362
363 %apply Pointer NONNULL {GDALRasterBandShadow *srcBand, GDALRasterBandShadow *dstBand};
364 #ifndef SWIGJAVA
365 %feature( "kwargs" ) SieveFilter;
366 #endif
367 %inline %{
368 int SieveFilter( GDALRasterBandShadow *srcBand,
369 GDALRasterBandShadow *maskBand,
370 GDALRasterBandShadow *dstBand,
371 int threshold, int connectedness=4,
372 char **options = NULL,
373 GDALProgressFunc callback=NULL,
374 void* callback_data=NULL) {
375
376 CPLErrorReset();
377
378 return GDALSieveFilter( srcBand, maskBand, dstBand,
379 threshold, connectedness,
380 options, callback, callback_data );
381 }
382 %}
383 %clear GDALRasterBandShadow *srcBand, GDALRasterBandShadow *dstBand;
384
385 /************************************************************************/
386 /* RegenerateOverviews() */
387 /************************************************************************/
388
389 #ifndef SWIGJAVA
390 %feature( "kwargs" ) RegenerateOverviews;
391 #endif /* SWIGJAVA */
392 #ifndef SWIGCSHARP
393 %apply (int object_list_count, GDALRasterBandShadow **poObjects) {(int overviewBandCount, GDALRasterBandShadow **overviewBands)};
394 #endif /* SWIGCSHARP */
395 #ifdef SWIGJAVA
396 %apply (const char* stringWithDefaultValue) {const char *resampling};
397 #endif /* SWIGJAVA */
398 %apply Pointer NONNULL { GDALRasterBandShadow* srcBand };
399 %inline %{
400 int RegenerateOverviews( GDALRasterBandShadow *srcBand,
401 int overviewBandCount,
402 GDALRasterBandShadow **overviewBands,
403 const char *resampling = "average",
404 GDALProgressFunc callback=NULL,
405 void* callback_data=NULL) {
406
407 CPLErrorReset();
408
409 return GDALRegenerateOverviews( srcBand, overviewBandCount, overviewBands,
410 resampling ? resampling : "average", callback, callback_data );
411 }
412 %}
413 #ifdef SWIGJAVA
414 %clear (const char* resampling);
415 #endif /* SWIGJAVA */
416 %clear GDALRasterBandShadow* srcBand;
417
418 /************************************************************************/
419 /* RegenerateOverview() */
420 /************************************************************************/
421
422 #ifndef SWIGJAVA
423 %feature( "kwargs" ) RegenerateOverview;
424 #endif
425 %apply Pointer NONNULL { GDALRasterBandShadow* srcBand, GDALRasterBandShadow* overviewBand};
426 %inline %{
427 int RegenerateOverview( GDALRasterBandShadow *srcBand,
428 GDALRasterBandShadow *overviewBand,
429 const char *resampling = "average",
430 GDALProgressFunc callback=NULL,
431 void* callback_data=NULL) {
432
433 CPLErrorReset();
434
435 return GDALRegenerateOverviews( srcBand, 1, &overviewBand,
436 resampling ? resampling : "average", callback, callback_data );
437 }
438 %}
439 %clear GDALRasterBandShadow* srcBand, GDALRasterBandShadow* overviewBand, char* resampling;
440
441 /************************************************************************/
442 /* GridCreate() */
443 /************************************************************************/
444
445 #ifdef SWIGJAVA
446 %rename (GridCreate) wrapper_GridCreate;
447 %apply (int nCount, double *x, double *y, double *z) { (int points, double *x, double *y, double *z) };
448 %apply (void* nioBuffer, long nioBufferSize) { (void* nioBuffer, long nioBufferSize) };
449 %inline %{
450 int wrapper_GridCreate( char* algorithmOptions,
451 int points, double *x, double *y, double *z,
452 double xMin, double xMax, double yMin, double yMax,
453 int xSize, int ySize, GDALDataType dataType,
454 void* nioBuffer, long nioBufferSize,
455 GDALProgressFunc callback = NULL,
456 void* callback_data = NULL)
457 {
458 GDALGridAlgorithm eAlgorithm = GGA_InverseDistanceToAPower;
459 void* pOptions = NULL;
460
461 CPLErr eErr = CE_Failure;
462
463 CPLErrorReset();
464
465 if (xSize * ySize * (GDALGetDataTypeSize(dataType) / 8) > nioBufferSize)
466 {
467 CPLError( eErr, CPLE_AppDefined, "Buffer too small" );
468 return eErr;
469 }
470
471 if ( algorithmOptions )
472 {
473 eErr = ParseAlgorithmAndOptions( algorithmOptions, &eAlgorithm, &pOptions );
474 }
475 else
476 {
477 eErr = ParseAlgorithmAndOptions( szAlgNameInvDist, &eAlgorithm, &pOptions );
478 }
479
480 if ( eErr != CE_None )
481 {
482 CPLError( eErr, CPLE_AppDefined, "Failed to process algorithm name and parameters.\n" );
483 return eErr;
484 }
485
486 eErr = GDALGridCreate( eAlgorithm, pOptions, points, x, y, z,
487 xMin, xMax, yMin, yMax, xSize, ySize, dataType, nioBuffer,
488 callback, callback_data );
489
490 CPLFree(pOptions);
491
492 return eErr;
493 }
494 %}
495 %clear (void *nioBuffer, long nioBufferSize);
496 #endif
497
498 /************************************************************************/
499 /* ContourGenerate() */
500 /************************************************************************/
501
502 #ifndef SWIGJAVA
503 %feature( "kwargs" ) ContourGenerate;
504 #endif
505 %apply Pointer NONNULL {GDALRasterBandShadow *srcBand, OGRLayerShadow* dstLayer};
506 %apply (int nList, double *pList ) { (int fixedLevelCount, double *fixedLevels ) };
507 %inline %{
508 int ContourGenerate( GDALRasterBandShadow *srcBand,
509 double contourInterval,
510 double contourBase,
511 int fixedLevelCount,
512 double *fixedLevels,
513 int useNoData,
514 double noDataValue,
515 OGRLayerShadow* dstLayer,
516 int idField,
517 int elevField,
518 GDALProgressFunc callback = NULL,
519 void* callback_data = NULL)
520 {
521 CPLErr eErr;
522
523 CPLErrorReset();
524
525 eErr = GDALContourGenerate( srcBand,
526 contourInterval,
527 contourBase,
528 fixedLevelCount,
529 fixedLevels,
530 useNoData,
531 noDataValue,
532 dstLayer,
533 idField,
534 elevField,
535 callback,
536 callback_data);
537
538 return eErr;
539 }
540 %}
541 %clear GDALRasterBandShadow *srcBand;
542 %clear OGRLayerShadow* dstLayer;
543 %clear (int fixedLevelCount, double *fixedLevels );
544
545 #ifndef SWIGJAVA
546 %feature( "kwargs" ) ContourGenerateEx;
547 #endif
548 %apply Pointer NONNULL {GDALRasterBandShadow *srcBand, OGRLayerShadow* dstLayer};
549 %inline %{
550 int ContourGenerateEx( GDALRasterBandShadow *srcBand,
551 OGRLayerShadow* dstLayer,
552 char** options = NULL,
553 GDALProgressFunc callback = NULL,
554 void* callback_data = NULL )
555 {
556 CPLErr eErr;
557
558 CPLErrorReset();
559
560 eErr = GDALContourGenerateEx( srcBand,
561 dstLayer,
562 options,
563 callback,
564 callback_data);
565
566 return eErr;
567 }
568 %}
569 %clear GDALRasterBandShadow *srcBand;
570 %clear OGRLayerShadow* dstLayer;
571
572 /************************************************************************/
573 /* ViewshedGenerate() */
574 /************************************************************************/
575
576 %rename (ViewshedMode) GDALViewshedMode;
577 typedef enum {
578 GVM_Diagonal = 1,
579 GVM_Edge = 2,
580 GVM_Max = 3,
581 GVM_Min = 4
582 } GDALViewshedMode;
583
584 %rename (ViewshedOutputType) GDALViewshedOutputType;
585 typedef enum {
586 GVOT_NORMAL = 1,
587 GVOT_MIN_TARGET_HEIGHT_FROM_DEM = 2,
588 GVOT_MIN_TARGET_HEIGHT_FROM_GROUND = 3
589 } GDALViewshedOutputType;
590
591 %newobject ViewshedGenerate;
592 #ifndef SWIGJAVA
593 %feature( "kwargs" ) ViewshedGenerate;
594 #endif
595 %apply Pointer NONNULL {GDALRasterBandShadow *srcBand};
596 %inline %{
597 GDALDatasetShadow *ViewshedGenerate( GDALRasterBandShadow *srcBand,
598 const char* driverName,
599 const char* targetRasterName,
600 char** creationOptions,
601 double observerX, double observerY, double observerHeight,
602 double targetHeight, double visibleVal, double invisibleVal,
603 double outOfRangeVal, double noDataVal, double dfCurvCoeff,
604 GDALViewshedMode mode, double maxDistance,
605 GDALProgressFunc callback = NULL, void* callback_data = NULL,
606 GDALViewshedOutputType heightMode = GVOT_NORMAL,
607 char** papszOptions = NULL)
608 {
609 GDALDatasetShadow* ds = GDALViewshedGenerate( srcBand,
610 driverName,
611 targetRasterName,
612 creationOptions,
613 observerX,
614 observerY,
615 observerHeight,
616 targetHeight,
617 visibleVal,
618 invisibleVal,
619 outOfRangeVal,
620 noDataVal,
621 dfCurvCoeff,
622 mode,
623 maxDistance,
624 callback,
625 callback_data,
626 heightMode,
627 papszOptions);
628 if (ds == 0) {
629 /*throw CPLGetLastErrorMsg(); causes a SWIG_exception later*/
630 }
631 return ds;
632 }
633 %}
634 %clear GDALRasterBandShadow *srcBand;
635
636 /************************************************************************/
637 /* AutoCreateWarpedVRT() */
638 /************************************************************************/
639
640 %newobject AutoCreateWarpedVRT;
641 %apply Pointer NONNULL { GDALDatasetShadow *src_ds };
642 %inline %{
643 GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds,
644 const char *src_wkt = 0,
645 const char *dst_wkt = 0,
646 GDALResampleAlg eResampleAlg = GRA_NearestNeighbour,
647 double maxerror = 0.0 ) {
648 GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt,
649 dst_wkt,
650 eResampleAlg,
651 maxerror,
652 0 );
653 if (ds == 0) {
654 /*throw CPLGetLastErrorMsg(); causes a SWIG_exception later*/
655 }
656 return ds;
657
658 }
659 %}
660 %clear GDALDatasetShadow *src_ds;
661
662 /************************************************************************/
663 /* CreatePansharpenedVRT() */
664 /************************************************************************/
665
666 %newobject CreatePansharpenedVRT;
667 #ifndef SWIGCSHARP
668 %apply (int object_list_count, GDALRasterBandShadow **poObjects) {(int nInputSpectralBands, GDALRasterBandShadow **ahInputSpectralBands)};
669 #endif /* SWIGCSHARP */
670 %apply Pointer NONNULL { GDALRasterBandShadow* panchroBand };
671
672 %inline %{
CreatePansharpenedVRT(const char * pszXML,GDALRasterBandShadow * panchroBand,int nInputSpectralBands,GDALRasterBandShadow ** ahInputSpectralBands)673 GDALDatasetShadow* CreatePansharpenedVRT( const char* pszXML,
674 GDALRasterBandShadow* panchroBand,
675 int nInputSpectralBands,
676 GDALRasterBandShadow** ahInputSpectralBands )
677 {
678 CPLErrorReset();
679
680 return (GDALDatasetShadow*)GDALCreatePansharpenedVRT( pszXML, panchroBand,
681 nInputSpectralBands, ahInputSpectralBands );
682 }
683 %}
684 %clear GDALRasterBandShadow* panchroBand;
685
686 /************************************************************************/
687 /* Transformer */
688 /************************************************************************/
689
690 #ifndef SWIGPYTHON
691 %rename (Transformer) GDALTransformerInfoShadow;
692 #endif
693
694 class GDALTransformerInfoShadow {
695 private:
696 GDALTransformerInfoShadow();
697 public:
698 %extend {
699
700 #ifndef SWIGPYTHON
GDALTransformerInfoShadow(GDALDatasetShadow * src,GDALDatasetShadow * dst,char ** options)701 GDALTransformerInfoShadow( GDALDatasetShadow *src, GDALDatasetShadow *dst,
702 char **options ) {
703 GDALTransformerInfoShadow *obj = (GDALTransformerInfoShadow*)
704 GDALCreateGenImgProjTransformer2( (GDALDatasetH)src, (GDALDatasetH)dst,
705 options );
706 return obj;
707 }
708 #endif
709
~GDALTransformerInfoShadow()710 ~GDALTransformerInfoShadow() {
711 GDALDestroyTransformer( self );
712 }
713
714 // Need to apply argin typemap second so the numinputs=1 version gets applied
715 // instead of the numinputs=0 version from argout.
716 #ifdef SWIGJAVA
717 %apply (double argout[ANY]) {(double inout[3])};
718 #else
719 %apply (double argout[ANY]) {(double inout[3])};
720 %apply (double argin[ANY]) {(double inout[3])};
721 #endif
TransformPoint(int bDstToSrc,double inout[3])722 int TransformPoint( int bDstToSrc, double inout[3] ) {
723 int nRet, nSuccess = TRUE;
724
725 nRet = GDALUseTransformer( self, bDstToSrc,
726 1, &inout[0], &inout[1], &inout[2],
727 &nSuccess );
728
729 return nRet && nSuccess;
730 }
731 %clear (double inout[3]);
732
733 int TransformPoint( double argout[3], int bDstToSrc,
734 double x, double y, double z = 0.0 ) {
735 int nRet, nSuccess = TRUE;
736
737 argout[0] = x;
738 argout[1] = y;
739 argout[2] = z;
740 nRet = GDALUseTransformer( self, bDstToSrc,
741 1, &argout[0], &argout[1], &argout[2],
742 &nSuccess );
743
744 return nRet && nSuccess;
745 }
746
747 #ifdef SWIGCSHARP
748 %apply (double *inout) {(double*)};
749 %apply (double *inout) {(int*)};
750 #endif
TransformPoints(int bDstToSrc,int nCount,double * x,double * y,double * z,int * panSuccess)751 int TransformPoints( int bDstToSrc,
752 int nCount, double *x, double *y, double *z,
753 int *panSuccess ) {
754 int nRet;
755
756 nRet = GDALUseTransformer( self, bDstToSrc, nCount, x, y, z, panSuccess );
757
758 return nRet;
759 }
760 #ifdef SWIGCSHARP
761 %clear (double*);
762 %clear (int*);
763 #endif
764
765 /************************************************************************/
766 /* TransformGeolocations() */
767 /************************************************************************/
768
769 %apply Pointer NONNULL {GDALRasterBandShadow *xBand, GDALRasterBandShadow *yBand, GDALRasterBandShadow *zBand};
770
771 #ifndef SWIGJAVA
772 %feature( "kwargs" ) TransformGeolocations;
773 #endif
774
775 int TransformGeolocations( GDALRasterBandShadow *xBand,
776 GDALRasterBandShadow *yBand,
777 GDALRasterBandShadow *zBand,
778 GDALProgressFunc callback=NULL,
779 void* callback_data=NULL,
780 char **options = NULL) {
781
782 CPLErrorReset();
783
784 return GDALTransformGeolocations( xBand, yBand, zBand,
785 GDALUseTransformer, self,
786 callback, callback_data, options );
787 }
788 %clear GDALRasterBandShadow *xBand, GDALRasterBandShadow *yBand, GDALRasterBandShadow *zBand;
789
790 } /*extend */
791 };
792
793 #ifdef SWIGPYTHON
794 %newobject Transformer;
795 %inline %{
Transformer(GDALDatasetShadow * src,GDALDatasetShadow * dst,char ** options)796 GDALTransformerInfoShadow* Transformer( GDALDatasetShadow *src, GDALDatasetShadow *dst,
797 char **options ) {
798 GDALTransformerInfoShadow *obj = (GDALTransformerInfoShadow*)
799 GDALCreateGenImgProjTransformer2( (GDALDatasetH)src, (GDALDatasetH)dst,
800 options );
801 return obj;
802 }
803 %}
804 #endif
805
806 /************************************************************************/
807 /* ApplyVerticalShiftGrid() */
808 /************************************************************************/
809
810 %newobject ApplyVerticalShiftGrid;
811 %apply Pointer NONNULL {GDALDatasetShadow *src_ds, GDALDatasetShadow *grid_ds};
812 #ifndef SWIGJAVA
813 %feature( "kwargs" ) ApplyVerticalShiftGrid;
814 #endif
815 %inline %{
816 GDALDatasetShadow* ApplyVerticalShiftGrid( GDALDatasetShadow *src_ds,
817 GDALDatasetShadow *grid_ds,
818 bool inverse = false,
819 double srcUnitToMeter = 1.0,
820 double dstUnitToMeter = 1.0,
821 char** options = NULL ) {
822 GDALDatasetShadow *ds = GDALApplyVerticalShiftGrid( src_ds, grid_ds,
823 inverse,
824 srcUnitToMeter,
825 dstUnitToMeter,
826 options );
827 return ds;
828
829 }
830 %}
831 %clear GDALDatasetShadow *src_ds, GDALDatasetShadow *grid_ds;
832
833