Skip to content

Commit 0b9881e

Browse files
committed
Task 2: Handle downsampling of different resolutions
1 parent 5259015 commit 0b9881e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

app/server.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,20 @@ server <- function(input, output, session) {
127127
bull$x3p <- lapply(bull$x3p, x3p_rotate, angle = -90)
128128
}
129129

130+
# Check if we need to down-sample the bullet
131+
# Calculate the closest integer `n` that samples reference resolution to match incrementX
132+
if (nrow(bulldata$allbull) > 0) {
133+
reference_resolution <- x3p_get_scale(bulldata$allbull$x3p[[1]]) / 1e6
134+
target_resolution <- x3p_get_scale(bull$x3p[[1]])
135+
136+
if (reference_resolution != target_resolution) {
137+
alert("Detected different resolutions, down-sampling to match reference resolution...")
138+
m <- round(reference_resolution / target_resolution)
139+
140+
bull$x3p <- lapply(bull$x3p, x3p_sample, m = m)
141+
}
142+
}
143+
130144
cond_x3p_m_to_mum <- function(x3p)
131145
{
132146
scale <- x3p %>% x3p_get_scale()

0 commit comments

Comments
 (0)