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

Function gmt_parse_interpolant

src/gmt_support.c:1681–1721  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1679}
1680
1681unsigned gmt_parse_interpolant (struct GMTAPI_CTRL *API, char *arg, unsigned int *mode, unsigned int *type, double *fit) {
1682 /* Do the parsing of the -F interpolant option using in sample1d and grdinterpolate */
1683 unsigned int n_errors = 0;
1684
1685 *type = *mode = 0; *fit = 0.0;
1686 switch (arg[0]) {
1687 case 'l':
1688 *mode = GMT_SPLINE_LINEAR;
1689 break;
1690 case 'a':
1691 *mode = GMT_SPLINE_AKIMA;
1692 break;
1693 case 'c':
1694 *mode = GMT_SPLINE_CUBIC;
1695 break;
1696 case 'n':
1697 *mode = GMT_SPLINE_NN;
1698 break;
1699 case 'e':
1700 *mode = GMT_SPLINE_STEP;
1701 break;
1702 case 's':
1703 *mode = GMT_SPLINE_SMOOTH;
1704 if (arg[1])
1705 *fit = atof (&arg[1]);
1706 else {
1707 GMT_Report (API, GMT_MSG_ERROR, "Option -Fs: No fit parameter given\n");
1708 n_errors++;
1709 }
1710 break;
1711 default:
1712 GMT_Report (API, GMT_MSG_ERROR, "Option -F: Bad interpolant selector %c\n", arg[0]);
1713 n_errors++;
1714 break;
1715 }
1716 if (strstr (&arg[1], "+d1")) *type = 1; /* Want first derivative */
1717 else if (strstr (&arg[1], "+d2")) *type = 2; /* Want second derivative */
1718 else if (strstr (&arg[1], "+1")) *type = 1; /* Want first derivative (backwards compatibility) */
1719 else if (strstr (&arg[1], "+2")) *type = 2; /* Want second derivative (backwards compatibility) */
1720 return (n_errors);
1721}
1722
1723void gmt_explain_interpolate_mode (struct GMTAPI_CTRL *API) {
1724 /* Display usage synopsis for -F interpolant option */

Callers 2

parseFunction · 0.85
parseFunction · 0.85

Calls 1

GMT_ReportFunction · 0.85

Tested by

no test coverage detected