Skip to content

Commit 840b8be

Browse files
authored
Fix signed/unsigned mix for gmt_lat_swap (#4288)
* Fix signed/unsigned mix for gmt_lat_swap The enums were signed but the arg was set to unsigned int, causing problem if anyone set --PROJ_AUX_LATITUDE=none. Also. the verbose report did not handle that case. Fixed. * Update gmt.conf.rst
1 parent 612863b commit 840b8be

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

doc/rst/source/gmt.conf.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ Projection Parameters
784784
**PROJ_AUX_LATITUDE**
785785
Only applies when geodesics are approximated by great circle
786786
distances on an equivalent sphere. Select from authalic, geocentric,
787-
conformal, meridional, parametric, or none [authalic]. When not none
787+
conformal, meridional, parametric, or none (i.e., geodetic) [authalic]. When not none
788788
we convert any latitude used in the great circle calculation to the
789789
chosen auxiliary latitude before doing the distance calculation. See
790790
also :term:`PROJ_MEAN_RADIUS`.

src/gmt_map.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8629,7 +8629,7 @@ double gmtmap_lat_swap_quick (struct GMT_CTRL *GMT, double lat, double c[]) {
86298629
}
86308630

86318631
/*! . */
8632-
double gmt_lat_swap (struct GMT_CTRL *GMT, double lat, unsigned int itype) {
8632+
double gmt_lat_swap (struct GMT_CTRL *GMT, double lat, int itype) {
86338633
/* Return latitude, in degrees, given latitude, in degrees, based on itype */
86348634

86358635
double delta, cos2phi, sin2phi;

src/gmt_prototypes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ EXTERN_MSC bool gmt_near_lines (struct GMT_CTRL *GMT, double lon, double lat, st
565565
EXTERN_MSC bool gmt_near_a_line (struct GMT_CTRL *GMT, double lon, double lat, uint64_t seg, struct GMT_DATASEGMENT *S, unsigned int return_mindist, double *dist_min, double *x_near, double *y_near);
566566
EXTERN_MSC bool gmt_near_a_point (struct GMT_CTRL *GMT, double x, double y, struct GMT_DATATABLE *T, double dist);
567567
EXTERN_MSC double gmt_great_circle_dist_meter (struct GMT_CTRL *GMT, double x0, double y0, double x1, double y1);
568-
EXTERN_MSC double gmt_lat_swap (struct GMT_CTRL *GMT, double lat, unsigned int itype);
568+
EXTERN_MSC double gmt_lat_swap (struct GMT_CTRL *GMT, double lat, int itype);
569569
EXTERN_MSC double gmt_mindist_to_point (struct GMT_CTRL *GMT, double lon, double lat, struct GMT_DATATABLE *T, uint64_t *id);
570570
EXTERN_MSC bool gmt_UTMzone_to_wesn (struct GMT_CTRL *GMT, unsigned int zone_x, char zone_y, int hemi, double wesn[]);
571571
EXTERN_MSC void gmt_ECEF_forward (struct GMT_CTRL *GMT, double in[], double out[]);

src/gmt_stat.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -2750,13 +2750,14 @@ GMT_LOCAL void gmtstat_get_geo_cellarea (struct GMT_CTRL *GMT, struct GMT_GRID *
27502750
* P.Wessel, July 2016.
27512751
*/
27522752
uint64_t node;
2753-
unsigned int row, col, j, first_row = 0, last_row = G->header->n_rows - 1, last_col = G->header->n_columns - 1;
2753+
unsigned int row, col, j, first_row = 0, last_row = G->header->n_rows - 1, last_col = G->header->n_columns - 1, ltype;
27542754
double lat, area, f, row_weight, col_weight = 1.0, R2 = pow (0.001 * GMT->current.proj.mean_radius, 2.0); /* squared mean radius in km */
27552755
char *aux[6] = {"geodetic", "authalic", "conformal", "meridional", "geocentric", "parametric"};
27562756
char *rad[5] = {"mean (R_1)", "authalic (R_2)", "volumetric (R_3)", "meridional", "quadratic"};
27572757

2758+
ltype = (GMT->current.setting.proj_aux_latitude == GMT_LATSWAP_NONE) ? 0 : 1+GMT->current.setting.proj_aux_latitude/2;
27582759
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Compute spherical gridnode areas using %s radius [R = %.12g km] and %s latitudes\n",
2759-
rad[GMT->current.setting.proj_mean_radius], GMT->current.proj.mean_radius, aux[1+GMT->current.setting.proj_aux_latitude/2]);
2760+
rad[GMT->current.setting.proj_mean_radius], GMT->current.proj.mean_radius, aux[ltype]);
27602761
/* May need special treatment of pole points */
27612762
f = (G->header->registration == GMT_GRID_NODE_REG) ? 0.5 : 1.0; /* Half pizza-slice for gridline regs with node at pole, full slice for grids */
27622763
area = R2 * (G->header->inc[GMT_X] * D2R);

0 commit comments

Comments
 (0)