Skip to content

Commit

Permalink
update the desciption of compute_viewshed
Browse files Browse the repository at this point in the history
  • Loading branch information
billbillbilly committed Feb 7, 2024
1 parent 544bb31 commit 294ce68
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/compute_viewshed.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param offset_height numeric, setting the height of positions that a given
#' viewpoint will look at. (defaut is 0)
#' @param r Numeric (optional), setting the radius for viewshed analysis.
#' (it is defaulted as NULL)
#' (The default is 1000m/3281ft)
#' @param parallel Logical, (default is FALSE) indicating if parallel computing
#' should be used to compute viewsheds of multiview points. When it is TRUE,
#' arguements 'raster' and 'plot' are ignored
Expand Down
2 changes: 1 addition & 1 deletion man/compute_viewshed.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/viewscape.so
Binary file not shown.
9 changes: 5 additions & 4 deletions src/visibleLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ Rcpp::IntegerMatrix visibleLabel(
const double h,
const int max_dis) {

Rcpp::NumericVector zl;
Rcpp::NumericVector xl;
Rcpp::NumericVector yl;
// Rcpp::NumericVector zl;
// Rcpp::NumericVector xl;
// Rcpp::NumericVector yl;
const int rows = dsm.rows();
const int cols = dsm.cols();
int steps;
Rcpp::IntegerMatrix visible(rows, cols);
Rcpp::NumericVector sequence(max_dis), xl(max_dis), yl(max_dis), zl(max_dis);

for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
steps = sqrt((viewpoint[0]-j)*(viewpoint[0]-j) + (viewpoint[1]-i)*(viewpoint[1]-i));
const double z = dsm(i,j) + h;
if (steps <= max_dis) {
Rcpp::NumericVector sequence(steps);
// Rcpp::NumericVector sequence(steps);
std::iota(sequence.begin(), sequence.end(), 1);
xl = viewpoint[0] + sequence * (j-viewpoint[0])/steps;
yl = viewpoint[1] + sequence * (i-viewpoint[1])/steps;
Expand Down
Binary file modified src/visibleLabel.o
Binary file not shown.

0 comments on commit 294ce68

Please sign in to comment.