[GRASS-SVN] r67929 - grass/trunk/raster/r.in.lidar
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 23 13:22:40 PST 2016
Author: mmetz
Date: 2016-02-23 13:22:40 -0800 (Tue, 23 Feb 2016)
New Revision: 67929
Modified:
grass/trunk/raster/r.in.lidar/main.c
grass/trunk/raster/r.in.lidar/r.in.lidar.html
Log:
r.in.lidar: bugfix for percent < 100 and other fp precision management errors
Modified: grass/trunk/raster/r.in.lidar/main.c
===================================================================
--- grass/trunk/raster/r.in.lidar/main.c 2016-02-23 21:19:45 UTC (rev 67928)
+++ grass/trunk/raster/r.in.lidar/main.c 2016-02-23 21:22:40 UTC (rev 67929)
@@ -54,7 +54,7 @@
void *raster_row;
struct Cell_head region;
struct Cell_head input_region;
- int rows, cols; /* scan box size */
+ int rows, last_rows, row0, cols; /* scan box size */
int row; /* counters */
int pass, npasses;
@@ -62,7 +62,6 @@
unsigned int counter;
char buff[BUFFSIZE];
double x, y, z;
- double pass_north, pass_south;
int arr_row, arr_col;
unsigned long count, count_total;
int point_class;
@@ -455,7 +454,18 @@
}
Rast_set_output_window(®ion);
- rows = (int)(region.rows * (percent / 100.0));
+ rows = last_rows = region.rows;
+ npasses = 1;
+ if (percent < 100) {
+ rows = (int)(region.rows * (percent / 100.0));
+ npasses = region.rows / rows;
+ last_rows = region.rows - npasses * rows;
+ if (last_rows)
+ npasses++;
+ else
+ last_rows = rows;
+
+ }
cols = region.cols;
G_debug(2, "region.n=%f region.s=%f region.ns_res=%f", region.north,
@@ -463,8 +473,6 @@
G_debug(2, "region.rows=%d [box_rows=%d] region.cols=%d", region.rows,
rows, region.cols);
- npasses = (int)ceil(1.0 * region.rows / rows);
-
/* using row-based chunks (used for output) when input and output
* region matches and using segment library when they don't */
int use_segment = 0;
@@ -528,9 +536,6 @@
count_total = line_total = 0;
- /* init northern border */
- pass_south = region.north;
-
/* main binning loop(s) */
for (pass = 1; pass <= npasses; pass++) {
@@ -538,11 +543,9 @@
G_message(_("Pass #%d (of %d) ..."), pass, npasses);
/* figure out segmentation */
- pass_north = pass_south; /* exact copy to avoid fp errors */
- pass_south = region.north - pass * rows * region.ns_res;
+ row0 = (pass - 1) * rows;
if (pass == npasses) {
- rows = region.rows - (pass - 1) * rows;
- pass_south = region.south; /* exact copy to avoid fp errors */
+ rows = last_rows;
}
if (base_array) {
@@ -552,8 +555,7 @@
}
}
- G_debug(2, "pass=%d/%d pass_n=%f pass_s=%f rows=%d",
- pass, npasses, pass_north, pass_south, rows);
+ G_debug(2, "pass=%d/%d rows=%d", pass, npasses, rows);
point_binning_allocate(&point_binning, rows, cols, rtype);
@@ -602,19 +604,21 @@
if (class_filter_is_out(&class_filter, point_class))
continue;
- if (y <= pass_south || y > pass_north) {
+ if (y <= region.south || y > region.north) {
continue;
}
if (x < region.west || x >= region.east) {
continue;
}
- z = z * zscale;
-
/* find the bin in the current array box */
- arr_row = (int)((pass_north - y) / region.ns_res);
+ arr_row = (int)((region.north - y) / region.ns_res) - row0;
+ if (arr_row < 0 || arr_row >= rows)
+ continue;
arr_col = (int)((x - region.west) / region.ew_res);
+ z = z * zscale;
+
if (base_array) {
double base_z;
if (row_array_get_value_row_col(base_array, arr_row, arr_col,
Modified: grass/trunk/raster/r.in.lidar/r.in.lidar.html
===================================================================
--- grass/trunk/raster/r.in.lidar/r.in.lidar.html 2016-02-23 21:19:45 UTC (rev 67928)
+++ grass/trunk/raster/r.in.lidar/r.in.lidar.html 2016-02-23 21:22:40 UTC (rev 67929)
@@ -275,11 +275,6 @@
<h2>KNOWN ISSUES</h2>
<ul>
-<li> <em>n</em> map <tt>percent=100</tt> and <tt>percent=xx</tt> maps
- differ slightly (point will fall above/below the segmentation line)
- <br>Investigate with "<tt>r.mapcalc diff = bin_n.100 - bin_n.33</tt>" etc.
- <br>Cause unknown.
-
<li> "<tt>nan</tt>" can leak into <em>coeff_var</em> maps.
<br>Cause unknown. Possible work-around: "<tt>r.null setnull=nan</tt>"
<!-- Another method: r.mapcalc 'No_nan = if(map == map, map, null() )' -->
More information about the grass-commit
mailing list