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

Function parse

src/fitcircle.c:153–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153static int parse (struct GMT_CTRL *GMT, struct FITCIRCLE_CTRL *Ctrl, struct GMT_OPTION *options) {
154 /* This parses the options provided to fitcircle and sets parameters in CTRL.
155 * Any GMT common options will override values set previously by other commands.
156 * It also replaces any file names specified as input or output with the data ID
157 * returned when registering these sources/destinations with the API.
158 */
159
160 unsigned int n_errors = 0;
161 size_t k, s_length;
162 struct GMT_OPTION *opt = NULL;
163 struct GMTAPI_CTRL *API = GMT->parent;
164
165 for (opt = options; opt; opt = opt->next) {
166 switch (opt->option) {
167
168 case '<': /* Skip input files */
169 if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
170 break;
171
172 /* Processes program-specific parameters */
173
174 case 'F': /* Select outputs for data */
175 n_errors += gmt_M_repeated_module_option (API, Ctrl->F.active);
176 s_length = strlen (opt->arg);
177 for (k = 0; k < s_length; k++) {
178 switch (opt->arg[k]) {
179 case 'f': Ctrl->F.mode |= 1; break;
180 case 'm': Ctrl->F.mode |= 2; break;
181 case 'n': Ctrl->F.mode |= 4; break;
182 case 's': Ctrl->F.mode |= 8; break;
183 case 'c': Ctrl->F.mode |= 16; break;
184 default:
185 GMT_Report (API, GMT_MSG_ERROR, "Option -F: Bad arg %s. Select any combination from fmnsc\n", opt->arg);
186 n_errors++;
187 break;
188 }
189 }
190 break;
191 case 'L': /* Select norm */
192 n_errors += gmt_M_repeated_module_option (API, Ctrl->L.active);
193 Ctrl->L.norm = (opt->arg[0]) ? atoi(opt->arg) : 3;
194 break;
195 case 'S': /* Fit small-circle instead [optionally fix the latitude] */
196 n_errors += gmt_M_repeated_module_option (API, Ctrl->S.active);
197 if (opt->arg[0]) {
198 Ctrl->S.lat = atof (opt->arg);
199 Ctrl->S.mode = 1;
200 }
201 break;
202
203 default: /* Report bad options */
204 n_errors += gmt_default_option_error (GMT, opt);
205 break;
206 }
207 }
208 if (Ctrl->F.active && Ctrl->F.mode == 0) Ctrl->F.mode = (Ctrl->S.active) ? 31 : 15; /* Select all */
209
210 n_errors += gmt_M_check_condition (GMT, Ctrl->F.mode & 16 && !Ctrl->S.active, "Option -F: Cannot select c without setting -S\n");

Callers 1

GMT_fitcircleFunction · 0.70

Calls 4

GMT_Get_FilePathFunction · 0.85
GMT_ReportFunction · 0.85
gmt_default_option_errorFunction · 0.85
gmt_check_binary_ioFunction · 0.85

Tested by

no test coverage detected