From 296f227929b2cff8a338541aa3327e5f78ad34b1 Mon Sep 17 00:00:00 2001 From: Dengda98 Date: Wed, 14 May 2025 20:25:30 +0800 Subject: [PATCH] FIX: add conversion between deg and km units of `G.inc` --- src/project.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/project.c b/src/project.c index 82040a77b65..54a97e67b2b 100644 --- a/src/project.c +++ b/src/project.c @@ -844,8 +844,14 @@ EXTERN_MSC int GMT_project (void *V_API, int mode, void *args) { gmt_set_column_type (GMT, GMT_OUT, GMT_X, (Ctrl->N.active) ? GMT_IS_FLOAT : GMT_IS_LON); gmt_set_column_type (GMT, GMT_OUT, GMT_Y, (Ctrl->N.active) ? GMT_IS_FLOAT : GMT_IS_LAT); gmt_set_column_type (GMT, GMT_OUT, GMT_Z, GMT_IS_FLOAT); - if (Ctrl->Q.active && Ctrl->G.unit != 'k' && !Ctrl->G.number) - Ctrl->G.inc *= 0.001 / GMT->current.map.dist[GMT_MAP_DIST].scale; /* Now in km */ + if (Ctrl->Q.active && Ctrl->G.unit != 'k' && !Ctrl->G.number){ + if (GMT->current.map.dist[GMT_MAP_DIST].arc) { + Ctrl->G.inc *= (GMT->current.proj.KM_PR_DEG / GMT->current.map.dist[GMT_MAP_DIST].scale); /* Now in km */ + } + else { + Ctrl->G.inc /= METERS_IN_A_KM * GMT->current.map.dist[GMT_MAP_DIST].scale; /* Now in km */ + } + } } else if (!Ctrl->N.active) { /* Decode and set the various output column types in the geographic case */ for (col = 0; col < P.n_outputs; col++) {