GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-847944e18e
|
GIS Library - converts the command line arguments into actinia JSON process chain building blocks. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <grass/glocale.h>
#include <grass/gis.h>
#include "parser_local_proto.h"
Go to the source code of this file.
Functions | |
void | check_create_import_opts (struct Option *, char *, FILE *) |
void | check_create_export_opts (struct Option *, char *, FILE *) |
char * | check_mapset_in_layer_name (char *, int) |
char * | G__json (void) |
This function generates actinia JSON process chain building blocks from the command line arguments that can be used in the actinia processing API. More... | |
GIS Library - converts the command line arguments into actinia JSON process chain building blocks.
(C) 2018-2021 by the GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Definition in file parser_json.c.
void check_create_export_opts | ( | struct Option * | opt, |
char * | element, | ||
FILE * | fp | ||
) |
Definition at line 449 of file parser_json.c.
References Option::answer, check_mapset_in_layer_name(), G_chop(), G_free_tokens(), G_strncasecmp(), G_tokenize(), and Option::key.
void check_create_import_opts | ( | struct Option * | opt, |
char * | element, | ||
FILE * | fp | ||
) |
Definition at line 364 of file parser_json.c.
References _, Option::answer, check_mapset_in_layer_name(), G_chop(), G_debug(), G_fatal_error(), G_free_tokens(), G_strncasecmp(), G_tokenize(), and Option::key.
char * check_mapset_in_layer_name | ( | char * | layer_name, |
int | always_remove | ||
) |
Definition at line 506 of file parser_json.c.
References G_chop(), G_mapset(), G_strcasecmp(), and G_tokenize().
Referenced by check_create_export_opts(), and check_create_import_opts().
char* G__json | ( | void | ) |
This function generates actinia JSON process chain building blocks from the command line arguments that can be used in the actinia processing API.
The following commands will create according JSON output:
r.slope.aspect elevation="elevation@https://storage.googleapis.com/graas-geodata/elev_ned_30m.tif" slope="slope+GTiff" aspect="aspect+GTiff" –json
{ "module": "r.slope.aspect", "id": "r.slope.aspect_1804289383", "inputs":[ {"import_descr": {"source":"https://storage.googleapis.com/graas-geodata/elev_ned_30m.tif", "type":"raster"}, "param": "elevation", "value": "elevation"}, {"param": "format", "value": "degrees"}, {"param": "precision", "value": "FCELL"}, {"param": "zscale", "value": "1.0"}, {"param": "min_slope", "value": "0.0"} ], "outputs":[ {"export": {"format":"GTiff", "type":"raster"}, "param": "slope", "value": "slope"}, {"export": {"format":"GTiff", "type":"raster"}, "param": "aspect", "value": "aspect"} ] }
v.out.ascii input="hospitals@PERMANENT" output="myfile+TXT" –json
{ "module": "v.out.ascii", "id": "v.out.ascii_1804289383", "inputs":[ {"param": "input", "value": "hospitals@PERMANENT"}, {"param": "layer", "value": "1"}, {"param": "type", "value": "point,line,boundary,centroid,area,face,kernel"}, {"param": "format", "value": "point"}, {"param": "separator", "value": "pipe"}, {"param": "precision", "value": "8"} ], "outputs":[ {"export": {"format":"TXT", "type":"file"}, "param": "output", "value": "$file::myfile"} ] }
v.info map="hospitals@PERMANENT" -c –json
{ "module": "v.info", "id": "v.info_1804289383", "flags":"c", "inputs":[ {"param": "map", "value": "hospitals@PERMANENT"}, {"param": "layer", "value": "1"} ] }
A process chain has the following form
{ 'list': [{ 'module': 'g.region', 'id': 'g_region_1', 'inputs': [{'import_descr': {'source': 'https://storage.googleapis.com/graas-geodata/elev_ned_30m.tif', 'type': 'raster'}, 'param': 'raster', 'value': 'elev_ned_30m_new'}], 'flags': 'p' }, { 'module': 'r.slope.aspect', 'id': 'r_slope_aspect_1', 'inputs': [{'param': 'elevation', 'value': 'elev_ned_30m_new'}], 'outputs': [{'export': {'format': 'GTiff', 'type': 'raster'}, 'param': 'slope', 'value': 'elev_ned_30m_new_slope'}], 'flags': 'a'}, { 'module': 'r.univar', 'id': 'r_univar_1', 'inputs': [{"import_descr": {"source": "LT52170762005240COA00", "type": "landsat", "landsat_atcor": "dos1"}, 'param': 'map', 'value': 'LT52170762005240COA00_dos1.1'}], 'stdout': {'id': 'stats', 'format': 'kv', 'delimiter': '='}, 'flags': 'a' }, { 'module': 'exporter', 'id': 'exporter_1', 'outputs': [{'export': {'format': 'GTiff', 'type': 'raster'}, 'param': 'map', 'value': 'LT52170762005240COA00_dos1.1'}] }, { "id": "ascii_out", "module": "r.out.ascii", "inputs": [{"param": "input", "value": "elevation@PERMANENT"}, {"param": "precision", "value": "0"}], "stdout": {"id": "elev_1", "format": "table", "delimiter": " "}, "flags": "h" }, { "id": "ascii_export", "module": "r.out.ascii", "inputs": [{"param": "input", "value": "elevation@PERMANENT"}], "outputs": [ {"export": {"type": "file", "format": "TXT"}, "param": "output", "value": "$file::out1"} ] }, { "id": "raster_list", "module": "g.list", "inputs": [{"param": "type", "value": "raster"}], "stdout": {"id": "raster", "format": "list", "delimiter": "\n"} }, { "module": "r.what", "id": "r_what_1", "verbose": True, "flags": "nfic", "inputs": [ { "param": "map", "value": "landuse96_28m@PERMANENT" }, { "param": "coordinates", "value": "633614.08,224125.12,632972.36,225382.87" }, { "param": "null_value", "value": "null" }, { "param": "separator", "value": "pipe" } ], "stdout": {"id": "sample", "format": "table", "delimiter": "|"} } ], 'webhooks': {'update': 'http://business-logic.company.com/api/v1/actinia-update-webhook', 'finished': 'http://business-logic.company.com/api/v1/actinia-finished-webhook'}, 'version': '1' }
Definition at line 190 of file parser_json.c.