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

Function main

src/testapi_vector_strings.c:11–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#define NROWS 2
10
11int main () {
12 void *API = NULL; /* The API control structure */
13 struct GMT_VECTOR *V = NULL; /* Structure to hold input dataset as vectors */
14 char input[GMT_VF_LEN] = {""}; /* String to hold virtual input filename */
15 char args[128] = {""}; /* String to hold module command arguments */
16
17 uint64_t dim[4] = {NCOLS, NROWS, 1, 0}; /* ncols, nrows, nlayers, type */
18 /* two data points */
19 double x[2] = {5.0, 5.0};
20 double y[2] = {3.0, 8.0};
21 double angle[2] = {30.0, 60.0};
22 char *strings[NROWS] = {"ML 18p,1,blue First label", "MR 32p,2,red Second label"};
23
24 /* Initialize the GMT session */
25 API = GMT_Create_Session ("test", 2U, GMT_SESSION_EXTERNAL, NULL);
26 /* Create a dataset */
27 if ((V = GMT_Create_Data (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_CONTAINER_ONLY, dim, NULL, NULL, 0, 0, NULL)) == NULL) return (EXIT_FAILURE);
28 /* Hook the three vectors up to this container */
29 GMT_Put_Vector(API, V, 0, GMT_DOUBLE, x);
30 GMT_Put_Vector(API, V, 1, GMT_DOUBLE, y);
31 GMT_Put_Vector(API, V, 2, GMT_DOUBLE, angle);
32 /* Hook the user text array up to this container */
33 GMT_Put_Strings(API, GMT_IS_VECTOR, V, strings);
34 /* Associate our data table with a virtual file */
35 GMT_Open_VirtualFile (API, GMT_IS_DATASET|GMT_VIA_VECTOR, GMT_IS_POINT, GMT_IN, V, input);
36 /* Prepare the module arguments */
37 sprintf (args, "%s -JX10c -R0/10/0/10 -Baf -F+a+j+f", input);
38 /* Call the pstext module */
39 GMT_Call_Module (API, "pstext", GMT_MODULE_CMD, args);
40 GMT_Close_VirtualFile (API, input);
41 /* Destroy the GMT session */
42 if (GMT_Destroy_Session (API)) return EXIT_FAILURE;
43};

Callers

nothing calls this directly

Calls 8

GMT_Create_SessionFunction · 0.85
GMT_Create_DataFunction · 0.85
GMT_Put_VectorFunction · 0.85
GMT_Put_StringsFunction · 0.85
GMT_Open_VirtualFileFunction · 0.85
GMT_Call_ModuleFunction · 0.85
GMT_Close_VirtualFileFunction · 0.85
GMT_Destroy_SessionFunction · 0.85

Tested by

no test coverage detected