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

Function main

src/testapi_vector_strings2.c:13–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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