Fix DCM intersecting time

This commit is contained in:
emanuel 2022-02-09 11:47:16 +00:00
parent 258190395e
commit 55d6488c41
1 changed files with 4 additions and 4 deletions

View File

@ -10,10 +10,10 @@
#define SLEEP_TIME_MS 100 #define SLEEP_TIME_MS 100
static int are_paths_intersecting(it2s_tender_st_s* tA, int tA_len, it2s_tender_st_s* tB, int tB_len) { static int are_paths_intersecting(it2s_tender_st_s* tA, int tA_len, it2s_tender_st_s* tB, int tB_len, uint64_t now) {
// TODO check first time intersection, then the spacial trajectory // TODO check first time intersection, then the spacial trajectory
double A1[2], A2[2], B1[2], B2[2]; double A1[2], A2[2], B1[2], B2[2];
uint64_t tsA, tsB; uint64_t tsA, tsB;
for (int a = 0; a < tA_len-1; ++a) { for (int a = 0; a < tA_len-1; ++a) {
@ -32,7 +32,7 @@ static int are_paths_intersecting(it2s_tender_st_s* tA, int tA_len, it2s_tender_
if (it2s_tender_do_segments_intersect(A1, A2, B1, B2)) { if (it2s_tender_do_segments_intersect(A1, A2, B1, B2)) {
if (tA[a].timestamp < tB[b].timestamp + 2000 && if (tA[a].timestamp < tB[b].timestamp + 2000 &&
tA[a].timestamp > tB[b].timestamp - 2000) { tA[a].timestamp > tB[b].timestamp - 2000) {
syslog_info("[facilities] [dc] intersecting @ (%d, %d) in %ld ms", tA[a].latitude, tA[a].longitude, tA[a].timestamp-tA[0].timestamp); syslog_info("[facilities] [dc] intersecting @ (%d, %d) in %ld ms", tA[a].latitude, tA[a].longitude, tA[a].timestamp-now);
return 1; return 1;
} }
} }
@ -81,7 +81,7 @@ int dcm_check(void* fc, DCM_t* dcm) {
} }
if (trajectoryA_len > 1 && trajectoryB_len > 1) { if (trajectoryA_len > 1 && trajectoryB_len > 1) {
are_paths_intersecting(trajectoryA, trajectoryA_len, trajectoryB, trajectoryB_len); are_paths_intersecting(trajectoryA, trajectoryA_len, trajectoryB, trajectoryB_len, now);
} }
cleanup: cleanup: