Changeset 14775

Show
Ignore:
Timestamp:
06/27/08 23:37:46 (5 months ago)
Author:
warmerdam
Message:

add ComputeProximity? operation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/swig/include/Operations.i

    r14263 r14775  
    128128     
    129129    return err; 
     130} 
     131%}  
     132 
     133/************************************************************************/ 
     134/*                          ComputeProximity()                          */ 
     135/************************************************************************/ 
     136 
     137%feature( "kwargs" ) ComputeProximity; 
     138%inline %{ 
     139int  ComputeProximity( GDALRasterBandShadow *srcBand, 
     140                       GDALRasterBandShadow *proximityBand, 
     141                       char **options = NULL, 
     142                       GDALProgressFunc callback=NULL, 
     143                       void* callback_data=NULL) { 
     144 
     145    CPLErrorReset(); 
     146 
     147    return GDALComputeProximity( srcBand, proximityBand, options, 
     148                                 callback, callback_data ); 
    130149} 
    131150%}  
  • trunk/gdal/swig/python/extensions/gdal_wrap.cpp

    r14263 r14775  
    37133713 
    37143714 
     3715int  ComputeProximity( GDALRasterBandShadow *srcBand, 
     3716                       GDALRasterBandShadow *proximityBand, 
     3717                       char **options = NULL, 
     3718                       GDALProgressFunc callback=NULL, 
     3719                       void* callback_data=NULL) { 
     3720 
     3721    CPLErrorReset(); 
     3722 
     3723    return GDALComputeProximity( srcBand, proximityBand, options, 
     3724                                 callback, callback_data ); 
     3725} 
     3726 
     3727 
    37153728GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds, 
    37163729                                        const char *src_wkt = 0, 
     
    1241212425  if (alloc3 == SWIG_NEWOBJ) delete[] buf3; 
    1241312426  if (alloc4 == SWIG_NEWOBJ) delete[] buf4; 
     12427  return NULL; 
     12428} 
     12429 
     12430 
     12431SWIGINTERN PyObject *_wrap_ComputeProximity(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { 
     12432  PyObject *resultobj = 0; 
     12433  GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ; 
     12434  GDALRasterBandShadow *arg2 = (GDALRasterBandShadow *) 0 ; 
     12435  char **arg3 = (char **) NULL ; 
     12436  GDALProgressFunc arg4 = (GDALProgressFunc) NULL ; 
     12437  void *arg5 = (void *) NULL ; 
     12438  int result; 
     12439  void *argp1 = 0 ; 
     12440  int res1 = 0 ; 
     12441  void *argp2 = 0 ; 
     12442  int res2 = 0 ; 
     12443  PyObject * obj0 = 0 ; 
     12444  PyObject * obj1 = 0 ; 
     12445  PyObject * obj2 = 0 ; 
     12446  PyObject * obj3 = 0 ; 
     12447  PyObject * obj4 = 0 ; 
     12448  char *  kwnames[] = { 
     12449    (char *) "srcBand",(char *) "proximityBand",(char *) "options",(char *) "callback",(char *) "callback_data", NULL  
     12450  }; 
     12451   
     12452  /* %typemap(arginit) ( const char* callback_data=NULL)  */ 
     12453  PyProgressData *psProgressInfo; 
     12454  psProgressInfo = (PyProgressData *) CPLCalloc(1,sizeof(PyProgressData)); 
     12455  psProgressInfo->nLastReported = -1; 
     12456  psProgressInfo->psPyCallback = NULL; 
     12457  psProgressInfo->psPyCallbackData = NULL; 
     12458  if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO|OOO:ComputeProximity",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; 
     12459  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_GDALRasterBandShadow, 0 |  0 ); 
     12460  if (!SWIG_IsOK(res1)) { 
     12461    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ComputeProximity" "', argument " "1"" of type '" "GDALRasterBandShadow *""'");  
     12462  } 
     12463  arg1 = reinterpret_cast< GDALRasterBandShadow * >(argp1); 
     12464  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_GDALRasterBandShadow, 0 |  0 ); 
     12465  if (!SWIG_IsOK(res2)) { 
     12466    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ComputeProximity" "', argument " "2"" of type '" "GDALRasterBandShadow *""'");  
     12467  } 
     12468  arg2 = reinterpret_cast< GDALRasterBandShadow * >(argp2); 
     12469  if (obj2) { 
     12470    { 
     12471      /* %typemap(in) char **options */ 
     12472      /* Check if is a list */ 
     12473      if ( ! PySequence_Check(obj2)) { 
     12474        PyErr_SetString(PyExc_TypeError,"not a sequence"); 
     12475        SWIG_fail; 
     12476      } 
     12477       
     12478      int size = PySequence_Size(obj2); 
     12479      for (int i = 0; i < size; i++) { 
     12480        char *pszItem = NULL; 
     12481        if ( ! PyArg_Parse( PySequence_GetItem(obj2,i), "s", &pszItem ) ) { 
     12482          PyErr_SetString(PyExc_TypeError,"sequence must contain strings"); 
     12483          SWIG_fail; 
     12484        } 
     12485        arg3 = CSLAddString( arg3, pszItem ); 
     12486      } 
     12487    } 
     12488  } 
     12489  if (obj3) { 
     12490    { 
     12491      /* %typemap(in) (GDALProgressFunc callback = NULL) */ 
     12492      /* callback_func typemap */ 
     12493      if (obj3) { 
     12494        void* cbfunction = NULL; 
     12495        SWIG_ConvertPtr( obj3,  
     12496          (void**)&cbfunction,  
     12497          SWIGTYPE_p_f_double_p_q_const__char_p_void__int,  
     12498          SWIG_POINTER_EXCEPTION | 0 ); 
     12499         
     12500        if ( cbfunction == GDALTermProgress ) { 
     12501          arg4 = GDALTermProgress; 
     12502        } else { 
     12503          if (!PyFunction_Check(obj3)) { 
     12504            PyErr_SetString( PyExc_RuntimeError,  
     12505              "Object given is not a Python function" ); 
     12506            SWIG_fail; 
     12507          } 
     12508          psProgressInfo->psPyCallback = obj3; 
     12509          arg4 = PyProgressProxy; 
     12510        } 
     12511         
     12512      } 
     12513       
     12514    } 
     12515  } 
     12516  if (obj4) { 
     12517    { 
     12518      /* %typemap(in) ( void* callback_data=NULL)  */ 
     12519       
     12520      psProgressInfo->psPyCallbackData = obj4 ; 
     12521      arg5 = psProgressInfo; 
     12522       
     12523    } 
     12524  } 
     12525  { 
     12526    result = (int)ComputeProximity(arg1,arg2,arg3,arg4,arg5); 
     12527    if ( bUseExceptions ) { 
     12528      CPLErr eclass = CPLGetLastErrorType(); 
     12529      if ( eclass == CE_Failure || eclass == CE_Fatal ) { 
     12530        SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() ); 
     12531      } 
     12532    } 
     12533  } 
     12534  resultobj = SWIG_From_int(static_cast< int >(result)); 
     12535  { 
     12536    /* %typemap(freearg) char **options */ 
     12537    CSLDestroy( arg3 ); 
     12538  } 
     12539  { 
     12540    /* %typemap(freearg) ( void* callback_data=NULL)  */ 
     12541     
     12542    CPLFree(psProgressInfo); 
     12543     
     12544  } 
     12545  return resultobj; 
     12546fail: 
     12547  { 
     12548    /* %typemap(freearg) char **options */ 
     12549    CSLDestroy( arg3 ); 
     12550  } 
     12551  { 
     12552    /* %typemap(freearg) ( void* callback_data=NULL)  */ 
     12553     
     12554    CPLFree(psProgressInfo); 
     12555     
     12556  } 
    1241412557  return NULL; 
    1241512558} 
     
    1391514058         { (char *)"DitherRGB2PCT", (PyCFunction) _wrap_DitherRGB2PCT, METH_VARARGS | METH_KEYWORDS, NULL}, 
    1391614059         { (char *)"ReprojectImage", _wrap_ReprojectImage, METH_VARARGS, NULL}, 
     14060         { (char *)"ComputeProximity", (PyCFunction) _wrap_ComputeProximity, METH_VARARGS | METH_KEYWORDS, NULL}, 
    1391714061         { (char *)"AutoCreateWarpedVRT", _wrap_AutoCreateWarpedVRT, METH_VARARGS, NULL}, 
    1391814062         { (char *)"new_Transformer", _wrap_new_Transformer, METH_VARARGS, NULL},