forked from pramitghosh/statvis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintercamera.R
More file actions
61 lines (55 loc) · 1.29 KB
/
intercamera.R
File metadata and controls
61 lines (55 loc) · 1.29 KB
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
tA = globalized_tracks[[2]]
tB = globalized_tracks[[7]]
# tA@time
# tB@time
duplicate_trackpoints = function(tA, tB)
{
if(TrackSummary(tA)$tmin <= TrackSummary(tB)$tmin)
{
t1 = tA
t2 = tB
} else {
t1 = tB
t2 = tA
}
index = 0
ijd = data.frame()
if(TrackSummary(t1)$tmax > TrackSummary(t2)$tmin)
{
i2 = 1
i1 = 1
while(t1@sp$time[i1] < t2@sp$time[i2])
{
i1 = i1+1
}
i = 0
j = 0
while(i1 <= length(t1@data) && i2 <= length(t2@data))
{
i = c(i, i1)
j = c(j, i2)
i1 = i1+1
i2 = i2+1
}
i = i[-c(1)]
j = j[-c(1)]
index = cbind(i,j)
sdist = 0
tdist = 0
for(ij in 1:length(index[,1]))
{
t_sdist = calc_spatial_dist(t1@sp@coords[index[ij,1],], t2@sp@coords[index[ij,2],])
sdist[ij] = as.numeric(t_sdist)
t_tdist = calc_temporal_dist(t1@sp@data$time[index[ij,1]], t2@sp@data$time[index[ij,2]])
tdist[ij] = as.difftime(t_tdist)
}
# sdist = sdist[-c(1)]
# tdist = tdist[-c(1)]
sD = cross_spatial_treshold(sdist)
tD = cross_temporal_treshold(tdist)
tdist = as.difftime(tdist, units = "secs")
stD = as.logical(bitwAnd(sdist, tdist))
ijd = data.frame(index, sdist, sD, tdist, tD, stD)
}
return(ijd$stD)
} #else return(data.frame(FALSE))