|
| 1 | +#include "gmt_dev.h" |
| 2 | + |
| 3 | +/* Testing the passing of a matrix to grdimage for global projection |
| 4 | + * when the central meridian changes. This currently fails as in |
| 5 | + * https://github.com/GenericMappingTools/pygmt/issues/515#issue-655281714 |
| 6 | + */ |
| 7 | + |
| 8 | +int main () { |
| 9 | + unsigned int mode = GMT_SESSION_EXTERNAL; |
| 10 | + struct GMT_MATRIX *M = NULL; |
| 11 | + char input[GMT_VF_LEN], args[256] = {""}; |
| 12 | + struct GMTAPI_CTRL *API = NULL; |
| 13 | + |
| 14 | + API = GMT_Create_Session ("test", 2U, mode, NULL); |
| 15 | + |
| 16 | + /* Read in earth_relief_01d as a matrix from text file and set correct region, inc, registartion */ |
| 17 | + M = GMT_Read_Data (API, GMT_IS_MATRIX, GMT_IS_FILE, GMT_IS_SURFACE, GMT_READ_NORMAL, NULL, "@earth_relief_01d.txt", NULL); |
| 18 | + M->range[0] = -180; M->range[1] = 180; M->range[2] = -90; M->range[3] = 90.0; |
| 19 | + M->inc[0] = M->inc[1] = 1.0; |
| 20 | + M->registration = 1; |
| 21 | + /* Create a virtual file to pass as a grid */ |
| 22 | + GMT_Open_VirtualFile (API, GMT_IS_GRID|GMT_VIA_MATRIX, GMT_IS_SURFACE, GMT_IN|GMT_IS_REFERENCE, M, input); |
| 23 | + /* Call grdimage with central longitude 0, which is the center of the grid */ |
| 24 | + sprintf (args, "%s -Rg -JH0/6i -Bg30 -K -Cgeo -P", input); |
| 25 | + GMT_Call_Module (API, "grdimage", GMT_MODULE_CMD, args); |
| 26 | + GMT_Init_VirtualFile (API, 0, input); |
| 27 | + /* Call grdimage with central longitude 180 which means grid needs to be rotated 180 */ |
| 28 | + sprintf (args, "%s -R -JH180/6i -Bg30 -O -Cgeo -Y3.5i", input); |
| 29 | + GMT_Call_Module (API, "grdimage", GMT_MODULE_CMD, args); |
| 30 | + GMT_Close_VirtualFile (API, input); |
| 31 | + |
| 32 | + if (GMT_Destroy_Session (API)) return EXIT_FAILURE; |
| 33 | + exit (0); |
| 34 | +} |
0 commit comments