Ignore:
Timestamp:
Mar 28, 2019, 11:31:26 PM (5 years ago)
Author:
djay
Message:

Add support for SAGA-GIS 7.2.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/prototype-v0/zoo-project/zoo-kernel/service_internal_saga.c

    r790 r900  
    3030#include <api_core.h>
    3131#include <data_manager.h>
    32 #include <module_library.h>
     32#include <saga_api.h>
    3333#define _ZOO_SAGA
    3434#include "service_internal_saga.h"
     
    237237        return false;
    238238      }
    239       return( param->Set_Value(SG_Get_Data_Manager().Find(&fileName)) );
     239      fprintf(stderr,"%s %s\n",carg->name,carg->value);
     240      fflush(stderr);
     241      return( param->Set_Value(SG_Get_Data_Manager().Find(&fileName,false)) );
    240242    }
    241243    else
     
    250252            SG_Get_Data_Manager().Add(&fileName);
    251253          }
    252           param->asList()->Add_Item(SG_Get_Data_Manager().Find(&fileName));
     254          param->asList()->Add_Item(SG_Get_Data_Manager().Find(&fileName,false));
    253255        }
    254256      }
     
    327329            inmap=getMap(argument,(CSG_String(param->Get_Identifier())+"_MIN").b_str());
    328330            if(inmap!=NULL)
     331#if SAGA_MAJOR_VERSION == 2           
    329332              param->asRange()->Set_LoVal(strtod(inmap->value,NULL));
     333#else
     334              param->asRange()->Set_Min(strtod(inmap->value,NULL));
     335#endif     
    330336            inmap=getMap(argument,(CSG_String(param->Get_Identifier())+"_MAX").b_str());
    331337            if(inmap!=NULL)
     338#if SAGA_MAJOR_VERSION == 2           
    332339              param->asRange()->Set_HiVal(strtod(inmap->value,NULL));       
     340#else
     341              param->asRange()->Set_Max(strtod(inmap->value,NULL));
     342#endif     
    333343          }
    334344          if(inmap==NULL){
     
    386396            else if( param->is_DataObject_List() )
    387397              {
    388                 for(int i=0; i<param->asList()->Get_Count(); i++)
     398                for(int i=0; i<
     399#if SAGA_MAJOR_VERSION == 2
     400                      param->asList()->Get_Count()
     401#else
     402                      param->asList()->Get_Data_Count()
     403#endif               
     404                      ; i++)
    389405                  {
    390                     CSG_Data_Object *pObject = param->asList()->asDataObject(i);
     406                    CSG_Data_Object *pObject =
     407#if SAGA_MAJOR_VERSION == 2                   
     408                      param->asList()->asDataObject(i)
     409#else
     410                      param->asList()->Get_Data(i)
     411#endif               
     412                      ;
    391413                   
    392414                    if( pObject->is_Modified() && SG_File_Exists(pObject->Get_File_Name()) )
     
    439461                        }
    440462                    }
    441                  
     463#if SAGA_MAJOR_VERSION == 2               
    442464                  int nFileNames = param->asList()->Get_Count() <= fileNames.Get_Count() ? fileNames.Get_Count() : fileNames.Get_Count() - 1;
    443465                  for(int i=0; i<param->asList()->Get_Count(); i++)
     
    458480                                  CSG_String(param->asList()->asDataObject(i)->Get_File_Name()).b_str());
    459481                    }
     482#else
     483                  int nFileNames = param->asList()->Get_Data_Count() <= fileNames.Get_Count() ? fileNames.Get_Count() : fileNames.Get_Count() - 1;
     484                  for(int i=0; i<param->asList()->Get_Data_Count(); i++)
     485                    {
     486                      if( i < nFileNames )
     487                        {
     488                          param->asList()->Get_Data(i)->Save(fileNames[i]);
     489                        }
     490                      else
     491                        {
     492                          param->asList()->Get_Data(i)->Save(CSG_String::Format(SG_T("%s_%0*d"),
     493                                                                                    fileNames[fileNames.Get_Count() - 1].c_str(),
     494                                                                                    SG_Get_Digit_Count(param->asList()->Get_Data_Count()),
     495                                                                                    1 + i - nFileNames
     496                                                                                    ));
     497                        }
     498                      setMapArray(cMaps->content,"generated_file",i,
     499                                  CSG_String(param->asList()->Get_Data(i)->Get_File_Name()).b_str());
     500                    }
     501                 
     502#endif           
    460503                }
    461504            }
     
    477520  int res=SERVICE_FAILED;
    478521
     522#if SAGA_MAJOR_VERSION == 2 
    479523  CSG_Module_Library * library=SG_Get_Module_Library_Manager().Get_Library(CSG_String(lib_name),true);
     524#else
     525  CSG_Tool_Library * library=SG_Get_Tool_Library_Manager().Get_Library(CSG_String(lib_name),true);
     526#endif 
    480527  if( library == NULL){
    481528    char tmp[255];
     
    486533  }
    487534
     535#if SAGA_MAJOR_VERSION == 2 
    488536  CSG_Module * module=library->Get_Module(atoi(module_name));
     537#else
     538  CSG_Tool * module=library->Get_Tool(atoi(module_name));
     539#endif 
    489540  if(module == NULL){
    490541    char tmp[255];
     
    9851036  SG_Set_UI_Callback(Get_Callback(watcher));
    9861037
     1038#if SAGA_MAJOR_VERSION == 2 
    9871039  int n = SG_Get_Module_Library_Manager().Add_Directory(wxT(MODULE_LIBRARY_PATH),false);
    988   if( SG_Get_Module_Library_Manager().Get_Count() <= 0 ){
     1040  if( SG_Get_Module_Library_Manager().Get_Count() <= 0 )
     1041#else
     1042  int n = SG_Get_Tool_Library_Manager().Add_Directory(wxT(MODULE_LIBRARY_PATH),false);
     1043  if( SG_Get_Tool_Library_Manager().Get_Count() <= 0 )
     1044#endif
     1045  {
    9891046    setMapInMaps(*main_conf,"lenv","message","Could not load any SAGA tool library");
    9901047    res=SERVICE_FAILED;
     
    9951052
    9961053  // Load the SAGA-GIS library corresponding to the serviceProvider
     1054#if SAGA_MAJOR_VERSION == 2 
    9971055  CSG_Module_Library * library=SG_Get_Module_Library_Manager().Get_Library(CSG_String(serviceProvider->value),true);
     1056#else
     1057  CSG_Tool_Library * library=SG_Get_Tool_Library_Manager().Get_Library(CSG_String(serviceProvider->value),true);
     1058#endif
    9981059  if( library == NULL){
    9991060    char tmp[255];
     
    10051066 
    10061067  // Load the SAGA-GIS module corresponding to the service name from the library
     1068#if SAGA_MAJOR_VERSION == 2 
    10071069  CSG_Module * module=library->Get_Module(atoi(s->name));
     1070#else
     1071  CSG_Tool * module=library->Get_Tool(atoi(s->name));
     1072#endif
    10081073  if(module == NULL){
    10091074    char tmp[255];
     
    10171082  // Load all the parameters defined for the module
    10181083  CSG_Parameters * params=module->Get_Parameters();
    1019   int pc=params->Get_Count();
    10201084  if(!params){
    10211085    char tmp[255];
     
    10261090    return res;
    10271091  }
     1092  int pc=params->Get_Count();
    10281093
    10291094  // Loop over each inputs to transform raster files to grid when needed,
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png