forked from r-lidar/lidR
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClass-LAScluster.r
74 lines (69 loc) · 2.3 KB
/
Class-LAScluster.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# ===============================================================================
#
# PROGRAMMERS:
#
# [email protected] - https://github.com/Jean-Romain/lidR
#
# COPYRIGHT:
#
# Copyright 2016 Jean-Romain Roussel
#
# This file is part of lidR R package.
#
# lidR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
#
# ===============================================================================
setClass(
Class = "LAScluster", contains = "Spatial",
representation(
center = "list",
bbbox = "matrix",
width = "numeric",
height = "numeric",
buffer = "numeric",
shape = "numeric",
select = "character",
filter = "character",
wkt = "character",
files = "character",
name = "character",
save = "character"
)
)
setMethod("initialize", "LAScluster", function(.Object, center, width, height, buffer, shape, files, name, wkt, proj4string)
{
hw = width/2
hh = height/2
xc = center$x
yc = center$y
.Object@center <- center
.Object@bbox <- matrix(c(xc - hw, yc - hh, xc + hw, yc + hh), ncol = 2)
.Object@bbbox <- .Object@bbox + buffer * matrix(c(-1, -1, +1, +1), ncol = 2)
.Object@width <- width + 2 * buffer
.Object@height <- height + 2 * buffer
.Object@buffer <- buffer
.Object@shape <- shape
.Object@name <- name
.Object@files <- files
.Object@save <- ""
.Object@wkt <- ""
.Object@proj4string <- proj4string
if (shape == LIDRCIRCLE)
.Object@filter = paste("-inside_circle", xc, yc, hw + buffer)
else if (shape == LIDRRECTANGLE)
.Object@filter = paste("-inside", .Object@bbbox[1], .Object@bbbox[2], .Object@bbbox[3], .Object@bbbox[4])
else
stop("Something went wrong internally initializing a cluster. Process aborted.")
return(.Object)
})