-
Notifications
You must be signed in to change notification settings - Fork 76
/
api_vector_info.R
63 lines (60 loc) · 1.6 KB
/
api_vector_info.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
#' @title Vector info API
#' @noRd
#' @author Rolf Simoes, \email{rolf.simoes@@inpe.br}
#' @author Felipe Carvalho, \email{felipe.carvalho@@inpe.br}
#'
#' @description
#' Set of functions for handling `vector_info`.
#'
NULL
#' @title Get `vector_info` from a given tile.
#' @noRd
#' @param tile A tile.
#' @returns A `vector_info` tibble.
.vi <- function(tile) {
vi <- tile[["vector_info"]][[1]]
vi
}
#' @title Set `vector_info` into a given tile.
#' @noRd
#' @param tile A tile.
#' @param value A `vector_info` to be set.
#' @returns An updated tile tibble.
`.vi<-` <- function(tile, value) {
tile <- .tile(tile)
tile[["vector_info"]] <- list(value)
tile
}
.vi_derived <- function(band, start_date, end_date, xres, yres,
xmin, xmax, ymin, ymax, path) {
# Create a new derived file_info
tibble::tibble(
band = .band_derived(band),
start_date = start_date,
end_date = end_date,
xres = xres,
yres = yres,
xmin = xmin,
xmax = xmax,
ymin = ymin,
ymax = ymax,
path = path
)
}
.vi_segment_from_file <- function(file, base_tile, band, start_date, end_date) {
file <- .file_path_expand(file)
v_obj <- .vector_read_vec(file_path = file)
bbox <- .vector_bbox(v_obj)
.vi_derived(
band = band,
start_date = start_date,
end_date = end_date,
xres = .tile_xres(base_tile),
yres = .tile_yres(base_tile),
xmin = bbox[["xmin"]],
xmax = bbox[["xmax"]],
ymin = bbox[["ymin"]],
ymax = bbox[["ymax"]],
path = file
)
}