Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gmtlogo: Create the gmt_letters array dynamically to avoid MSVC compiler error #8629

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/gmt_notposix.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@

#ifndef NAN
# ifdef _MSC_VER
static const double _NAN = (-(float)(((float)(1e+300 * 1e+300)) * 0.0F));
# define NAN _NAN
# include <ymath.h>
# define NAN _Nan._Double
# else /* _MSC_VER */
static const double _NAN = (HUGE_VAL-HUGE_VAL);
# define NAN _NAN
Expand Down
35 changes: 29 additions & 6 deletions src/gmtlogo.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
#define THIS_MODULE_NEEDS "jr"
#define THIS_MODULE_OPTIONS "->KJOPRUVXYtxy" GMT_OPT("c")

#define GMT_N_LETTERS 116
static float gmt_letters[GMT_N_LETTERS][2] = { /* The G, M, T polygons */
{ NAN, NAN },

#define GMT_N_LETTERS_G 92
#define GMT_N_LETTERS_M 13
#define GMT_N_LETTERS_T 8
#define GMT_N_LETTERS (GMT_N_LETTERS_G + GMT_N_LETTERS_M + GMT_N_LETTERS_T + 3)

static float gmt_letters_g[GMT_N_LETTERS_G][2] = { /* The G polygons */
{ -59.5, -41.8 },
{ -59.5, 2.2 },
{ -105, 2.2 },
Expand Down Expand Up @@ -128,7 +132,8 @@ static float gmt_letters[GMT_N_LETTERS][2] = { /* The G, M, T polygons */
{ -72.7, -32 },
{ -71.96, -30.8 },
{ -68.04, -41.8 },
{ NAN, NAN },
};
static float gmt_letters_m[GMT_N_LETTERS_M][2] = { /* The M polygons */
{ -37.8, -41.8 },
{ -23.8, -41.8 },
{ -23.8, 27.39 },
Expand All @@ -142,7 +147,8 @@ static float gmt_letters[GMT_N_LETTERS][2] = { /* The G, M, T polygons */
{ 12.46, -29.7 },
{ -17.22, 40.48 },
{ -37.8, 40.48 },
{ NAN, NAN },
};
static float gmt_letters_t[GMT_N_LETTERS_T][2] = { /* The T polygons */
{ 124.46, -41.8 },
{ 124.46, 30.47 },
{ 160.02, 30.47 },
Expand Down Expand Up @@ -329,12 +335,13 @@ static int parse (struct GMT_CTRL *GMT, struct GMTLOGO_CTRL *Ctrl, struct GMT_OP

EXTERN_MSC int GMT_gmtlogo (void *V_API, int mode, void *args) {
/* High-level function that implements the gmtlogo task */
int error, fmode;
int error, fmode, idx = 0;

uint64_t par[4] = {0, 0, 0, 0};

double wesn[4] = {0.0, 0.0, 0.0, 0.0}; /* Dimensions in inches */
double scale, y, dim[2];
float gmt_letters[GMT_N_LETTERS][2];

char cmd[GMT_LEN256] = {""}, pars[GMT_LEN128] = {""}, file[GMT_VF_LEN] = {""};

Expand Down Expand Up @@ -439,6 +446,22 @@ EXTERN_MSC int GMT_gmtlogo (void *V_API, int mode, void *args) {

/* Plot the GMT letters as shadows, then full size, using GMT_psxy */

/* Copy the polygons into the gmt_letters array, with NAN records as segment separators */
gmt_letters[idx][0] = NAN;
gmt_letters[idx][1] = NAN;
idx += 1;
memcpy(gmt_letters + idx, gmt_letters_g, sizeof(gmt_letters_g));
idx += GMT_N_LETTERS_G;
gmt_letters[idx][0] = NAN;
gmt_letters[idx][1] = NAN;
idx += 1;
memcpy(gmt_letters + idx, gmt_letters_m, sizeof(gmt_letters_m));
idx += GMT_N_LETTERS_M;
gmt_letters[idx][0] = NAN;
gmt_letters[idx][1] = NAN;
idx += 1;
memcpy(gmt_letters + idx, gmt_letters_t, sizeof(gmt_letters_t));

/* Allocate a matrix container for holding the GMT-matrix coordinates */
par[0] = 2; par[1] = GMT_N_LETTERS;
if ((M = GMT_Create_Data (API, GMT_IS_DATASET|GMT_VIA_MATRIX, GMT_IS_POLY, GMT_CONTAINER_ONLY, par, NULL, NULL, 0, GMT_IS_ROW_FORMAT, NULL)) == NULL)
Expand Down
Loading