| 334 | #define Return(code) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);} |
| 335 | |
| 336 | EXTERN_MSC int GMT_sample1d(void *V_API, int mode, void *args) { |
| 337 | unsigned int geometry, int_mode; |
| 338 | int error = 0, result; |
| 339 | |
| 340 | unsigned char *nan_flag = NULL; |
| 341 | |
| 342 | uint64_t k, tbl, col, row, seg, m = 0, dim[GMT_DIM_SIZE] = {0, 0, 0, 0}; |
| 343 | |
| 344 | double *t_out = NULL, *dist_in = NULL, *ttime = NULL, *data = NULL; |
| 345 | double low_t, high_t, *lon = NULL, *lat = NULL, *weight = NULL; |
| 346 | |
| 347 | struct GMT_DATASET *Din = NULL, *Dout = NULL; |
| 348 | struct GMT_DATATABLE *Tout = NULL; |
| 349 | struct GMT_DATASEGMENT *S = NULL, *Sout = NULL; |
| 350 | struct GMT_DATASEGMENT_HIDDEN *SH = NULL; |
| 351 | struct SAMPLE1D_CTRL *Ctrl = NULL; |
| 352 | struct GMT_CTRL *GMT = NULL, *GMT_cpy = NULL; |
| 353 | struct GMT_OPTION *options = NULL; |
| 354 | struct GMTAPI_CTRL *API = gmt_get_api_ptr (V_API); /* Cast from void to GMTAPI_CTRL pointer */ |
| 355 | |
| 356 | /*----------------------- Standard module initialization and parsing ----------------------*/ |
| 357 | |
| 358 | if (API == NULL) return (GMT_NOT_A_SESSION); |
| 359 | if (mode == GMT_MODULE_PURPOSE) return (usage (API, GMT_MODULE_PURPOSE)); /* Return the purpose of program */ |
| 360 | options = GMT_Create_Options (API, mode, args); if (API->error) return (API->error); /* Set or get option list */ |
| 361 | |
| 362 | if ((error = gmt_report_usage (API, options, 0, usage)) != GMT_NOERROR) bailout (error); /* Give usage if requested */ |
| 363 | |
| 364 | /* Parse the command-line arguments */ |
| 365 | |
| 366 | if ((GMT = gmt_init_module (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_KEYS, THIS_MODULE_NEEDS, module_kw, &options, &GMT_cpy)) == NULL) bailout (API->error); /* Save current state */ |
| 367 | if (GMT_Parse_Common (API, THIS_MODULE_OPTIONS, options)) Return (API->error); |
| 368 | Ctrl = New_Ctrl (GMT); /* Allocate and initialize a new control structure */ |
| 369 | if ((error = parse (GMT, Ctrl, options)) != 0) Return (error); |
| 370 | |
| 371 | /*---------------------------- This is the sample1d main code ----------------------------*/ |
| 372 | |
| 373 | GMT_Report (API, GMT_MSG_INFORMATION, "Processing input table data\n"); |
| 374 | GMT->current.setting.interpolant = Ctrl->F.mode % 10; |
| 375 | GMT->current.io.skip_if_NaN[GMT_X] = GMT->current.io.skip_if_NaN[GMT_Y] = false; /* Turn off default GMT NaN-handling for (x,y) which is not the case here */ |
| 376 | GMT->current.io.skip_if_NaN[Ctrl->N.col] = true; /* ... But disallow NaN in "time" column */ |
| 377 | int_mode = gmt_set_interpolate_mode (GMT, Ctrl->F.mode, Ctrl->F.type); /* What mode we pass to the interpolater */ |
| 378 | |
| 379 | if (Ctrl->T.T.spatial) { |
| 380 | if (gmt_M_is_cartesian (GMT, GMT_IN) && Ctrl->A.loxo) { |
| 381 | GMT_Report (API, GMT_MSG_ERROR, "Loxodrome mode ignored for Cartesian data.\n"); |
| 382 | Ctrl->A.loxo = false; |
| 383 | } |
| 384 | if (Ctrl->A.loxo) GMT->current.map.loxodrome = true; |
| 385 | GMT->hidden.sample_along_arc = true; /* Ensure equidistant sampling along arc, not cord */ |
| 386 | } |
| 387 | |
| 388 | geometry = (Ctrl->T.T.spatial) ? GMT_IS_LINE : GMT_IS_NONE; |
| 389 | if (GMT_Init_IO (API, GMT_IS_DATASET, geometry, GMT_IN, GMT_ADD_DEFAULT, 0, options) != GMT_NOERROR) { /* Establishes data input */ |
| 390 | Return (API->error); |
| 391 | } |
| 392 | if (GMT_Init_IO (API, GMT_IS_DATASET, geometry, GMT_OUT, GMT_ADD_DEFAULT, 0, options) != GMT_NOERROR) { /* Establishes data output */ |
| 393 | Return (API->error); |
nothing calls this directly
no test coverage detected