Skip to content

Commit

Permalink
Fix error in indexing for matrix-to-grid input (#8554)
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman authored Jul 25, 2024
1 parent 425334f commit 24984c1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/gmt_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -5522,6 +5522,10 @@ GMT_LOCAL struct GMT_GRID *gmtapi_import_grid (struct GMTAPI_CTRL *API, int obje
else if (S_obj->wesn[XHI] < G_obj->header->wesn[XLO]) { /* Must first wrap G_obj->header->wesn east to fit the data */
G_obj->header->wesn[XLO] -= 360.0; G_obj->header->wesn[XHI] -= 360.0;
}
if (S_obj->wesn[XLO] < G_obj->header->wesn[XLO]) {
/* Must wrap G_obj->header.wesn so the left bound in S_obj is smaller larger than that in G_obj, otherwise i0 is negative (but it's defined as unsigned int */
G_obj->header->wesn[XLO] -= 360.0; G_obj->header->wesn[XHI] -= 360.0;
}
}
j1 = (unsigned int)gmt_M_grd_y_to_row (GMT, S_obj->wesn[YLO]+dy, G_obj->header);
j0 = (unsigned int)gmt_M_grd_y_to_row (GMT, S_obj->wesn[YHI]-dy, G_obj->header);
Expand Down Expand Up @@ -6341,7 +6345,11 @@ GMT_LOCAL struct GMT_CUBE * gmtapi_import_cube (struct GMTAPI_CTRL *API, int obj
if (S_obj->wesn[XLO] > U_obj->header->wesn[XHI]) { /* Must first wrap U_obj->header->wesn west to fit the data */
U_obj->header->wesn[XLO] += 360.0; U_obj->header->wesn[XHI] += 360.0;
}
else if (S_obj->wesn[XHI] < U_obj->header->wesn[XLO]) { /* Must first wrap G_obj->header->wesn east to fit the data */
else if (S_obj->wesn[XHI] < U_obj->header->wesn[XLO]) { /* Must first wrap U_obj->header->wesn east to fit the data */
U_obj->header->wesn[XLO] -= 360.0; U_obj->header->wesn[XHI] -= 360.0;
}
if (S_obj->wesn[XLO] < U_obj->header->wesn[XLO]) {
/* Must wrap U_obj->header.wesn so the left bound in S_obj is smaller larger than that in U_obj, otherwise i0 is negative (but it's defined as unsigned int */
U_obj->header->wesn[XLO] -= 360.0; U_obj->header->wesn[XHI] -= 360.0;
}
}
Expand Down

0 comments on commit 24984c1

Please sign in to comment.