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

Function parse

src/triangulate.c:242–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242static int parse(struct GMT_CTRL *GMT, struct TRIANGULATE_CTRL *Ctrl, struct GMT_OPTION *options) {
243 /* This parses the options provided to triangulate and sets parameters in CTRL.
244 * Any GMT common options will override values set previously by other commands.
245 * It also replaces any file names specified as input or output with the data ID
246 * returned when registering these sources/destinations with the API.
247 */
248
249 unsigned int n_errors = 0;
250 char *c = NULL;
251 struct GMT_OPTION *opt = NULL;
252 struct GMTAPI_CTRL *API = GMT->parent;
253
254 for (opt = options; opt; opt = opt->next) {
255 switch (opt->option) {
256
257 case '<': /* Skip input files after checking they exist */
258 if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
259 break;
260 case '>': /* Got named output file */
261 n_errors += gmt_M_repeated_module_option (API, Ctrl->Out.active);
262 n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_DATASET, GMT_OUT, GMT_FILE_LOCAL, &(Ctrl->Out.file));
263 break;
264
265 /* Processes program-specific parameters */
266
267 case 'A': /* Calculate triangle areas and add to header in -S */
268 n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
269 break;
270 case 'C': /* CURVE input slope grid */
271 n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active);
272 n_errors += gmt_get_required_file (GMT, opt->arg, opt->option, 0, GMT_IS_GRID, GMT_IN, GMT_FILE_REMOTE, &(Ctrl->C.file));
273 break;
274 case 'D':
275 n_errors += gmt_M_repeated_module_option (API, Ctrl->D.active);
276 switch (opt->arg[0]) {
277 case 'x': case 'X':
278 Ctrl->D.dir = GMT_X; break;
279 case 'y': case 'Y':
280 Ctrl->D.dir = GMT_Y; break;
281 default:
282 GMT_Report (API, GMT_MSG_ERROR, "Option -D: Give -Dx or -Dy\n");
283 n_errors++; break;
284 }
285 break;
286 case 'E':
287 n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active);
288 Ctrl->E.value = (opt->arg[0] == 'N' || opt->arg[0] == 'n') ? GMT->session.d_NaN : atof (opt->arg);
289 break;
290 case 'F': /* Previous grid input values used */
291 if (gmt_M_compat_check (GMT, 4) && opt->arg[0] == 0) { /* Old -F instead of -r */
292 GMT_Report (API, GMT_MSG_COMPAT, "Option -F is deprecated. Use -r instead.\n" );
293 n_errors += gmt_parse_common_options (GMT, "r", 'r', "");
294 break;
295 }
296 n_errors += gmt_M_repeated_module_option (API, Ctrl->F.active);
297 GMT_Report (API, GMT_MSG_WARNING, "-F is experimental and unstable.\n");
298 if ((c = strstr (opt->arg, "+d"))) { /* Got modifier to also use input data */
299 c[0] = '\0'; /* Temporarily chop off modifier */

Callers 1

GMT_triangulateFunction · 0.70

Calls 10

GMT_Get_FilePathFunction · 0.85
gmt_get_required_fileFunction · 0.85
GMT_ReportFunction · 0.85
gmt_parse_common_optionsFunction · 0.85
strdupFunction · 0.85
gmt_parse_inc_optionFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_get_no_argumentFunction · 0.85
gmt_check_binary_ioFunction · 0.85

Tested by

no test coverage detected