Skip to content

Commit

Permalink
undo s4 solution GVI
Browse files Browse the repository at this point in the history
  • Loading branch information
wlangera committed Jan 9, 2024
1 parent dcacef8 commit 0601c40
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions source/R/steekproefkader.R
Original file line number Diff line number Diff line change
Expand Up @@ -568,36 +568,14 @@ add_visibility_to_frame <- function(punten_sf,
dtm <- terra::rast(file_dtm)
crs(dtm) <- "epsg:31370"

# ptr slot gone when using terra::rast but still used in GVI
## Create a new class definition with the additional slot
setClass(
"SpatRasterWithPtr",
contains = "SpatRaster",
slots = c(ptr = "ANY")
)

## Create a constructor function for the new class
SpatRasterWithPtr <- function(...) {
obj <- new("SpatRasterWithPtr", ...)
obj@ptr <- NULL # You can initialize the ptr slot as needed
return(obj)
}

## Add ptr slot
dsm_with_ptr <- SpatRasterWithPtr(dsm)
dsm_with_ptr@ptr <- dsm@cpp

dtm_with_ptr <- SpatRasterWithPtr(dtm)
dtm_with_ptr@ptr <- dtm@cpp

vvi_dm <- vvi_from_sf(
observer = punten_sf %>% st_buffer(dist = observer_dist),
spacing = spacing,
cores = 1,
progress = TRUE,
max_distance = viewshed_dist,
dsm_rast = dsm_with_ptr,
dtm_rast = dtm_with_ptr,
dsm_rast = dsm,
dtm_rast = dtm,
observer_height = obs_height,
raster_res = resolution,
output_type = "cumulative",
Expand Down

0 comments on commit 0601c40

Please sign in to comment.