Skip to content

Commit f9c5cf0

Browse files
netelerlbartoletti
authored andcommitted
revert C related INFINITY/NAN changes (this is taken care of in OSGeo#2681)
1 parent 43daba2 commit f9c5cf0

File tree

18 files changed

+50
-52
lines changed

18 files changed

+50
-52
lines changed

general/g.region/printwindow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void print_window(struct Cell_head *window, int print_flag, int flat_flag)
469469
double convergence;
470470

471471
if (G_projection() == PROJECTION_XY)
472-
convergence = INFINITY;
472+
convergence = 0. / 0.;
473473
else if (G_projection() == PROJECTION_LL)
474474
convergence = 0.0;
475475
else {

lib/btree2/kdtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ int kdtree_knn(struct kdtree *t, double *c, int *uid, double *d, int k,
531531
if (skip)
532532
sn.uid = *skip;
533533

534-
maxdist = INFINITY;
534+
maxdist = 1.0 / 0.0;
535535
found = 0;
536536

537537
/* go down */

lib/raster3d/mask.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ void Rast3d_mask_tile(RASTER3D_Map *map, int tileIndex, void *tile, int type)
304304
for (dy = y; dy < rows; dy++) {
305305
for (dx = x; dx < cols; dx++) {
306306
RASTER3D_MASKNUM(map, dx, dy, dz, tile, type);
307-
tile = (int*)tile + length;
307+
tile += length;
308308
}
309309

310-
tile = (int*) + xLength;
310+
tile += xLength;
311311
}
312-
tile = (int*) + yLength;
312+
tile += yLength;
313313
}
314314
}
315315

lib/vector/Vlib/box.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ int Vect_get_line_box(const struct Map_info *Map, int line,
248248

249249
Line = Plus->Line[line];
250250
if (Line == NULL) { /* dead */
251-
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY;
251+
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.;
252252
return 0;
253253
}
254254

@@ -313,7 +313,7 @@ int Vect_get_area_box(const struct Map_info *Map, int area,
313313
Area = Plus->Area[area];
314314

315315
if (Area == NULL) { /* dead */
316-
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY;
316+
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.;
317317
return 0;
318318
}
319319

@@ -360,7 +360,7 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle,
360360
Isle = Plus->Isle[isle];
361361

362362
if (Isle == NULL) { /* dead */
363-
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY;
363+
Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.;
364364
return 0;
365365
}
366366

raster/r.horizon/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ double horizon_height(void)
746746
{
747747
double height;
748748

749-
tanh0 = -INFINITY;
749+
tanh0 = -1.0 / 0.0; /* -inf */
750750
length = 0;
751751

752752
height = searching();

raster/r.in.bin/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
255255
const char *outpre;
256256
char output[GNAME_MAX];
257257
const char *title;
258-
double null_val = INFINITY;
258+
double null_val = 0.0 / 0.0;
259259
int is_fp;
260260
int is_signed;
261261
int bytes, hbytes;

raster/r.in.lidar/info.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
*/
1313

1414
#include <string.h>
15-
#include <math.h> /* For INIFINITY */
1615

1716
#include <grass/glocale.h>
1817
#include <liblas/capi/liblas.h>
@@ -98,7 +97,7 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, int update,
9897
first = TRUE;
9998

10099
/* init to nan in case no points are found */
101-
min_x = max_x = min_y = max_y = min_z = max_z = INFINITY;
100+
min_x = max_x = min_y = max_y = min_z = max_z = 0.0 / 0.0;
102101

103102
G_verbose_message(_("Scanning data ..."));
104103

raster/r.in.lidar/point_binning.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void write_median(struct BinIndex *bin_index, void *raster_row,
434434
Rast_set_null_value(ptr, 1, rtype);
435435
else { /* one or more points in cell */
436436

437-
head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE);
437+
head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE);
438438
node_id = head_id;
439439

440440
n = 0;
@@ -493,7 +493,7 @@ void write_percentile(struct BinIndex *bin_index, void *raster_row,
493493
CELL_TYPE)) /* no points in cell */
494494
Rast_set_null_value(ptr, 1, rtype);
495495
else {
496-
head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE);
496+
head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE);
497497
node_id = head_id;
498498
n = 0;
499499

@@ -548,7 +548,7 @@ void write_skewness(struct BinIndex *bin_index, void *raster_row,
548548
CELL_TYPE)) /* no points in cell */
549549
Rast_set_null_value(ptr, 1, rtype);
550550
else {
551-
head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE);
551+
head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE);
552552
node_id = head_id;
553553

554554
n = 0; /* count */
@@ -605,7 +605,7 @@ void write_trimmean(struct BinIndex *bin_index, void *raster_row,
605605
CELL_TYPE)) /* no points in cell */
606606
Rast_set_null_value(ptr, 1, rtype);
607607
else {
608-
head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE);
608+
head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE);
609609

610610
node_id = head_id;
611611
n = 0;
@@ -697,9 +697,9 @@ void write_values(struct PointBinning *point_binning,
697697
for (col = 0; col < cols; col++) {
698698
size_t offset = ((size_t)row * cols + col) * Rast_cell_size(rtype);
699699
double min =
700-
Rast_get_d_value((DCELL*)point_binning->min_array + offset, rtype);
700+
Rast_get_d_value(point_binning->min_array + offset, rtype);
701701
double max =
702-
Rast_get_d_value((DCELL*)point_binning->max_array + offset, rtype);
702+
Rast_get_d_value(point_binning->max_array + offset, rtype);
703703
Rast_set_d_value(ptr, max - min, rtype);
704704
ptr = G_incr_void_ptr(ptr, Rast_cell_size(rtype));
705705
}
@@ -714,7 +714,7 @@ void write_values(struct PointBinning *point_binning,
714714
int n =
715715
Rast_get_c_value(point_binning->n_array + n_offset, CELL_TYPE);
716716
double sum =
717-
Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype);
717+
Rast_get_d_value(point_binning->sum_array + offset, rtype);
718718

719719
if (n == 0)
720720
Rast_set_null_value(ptr, 1, rtype);
@@ -765,12 +765,12 @@ void write_values(struct PointBinning *point_binning,
765765
continue;
766766

767767
double sum_x =
768-
Rast_get_d_value((DCELL*)point_binning->x_array + offset, rtype);
768+
Rast_get_d_value(point_binning->x_array + offset, rtype);
769769
double sum_y =
770-
Rast_get_d_value((DCELL*)point_binning->y_array + offset, rtype);
770+
Rast_get_d_value(point_binning->y_array + offset, rtype);
771771
/* TODO: we do this also in mean writing */
772772
double sum_z =
773-
Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype);
773+
Rast_get_d_value(point_binning->sum_array + offset, rtype);
774774

775775
/* We are not writing any categories. They are not needed
776776
* and potentially it is too much trouble to do it and it is

raster/r.li/r.li.padrange/padrange.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,8 @@ int calculate(int fd, struct area_entry *ad, double *result)
309309
(((NS_DIST1 + NS_DIST2) / 2) / hd.rows);
310310

311311
/* get min and max patch size */
312-
min = INFINITY;
313-
max = -INFINITY;
312+
min = 1.0 / 0.0; /* inf */
313+
max = -1.0 / 0.0; /* -inf */
314314
for (old_pid = 1; old_pid <= pid; old_pid++) {
315315
if (pst[old_pid].count > 0) {
316316
area_p = cell_size_m * pst[old_pid].count / 10000;
@@ -543,8 +543,8 @@ int calculateD(int fd, struct area_entry *ad, double *result)
543543
(((NS_DIST1 + NS_DIST2) / 2) / hd.rows);
544544

545545
/* get min and max patch size */
546-
min = INFINITY;
547-
max = -INFINITY;
546+
min = 1.0 / 0.0; /* inf */
547+
max = -1.0 / 0.0; /* -inf */
548548
for (old_pid = 1; old_pid <= pid; old_pid++) {
549549
if (pst[old_pid].count > 0) {
550550
area_p = cell_size_m * pst[old_pid].count / 10000;
@@ -777,8 +777,8 @@ int calculateF(int fd, struct area_entry *ad, double *result)
777777
(((NS_DIST1 + NS_DIST2) / 2) / hd.rows);
778778

779779
/* get min and max patch size */
780-
min = INFINITY;
781-
max = -INFINITY;
780+
min = 1.0 / 0.0; /* inf */
781+
max = -1.0 / 0.0; /* -inf */
782782
for (old_pid = 1; old_pid <= pid; old_pid++) {
783783
if (pst[old_pid].count > 0) {
784784
area_p = cell_size_m * pst[old_pid].count / 10000;

raster/r.out.gdal/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,11 +1047,11 @@ double set_default_nodata_value(GDALDataType datatype, double min, double max)
10471047

10481048
case GDT_Float32:
10491049
case GDT_CFloat32:
1050-
return INFINITY;
1050+
return 0.0 / 0.0;
10511051

10521052
case GDT_Float64:
10531053
case GDT_CFloat64:
1054-
return INFINITY;
1054+
return 0.0 / 0.0;
10551055

10561056
default:
10571057
return 0;

0 commit comments

Comments
 (0)