From 6d786782d455d41ce1a80a462dfc90feda3329ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 18:19:44 +0000 Subject: [PATCH 1/3] Initial plan From fab4621078dfaac3aca5ff7c773266931093e81e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 18:23:15 +0000 Subject: [PATCH 2/3] Fix invalid map step handling in path sampling --- src/gmt_map.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gmt_map.c b/src/gmt_map.c index 373c46c9980..defae750fea 100644 --- a/src/gmt_map.c +++ b/src/gmt_map.c @@ -8011,6 +8011,14 @@ uint64_t gmtlib_lonpath (struct GMT_CTRL *GMT, double lon, double lat1, double l /* Must do general case */ n = 0; min_gap = 0.1 * GMT->current.setting.map_line_step; + if (!isfinite (GMT->current.map.dlat) || GMT->current.map.dlat <= 0.0) { /* Guard against invalid sampling step (e.g., antipodal singularities) */ + gmt_M_malloc2 (GMT, tlon, tlat, 2U, NULL, double); + tlon[0] = tlon[1] = lon; + tlat[0] = lat1; tlat[1] = lat2; + *x = tlon; + *y = tlat; + return (2ULL); + } if ((n_alloc = lrint (ceil (fabs (lat2 - lat1) / GMT->current.map.dlat))) == 0) return (0); n_alloc++; /* So n_alloc is at least 2 */ @@ -8108,6 +8116,13 @@ uint64_t gmtlib_latpath (struct GMT_CTRL *GMT, double lat, double lon1, double l } /* Here we try to walk along lat for small increment in longitude to make sure our steps are smaller than the line_step */ min_gap = 0.1 * GMT->current.setting.map_line_step; + if (!isfinite (GMT->current.map.dlon) || GMT->current.map.dlon <= 0.0) { /* Guard against invalid sampling step (e.g., antipodal singularities) */ + gmt_M_malloc2 (GMT, tlon, tlat, 2U, NULL, double); + tlat[0] = tlat[1] = lat; + tlon[0] = lon1; tlon[1] = lon2; + *x = tlon; *y = tlat; + return (2ULL); + } if ((n_alloc = lrint (ceil (fabs (lon2 - lon1) / GMT->current.map.dlon))) == 0) return (0); /* Initial guess to path length */ n_alloc++; /* n_alloc is at least 2 */ From 9228a4f3ddcb8d794f86f6ecc644e1960cc275b2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 18:24:03 +0000 Subject: [PATCH 3/3] Polish fallback path assignments for readability --- src/gmt_map.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gmt_map.c b/src/gmt_map.c index defae750fea..4fbcc82df10 100644 --- a/src/gmt_map.c +++ b/src/gmt_map.c @@ -8014,7 +8014,8 @@ uint64_t gmtlib_lonpath (struct GMT_CTRL *GMT, double lon, double lat1, double l if (!isfinite (GMT->current.map.dlat) || GMT->current.map.dlat <= 0.0) { /* Guard against invalid sampling step (e.g., antipodal singularities) */ gmt_M_malloc2 (GMT, tlon, tlat, 2U, NULL, double); tlon[0] = tlon[1] = lon; - tlat[0] = lat1; tlat[1] = lat2; + tlat[0] = lat1; + tlat[1] = lat2; *x = tlon; *y = tlat; return (2ULL); @@ -8119,8 +8120,10 @@ uint64_t gmtlib_latpath (struct GMT_CTRL *GMT, double lat, double lon1, double l if (!isfinite (GMT->current.map.dlon) || GMT->current.map.dlon <= 0.0) { /* Guard against invalid sampling step (e.g., antipodal singularities) */ gmt_M_malloc2 (GMT, tlon, tlat, 2U, NULL, double); tlat[0] = tlat[1] = lat; - tlon[0] = lon1; tlon[1] = lon2; - *x = tlon; *y = tlat; + tlon[0] = lon1; + tlon[1] = lon2; + *x = tlon; + *y = tlat; return (2ULL); } if ((n_alloc = lrint (ceil (fabs (lon2 - lon1) / GMT->current.map.dlon))) == 0) return (0); /* Initial guess to path length */