MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / parse

Function parse

src/grdselect.c:214–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214static int parse (struct GMT_CTRL *GMT, struct GRDSELECT_CTRL *Ctrl, struct GMT_OPTION *options) {
215
216 /* This parses the options provided to grdselect and sets parameters in CTRL.
217 * Any GMT common options will override values set previously by other commands.
218 * It also replaces any file names specified as input or output with the data ID
219 * returned when registering these sources/destinations with the API.
220 */
221
222 unsigned int n_errors = 0, k = 0, nc = 0, ng = 0;
223 char string[GMT_LEN128] = {""}, *c = NULL;
224 struct GMT_OPTION *opt = NULL;
225 struct GMTAPI_CTRL *API = GMT->parent;
226
227 /* First precheck if we are dealing with cubes or grids - no mixing is allowed */
228
229 for (opt = options; opt; opt = opt->next) { /* Loop over arguments, skip options */
230
231 if (opt->option != '<') continue; /* We are only processing filenames here */
232
233 if (gmt_M_memfile_is_grid (opt->arg)) /* Can just check file name */
234 ng++;
235 else if (gmt_M_memfile_is_cube (opt->arg)) /* Can just check file name */
236 nc++;
237 else if (gmt_nc_is_cube (API, opt->arg)) /* Determine if this file is a netCDF cube or not */
238 nc++;
239 else /* Thus a grid */
240 ng++;
241 }
242
243 if (nc && ng) {
244 GMT_Report (API, GMT_MSG_ERROR, "Cannot give a mixed list of data cubes and data grids\n");
245 n_errors++;
246 goto time_to_return;
247 }
248 Ctrl->is_cube = (nc > 0);
249
250 for (opt = options; opt; opt = opt->next) { /* Process all the options given */
251
252 switch (opt->option) {
253 /* Common parameters */
254
255 case '<': /* Input files */
256 if (GMT_Get_FilePath (API, GMT_IS_GRID, GMT_IN, GMT_FILE_REMOTE, &(opt->arg)))
257 n_errors++;
258 else
259 Ctrl->n_files++;
260 break;
261
262 /* Processes program-specific parameters */
263
264 case 'A': /* Area comparisons */
265 n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
266 switch (opt->arg[0]) {
267 case 'u': Ctrl->A.mode = GRDSELECT_UNION; k = 1; break;
268 case 'i': Ctrl->A.mode = GRDSELECT_INTERSECTION; k = 1; break;
269 default: k = 0; break; /* No directive, default to intersection */
270 }
271 if (gmt_get_modifier (opt->arg, 'i', string)) { /* Want to control rounding */

Callers 1

GMT_grdselectFunction · 0.70

Calls 10

gmt_nc_is_cubeFunction · 0.85
GMT_ReportFunction · 0.85
GMT_Get_FilePathFunction · 0.85
gmt_get_modifierFunction · 0.85
gmt_getincFunction · 0.85
gmt_get_required_fileFunction · 0.85
gmt_inc_syntaxFunction · 0.85
GMT_Get_ValuesFunction · 0.85
gmt_get_limitsFunction · 0.85
gmt_default_option_errorFunction · 0.85

Tested by

no test coverage detected