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

Function GMT_grdvector

src/grdvector.c:425–893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423#define Return(code) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}
424
425EXTERN_MSC int GMT_grdvector (void *V_API, int mode, void *args) {
426 openmp_int row, col, col_0, row_0, d_col, d_row;
427 unsigned int justify, k, n_warn[3] = {0, 0, 0}, warn;
428 int error = 0;
429 bool Geographic;
430
431 uint64_t ij;
432
433 double tmp, x, y, plot_x, plot_y, x_off, y_off, f, headpen_width = 0.0;
434 double x2, y2, wesn[4], value, vec_data_length, vec_azim, scaled_vec_length, c, s, dim[PSL_MAX_DIMS];
435
436 struct GMT_GRID *Grid[2] = {NULL, NULL};
437 struct GMT_PALETTE *P = NULL;
438 struct GMT_PEN last_headpen;
439 struct GRDVECTOR_CTRL *Ctrl = NULL;
440 struct GMT_CTRL *GMT = NULL, *GMT_cpy = NULL; /* General GMT internal parameters */
441 struct GMT_OPTION *options = NULL;
442 struct PSL_CTRL *PSL = NULL; /* General PSL internal parameters */
443 struct GMTAPI_CTRL *API = gmt_get_api_ptr (V_API); /* Cast from void to GMTAPI_CTRL pointer */
444
445 /*----------------------- Standard module initialization and parsing ----------------------*/
446
447 if (API == NULL) return (GMT_NOT_A_SESSION);
448 if (mode == GMT_MODULE_PURPOSE) return (usage (API, GMT_MODULE_PURPOSE)); /* Return the purpose of program */
449 options = GMT_Create_Options (API, mode, args); if (API->error) return (API->error); /* Set or get option list */
450
451 if ((error = gmt_report_usage (API, options, 0, usage)) != GMT_NOERROR) bailout (error); /* Give usage if requested */
452
453 /* Parse the command-line arguments */
454
455 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 */
456 if (GMT_Parse_Common (API, THIS_MODULE_OPTIONS, options)) Return (API->error);
457 Ctrl = New_Ctrl (GMT); /* Allocate and initialize a new control structure */
458 if ((error = parse (GMT, Ctrl, options)) != 0) Return (error);
459
460 /*---------------------------- This is the grdvector main code ----------------------------*/
461
462 gmt_M_memset (&last_headpen, 1, struct GMT_PEN); /* Initilaize members to zero */
463 GMT_Report (API, GMT_MSG_INFORMATION, "Processing input grids\n");
464 d_col = d_row = 1;
465 col_0 = row_0 = 0;
466
467 if (!(strcmp (Ctrl->In.file[0], "=") || strcmp (Ctrl->In.file[1], "="))) {
468 GMT_Report (API, GMT_MSG_ERROR, "Piping of grid files not supported!\n");
469 Return (GMT_RUNTIME_ERROR);
470 }
471
472 for (k = 0; k < 2; k++) {
473 if ((Grid[k] = GMT_Read_Data (API, GMT_IS_GRID, GMT_IS_FILE, GMT_IS_SURFACE, GMT_CONTAINER_ONLY, NULL, Ctrl->In.file[k], NULL)) == NULL) { /* Get header only */
474 Return (API->error);
475 }
476 if ((API->error = gmt_img_sanitycheck (GMT, Grid[k]->header))) { /* Used map projection on a Mercator (cartesian) grid */
477 Return (API->error);
478 }
479 gmt_grd_init (GMT, Grid[k]->header, options, true);
480 }
481
482 if (!gmt_grd_domains_match (GMT, Grid[0], Grid[1], "input component")) {

Callers

nothing calls this directly

Calls 15

gmt_get_api_ptrFunction · 0.85
GMT_Create_OptionsFunction · 0.85
gmt_report_usageFunction · 0.85
gmt_init_moduleFunction · 0.85
GMT_Parse_CommonFunction · 0.85
GMT_ReportFunction · 0.85
GMT_Read_DataFunction · 0.85
gmt_img_sanitycheckFunction · 0.85
gmt_grd_initFunction · 0.85
gmt_grd_domains_matchFunction · 0.85
gmt_set_R_from_grdFunction · 0.85
gmt_map_setupFunction · 0.85

Tested by

no test coverage detected