Skip to content

Commit cd47fef

Browse files
authored
FIX: add conversion between deg and km units of G.inc (#8727)
1 parent 640f1e6 commit cd47fef

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/project.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,14 @@ EXTERN_MSC int GMT_project (void *V_API, int mode, void *args) {
844844
gmt_set_column_type (GMT, GMT_OUT, GMT_X, (Ctrl->N.active) ? GMT_IS_FLOAT : GMT_IS_LON);
845845
gmt_set_column_type (GMT, GMT_OUT, GMT_Y, (Ctrl->N.active) ? GMT_IS_FLOAT : GMT_IS_LAT);
846846
gmt_set_column_type (GMT, GMT_OUT, GMT_Z, GMT_IS_FLOAT);
847-
if (Ctrl->Q.active && Ctrl->G.unit != 'k' && !Ctrl->G.number)
848-
Ctrl->G.inc *= 0.001 / GMT->current.map.dist[GMT_MAP_DIST].scale; /* Now in km */
847+
if (Ctrl->Q.active && Ctrl->G.unit != 'k' && !Ctrl->G.number){
848+
if (GMT->current.map.dist[GMT_MAP_DIST].arc) {
849+
Ctrl->G.inc *= (GMT->current.proj.KM_PR_DEG / GMT->current.map.dist[GMT_MAP_DIST].scale); /* Now in km */
850+
}
851+
else {
852+
Ctrl->G.inc /= METERS_IN_A_KM * GMT->current.map.dist[GMT_MAP_DIST].scale; /* Now in km */
853+
}
854+
}
849855
}
850856
else if (!Ctrl->N.active) { /* Decode and set the various output column types in the geographic case */
851857
for (col = 0; col < P.n_outputs; col++) {

0 commit comments

Comments
 (0)