diff --git a/R/RcppExports.R b/R/RcppExports.R index 3bd7c04..95a5a94 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -5,10 +5,6 @@ get_depths <- function(px, py, x, y, num) { .Call('_viewscape_get_depths', PACKAGE = 'viewscape', px, py, x, y, num) } -multiLabel <- function(vpts, dsm, max_dis, vpth, h) { - .Call('_viewscape_multiLabel', PACKAGE = 'viewscape', vpts, dsm, max_dis, vpth, h) -} - visibleLabel <- function(viewpoint, dsm, h, max_dis) { .Call('_viewscape_visibleLabel', PACKAGE = 'viewscape', viewpoint, dsm, h, max_dis) } diff --git a/R/compute_viewshed.R b/R/compute_viewshed.R index 8466d5f..88b0ed9 100644 --- a/R/compute_viewshed.R +++ b/R/compute_viewshed.R @@ -144,10 +144,6 @@ compute_viewshed <- function(dsm, # inputs <- split(viewpoints,seq(nrow(viewpoints))) if (isTRUE(Sys.info()[1]=="Windows") == TRUE){ workers = 1 - # viewsheds <- radius_viewshed_m(dsm=dsm, - # r=r, - # viewPts=viewpoints, - # offset=offset_viewpoint) } suppressWarnings( viewsheds <- paral_nix(X = inputs, @@ -157,19 +153,6 @@ compute_viewshed <- function(dsm, workers = workers) ) } else { - # if (isTRUE(Sys.info()[1]=="Windows") == TRUE){ - # viewsheds <- c() - # for(i in 1:length(viewpoints[,1])){ - # viewpoint <- c(viewpoints[i,1],viewpoints[i,2]) - # output <- radius_viewshed(dsm, r, viewpoint, offset_viewpoint) - # viewsheds <- c(viewsheds, output) - # } - # } else { - # viewsheds <- radius_viewshed_m(dsm=dsm, - # r=r, - # viewPts=viewpoints, - # offset=offset_viewpoint) - # } suppressWarnings( viewsheds <- paral_nix(X = inputs, dsm = dsm, diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 3891e5b..8b173f7 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -25,21 +25,6 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } -// multiLabel -Rcpp::List multiLabel(Rcpp::NumericMatrix& vpts, Rcpp::List& dsm, const int max_dis, const double vpth, const double h); -RcppExport SEXP _viewscape_multiLabel(SEXP vptsSEXP, SEXP dsmSEXP, SEXP max_disSEXP, SEXP vpthSEXP, SEXP hSEXP) { -BEGIN_RCPP - Rcpp::RObject rcpp_result_gen; - Rcpp::RNGScope rcpp_rngScope_gen; - Rcpp::traits::input_parameter< Rcpp::NumericMatrix& >::type vpts(vptsSEXP); - Rcpp::traits::input_parameter< Rcpp::List& >::type dsm(dsmSEXP); - Rcpp::traits::input_parameter< const int >::type max_dis(max_disSEXP); - Rcpp::traits::input_parameter< const double >::type vpth(vpthSEXP); - Rcpp::traits::input_parameter< const double >::type h(hSEXP); - rcpp_result_gen = Rcpp::wrap(multiLabel(vpts, dsm, max_dis, vpth, h)); - return rcpp_result_gen; -END_RCPP -} // visibleLabel Rcpp::IntegerMatrix visibleLabel(const Rcpp::NumericVector& viewpoint, const Rcpp::NumericMatrix& dsm, const double h, const int max_dis); RcppExport SEXP _viewscape_visibleLabel(SEXP viewpointSEXP, SEXP dsmSEXP, SEXP hSEXP, SEXP max_disSEXP) { @@ -57,7 +42,6 @@ END_RCPP static const R_CallMethodDef CallEntries[] = { {"_viewscape_get_depths", (DL_FUNC) &_viewscape_get_depths, 5}, - {"_viewscape_multiLabel", (DL_FUNC) &_viewscape_multiLabel, 5}, {"_viewscape_visibleLabel", (DL_FUNC) &_viewscape_visibleLabel, 4}, {NULL, NULL, 0} }; diff --git a/src/RcppExports.o b/src/RcppExports.o index 28df817..852a100 100644 Binary files a/src/RcppExports.o and b/src/RcppExports.o differ diff --git a/src/multiLabel.cpp b/src/multiLabel.cpp deleted file mode 100644 index 58f361b..0000000 --- a/src/multiLabel.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include - -using namespace Rcpp; - - -// [[Rcpp::export]] -Rcpp::List multiLabel(Rcpp::NumericMatrix &vpts, - Rcpp::List &dsm, - const int max_dis, - const double vpth, - const double h) { - - const int vptnum = vpts.rows(); - Rcpp::List output(vptnum); - for (int i = 0; i < vptnum; i++) { - Rcpp::NumericMatrix sub_dsm = dsm[i]; - int vx = vpts(i,0); - int vy = vpts(i,1); - const double vz = vpts(i,2) + vpth; - Rcpp::NumericVector zl; - Rcpp::NumericVector xl; - Rcpp::NumericVector yl; - const int sub_rows = sub_dsm.rows(); - const int sub_cols = sub_dsm.cols(); - int steps; - Rcpp::IntegerMatrix visible(sub_rows, sub_cols); - for (int j = 0; j < sub_rows; j++) { - for (int k = 0; k < sub_cols; k++) { - steps = sqrt((vx-k)*(vx-k) + (vy-j)*(vy-j)); - const double z = sub_dsm(j,k) + h; - if (steps <= max_dis) { - Rcpp::NumericVector sequence(steps); - std::iota(sequence.begin(), sequence.end(), 1); - xl = vx + sequence * (k-vx)/steps; - yl = vy + sequence * (j-vy)/steps; - if(vzz) { - zl = vz - sequence/steps*fabs(vz-z); - } else if (vz==z) { - zl = vz + 0*sequence; - } - int temp = 1; - for (int p = 0; p < steps; p++) { - const double d = zl[p] - sub_dsm(yl[p],xl[p]); - if (d < 0) { - temp = 0; - break; - } - } - visible(j,k) = temp; - } else { - visible(j,k) = 0; - } - } - } - output(i) = visible; - } - return output; -} - - diff --git a/src/viewscape.so b/src/viewscape.so index 8ec8126..a63a040 100755 Binary files a/src/viewscape.so and b/src/viewscape.so differ