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

Function main

src/testapi_vector.c:6–41  ·  view source on GitHub ↗

* Testing a specific case where we wish to pass and receive a GMT_VECTOR or GMT_MATRIX * to/from a module that expect to read/write GMT_DATASETs. */

Source from the content-addressed store, hash-verified

4 * to/from a module that expect to read/write GMT_DATASETs.
5 */
6int main () {
7 void *API = NULL; /* The API control structure */
8 struct GMT_VECTOR *V[2] = {NULL, NULL}; /* Structure to hold input/output dataset as vectors */
9 char input[GMT_VF_LEN] = {""}; /* String to hold virtual input filename */
10 char output[GMT_VF_LEN] = {""}; /* String to hold virtual output filename */
11 char args[128] = {""}; /* String to hold module command arguments */
12
13 /* Initialize the GMT session */
14 API = GMT_Create_Session ("test", 2U, GMT_SESSION_EXTERNAL, NULL);
15 /* FIRST TEST GMT_VECTOR */
16 /* Read in our data table to memory */
17 V[GMT_IN] = GMT_Read_Data (API, GMT_IS_VECTOR, GMT_IS_FILE, GMT_IS_PLP, GMT_READ_NORMAL, NULL, "belgium.txt", NULL);
18 /* Associate our data table with a virtual file */
19 GMT_Open_VirtualFile (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_PLP, GMT_IN, V[GMT_IN], input);
20 /* Create a virtual file to hold the sampled points */
21 GMT_Open_VirtualFile (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_PLP, GMT_OUT|GMT_IS_REFERENCE, NULL, output);
22 /* Prepare the module arguments */
23 sprintf (args, "-sa %s -Gtopo.nc ->%s", input, output);
24 /* Call the grdtrack module */
25 GMT_Call_Module (API, "grdtrack", GMT_MODULE_CMD, args);
26 /* Obtain the data from the virtual file */
27 V[GMT_OUT] = GMT_Read_VirtualFile (API, output);
28 /* Close the virtual files */
29 GMT_Close_VirtualFile (API, input);
30 GMT_Close_VirtualFile (API, output);
31 /* Associate our sampled table with a virtual file */
32 GMT_Open_VirtualFile (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_PLP, GMT_IN, V[GMT_OUT], input);
33 /* Prepare the module arguments */
34 sprintf (args, "-R3/9/50/54 -JM6i -P -Baf -W0.5p %s ->apivec.ps", input);
35 /* Call the psxy module */
36 GMT_Call_Module (API, "psxy", GMT_MODULE_CMD, args);
37 /* Close the virtual files */
38 GMT_Close_VirtualFile (API, input);
39 /* Destroy the GMT session */
40 if (GMT_Destroy_Session (API)) return EXIT_FAILURE;
41};

Callers

nothing calls this directly

Calls 7

GMT_Create_SessionFunction · 0.85
GMT_Read_DataFunction · 0.85
GMT_Open_VirtualFileFunction · 0.85
GMT_Call_ModuleFunction · 0.85
GMT_Read_VirtualFileFunction · 0.85
GMT_Close_VirtualFileFunction · 0.85
GMT_Destroy_SessionFunction · 0.85

Tested by

no test coverage detected