[GRASS-SVN] r67938 - grass/branches/releasebranch_7_0/raster/r.in.lidar
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Feb 24 05:28:50 PST 2016
Author: mmetz
Date: 2016-02-24 05:28:49 -0800 (Wed, 24 Feb 2016)
New Revision: 67938
Modified:
grass/branches/releasebranch_7_0/raster/r.in.lidar/main.c
grass/branches/releasebranch_7_0/raster/r.in.lidar/r.in.lidar.html
Log:
r.in.lidar: fix scan box calculation for percent < 100
Modified: grass/branches/releasebranch_7_0/raster/r.in.lidar/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.in.lidar/main.c 2016-02-24 13:28:01 UTC (rev 67937)
+++ grass/branches/releasebranch_7_0/raster/r.in.lidar/main.c 2016-02-24 13:28:49 UTC (rev 67938)
@@ -114,7 +114,7 @@
*index_array;
void *raster_row, *ptr;
struct Cell_head region;
- int rows, cols; /* scan box size */
+ int rows, last_rows, row0, cols; /* scan box size */
int row, col; /* counters */
int pass, npasses;
@@ -122,7 +122,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 skipme, i;
@@ -629,7 +628,17 @@
}
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,
@@ -637,8 +646,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);
-
if (!scan_flag->answer) {
/* check if rows * (cols + 1) go into a size_t */
if (sizeof(size_t) < 8) {
@@ -694,9 +701,6 @@
count_total = line_total = 0;
- /* init northern border */
- pass_south = region.north;
-
/* main binning loop(s) */
for (pass = 1; pass <= npasses; pass++) {
LASError LAS_error;
@@ -710,17 +714,13 @@
G_fatal_error(_("Could not rewind input file"));
/* 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;
}
- 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);
-
if (bin_n) {
G_debug(2, "allocating n_array");
n_array = G_calloc((size_t)rows * (cols + 1), Rast_cell_size(CELL_TYPE));
@@ -821,13 +821,22 @@
}
}
- if (y <= pass_south || y > pass_north) {
+ if (y <= region.south || y > region.north) {
continue;
}
if (x < region.west || x >= region.east) {
continue;
}
+ /* find the bin in the current array box */
+ 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);
+
+ /* G_debug(5, "arr_row: %d arr_col: %d", arr_row, arr_col); */
+
z = z * zscale;
if (zrange_opt->answer) {
@@ -839,10 +848,6 @@
count++;
/* G_debug(5, "x: %f, y: %f, z: %f", x, y, z); */
- /* find the bin in the current array box */
- arr_row = (int)((pass_north - y) / region.ns_res);
- arr_col = (int)((x - region.west) / region.ew_res);
-
if (bin_n)
update_n(n_array, cols, arr_row, arr_col);
if (bin_min)
Modified: grass/branches/releasebranch_7_0/raster/r.in.lidar/r.in.lidar.html
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.in.lidar/r.in.lidar.html 2016-02-24 13:28:01 UTC (rev 67937)
+++ grass/branches/releasebranch_7_0/raster/r.in.lidar/r.in.lidar.html 2016-02-24 13:28:49 UTC (rev 67938)
@@ -260,11 +260,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