ZOO-Project
Data Structures | Macros | Functions | Variables
service_internal_saga.c File Reference
#include <stdlib.h>
#include <limits.h>
#include <locale.h>
#include <wx/string.h>
#include <wx/app.h>
#include <api_core.h>
#include <data_manager.h>
#include <saga_api.h>
#include "service_internal_saga.h"
#include "server_internal.h"
#include "mimetypes.h"

Data Structures

class  SagaWatcher
 Observer used to access the ongoing status of a running OTB Application. More...
 

Macros

#define _ZOO_SAGA
 

Functions

TSG_PFNC_UI_Callback Get_Callback (SagaWatcher watcher)
 
const char * sagaGetDefaultExt (CSG_Parameter *param)
 Get the default file extension for SAGA-GIS parameter type. More...
 
bool sagaLoadInput (CSG_Parameter *param, map *arg)
 Load a datasource in the SAGA-GIS Data Manager. More...
 
bool sagaSetParameters (CSG_Parameters *params, map *argument)
 Extract all SAGA-GIS parameters from a parameters list and set its values to the one defined in the map. More...
 
bool sagaSaveOutputs (CSG_Parameters *params, maps *main_conf, maps **outputs)
 Save all values outputed by a SAGA-GIS module invocation to files. More...
 
int sagaExecuteCmd (maps **main_conf, const char *lib_name, const char *module_name, map *arguments, maps **outputs=NULL)
 Invoke the execution of a SAGA-GIS module. More...
 
int sagaExportOGR (maps **conf, maps **in)
 Export a SAGA-GIS Shapes to a file in a specific format (GML,KML,GeoJSON). More...
 
void sagaExportPC (maps **conf, maps **in)
 Export a SAGA-GIS pointcloud to a las file. More...
 
int sagaExportGDAL (maps **conf, maps **in)
 Export a SAGA-GIS Grid to a file in a specific format (tiff,hdr,aa). More...
 
int sagaExportTIN (maps **conf, maps **in, const char *tname)
 Export a SAGA-GIS TIN to a file in a specific format (GML,KML,GeoJSON). More...
 
int sagaImportGDAL (maps **conf, maps **in)
 Import GDAL Datasource into SAGA-GIS. More...
 
int sagaImportOGR (maps **conf, maps **in)
 Import OGR Datasource into SAGA-GIS. More...
 
bool sagaImportTIN (maps **conf, maps **in)
 Import TIN into SAGA-GIS. More...
 
int sagaImportTable (maps **conf, maps **in)
 Import table into SAGA-GIS. More...
 
int sagaImportPC (maps **conf, maps **in)
 Import las file as pointcloud into SAGA-GIS. More...
 
int zoo_saga_support (maps **main_conf, map *request, service *s, maps **inputs, maps **outputs)
 Load and invoke a SAGA-GIS module defined in a service metadata definitions. More...
 

Variables

int sagaOutputCounter =0
 Global SAGA-GIS output counter. More...
 

Macro Definition Documentation

◆ _ZOO_SAGA

#define _ZOO_SAGA

Function Documentation

◆ Get_Callback()

TSG_PFNC_UI_Callback Get_Callback ( SagaWatcher  watcher)

◆ sagaExecuteCmd()

int sagaExecuteCmd ( maps **  main_conf,
const char *  lib_name,
const char *  module_name,
map arguments,
maps **  outputs = NULL 
)

Invoke the execution of a SAGA-GIS module.

Parameters
main_confthe conf maps containing the main.cfg settings
lib_namethe SAGA-GIS library name
module_namethe SAGA-GIS module name
argumentsthe map containing the arguments to pass to the module
outputsdefault to NULL, contains the maps to fill with the result

◆ sagaExportGDAL()

int sagaExportGDAL ( maps **  conf,
maps **  in 
)

Export a SAGA-GIS Grid to a file in a specific format (tiff,hdr,aa).

saga_cmd io_gdal 1 -FILE my.format -GRIDS my.sgrd -FORMAT XXX

Parameters
main_confthe conf maps containing the main.cfg settings
inthe output maps to fill with the resulting file

◆ sagaExportOGR()

int sagaExportOGR ( maps **  conf,
maps **  in 
)

Export a SAGA-GIS Shapes to a file in a specific format (GML,KML,GeoJSON).

saga_cmd io_gdal 4 -FILE my.format -SHAPES my.shp -FORMAT XXX

Parameters
main_confthe conf maps containing the main.cfg settings
inthe output maps to fill with the resulting file

◆ sagaExportPC()

void sagaExportPC ( maps **  conf,
maps **  in 
)

Export a SAGA-GIS pointcloud to a las file.

saga_cmd io_shapes_las 0 -POINTS my.spc -FILE my.las

Parameters
main_confthe conf maps containing the main.cfg settings
inthe output maps to fill with the resulting file

◆ sagaExportTIN()

int sagaExportTIN ( maps **  conf,
maps **  in,
const char *  tname 
)

Export a SAGA-GIS TIN to a file in a specific format (GML,KML,GeoJSON).

Exporting TIN produce 5 separated files (POINTS, CENTER, EDGES, TRIANGLES and POLYGONS). Even if a client can choose which result it want to have, SAGA-GIS module will be invoked in a way that it will produce in any case each possible outputs. The selection of a specific output is made in the ZOO-Kernel itself and not specifically at this level. saga_cmd tin_tools 3 -TIN my.shp -POINTS p.shp ...

Parameters
confthe conf maps containing the main.cfg settings
inthe output maps to fill with the resulting file
See also
sagaExportOGR

◆ sagaGetDefaultExt()

const char* sagaGetDefaultExt ( CSG_Parameter *  param)

Get the default file extension for SAGA-GIS parameter type.

Extensions are the following:

  • sgrd for grid and data_object
  • shp for shapes and tin
  • csv for tables
  • spc for points
Parameters
parama SAGA-GIS Parameter

◆ sagaImportGDAL()

int sagaImportGDAL ( maps **  conf,
maps **  in 
)

Import GDAL Datasource into SAGA-GIS.

saga_cmd io_gdal 0 -TRANSFORM 0 -FILES my.format -GRIDS /tmpPath/MyGridXXX.sgrd

Parameters
confthe conf maps containing the main.cfg settings
inin the inputs maps

◆ sagaImportOGR()

int sagaImportOGR ( maps **  conf,
maps **  in 
)

Import OGR Datasource into SAGA-GIS.

saga_cmd io_gdal 3 -SHAPES my.shp -FILES my.format

Parameters
confthe conf maps containing the main.cfg settings
inin the inputs maps

◆ sagaImportPC()

int sagaImportPC ( maps **  conf,
maps **  in 
)

Import las file as pointcloud into SAGA-GIS.

saga_cmd io_shapes_las 1 -POINTS my.spc -FILENAME my.las

Parameters
confthe conf maps containing the main.cfg settings
inin the inputs maps

◆ sagaImportTable()

int sagaImportTable ( maps **  conf,
maps **  in 
)

Import table into SAGA-GIS.

saga_cmd io_table 1 -TABLE myTable -FILENAME myFile -SEPARATOR 2

Parameters
confthe conf maps containing the main.cfg settings
inin the inputs maps

◆ sagaImportTIN()

bool sagaImportTIN ( maps **  conf,
maps **  in 
)

Import TIN into SAGA-GIS.

Calling this function suppose that sagaImportOGR was called first. saga_cmd tin_tools 2 -SHAPES myShapes.shp -TIN myTin.shp

Parameters
confthe conf maps containing the main.cfg settings
inin the inputs maps
See also
sagaImportOGR

◆ sagaLoadInput()

bool sagaLoadInput ( CSG_Parameter *  param,
map arg 
)

Load a datasource in the SAGA-GIS Data Manager.

Parameters
parama SAGA-GIS Parameter
argthe arguments map passed to a SAGA-GIS module
Returns
false on failure, true in case of success

◆ sagaSaveOutputs()

bool sagaSaveOutputs ( CSG_Parameters *  params,
maps main_conf,
maps **  outputs 
)

Save all values outputed by a SAGA-GIS module invocation to files.

Parameters
paramsthe parameters list
main_confthe conf maps containing the main.cfg settings
outputsthe maps to set the generated_file for each output

◆ sagaSetParameters()

bool sagaSetParameters ( CSG_Parameters *  params,
map argument 
)

Extract all SAGA-GIS parameters from a parameters list and set its values to the one defined in the map.

@parap params the parameters list @parap argument the argument map containing the value to use

Returns
true in success, false in other case

◆ zoo_saga_support()

int zoo_saga_support ( maps **  main_conf,
map request,
service s,
maps **  inputs,
maps **  outputs 
)

Load and invoke a SAGA-GIS module defined in a service metadata definitions.

Load all the input data into SAGA-GIS using io_gdal, io_tables and io_shapes_las for SAGA grids/shapes, tables and pointcloud respectively. Load and run the module from its library and invoke it using the data imported in SAGA-GIS at first stage. After the execution, export the outputs to files using io_gdal and io_shapes_las for grids/shapes and pointcloud respectively.

Parameters
main_confthe conf maps containing the main.cfg settings
requestthe map containing the HTTP request
sthe service structure
inputsthe maps containing the inputs
outputsthe maps containing the outputs

Variable Documentation

◆ sagaOutputCounter

int sagaOutputCounter =0

Global SAGA-GIS output counter.