From 54d5b968bcf3e578a2170ec62ffd74c5db87e97b Mon Sep 17 00:00:00 2001 From: emanuel Date: Thu, 10 Feb 2022 18:05:34 +0000 Subject: [PATCH] Change DCM intersect info --- src/dcm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/dcm.c b/src/dcm.c index aad7a86..000256a 100644 --- a/src/dcm.c +++ b/src/dcm.c @@ -12,7 +12,8 @@ static int are_vehicles_intersecting( it2s_tender_st_s* tA, int tA_len, uint16_t vA_length, uint16_t vA_width, - it2s_tender_st_s* tB, int tB_len, uint16_t vB_length, uint16_t vB_width + it2s_tender_st_s* tB, int tB_len, uint16_t vB_length, uint16_t vB_width, + int* index ) { // TODO check first time intersection, then the spacial trajectory @@ -37,7 +38,7 @@ static int are_vehicles_intersecting( if (it2s_tender_is_inside_rectangle(tA[a].latitude, tA[a].longitude, tB[b].latitude, tB[b].longitude, 8, 8, 0, DCM_HAVERSINE)) { if (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); + *index = a; return 1; } } @@ -86,7 +87,15 @@ int dcm_check(void* fc, DCM_t* dcm) { } if (trajectoryA_len > 1 && trajectoryB_len > 1) { - are_vehicles_intersecting(trajectoryA, trajectoryA_len, facilities->vehicle.length, facilities->vehicle.width, trajectoryB, trajectoryB_len, dcm->dcm.vehicleDimensions.length, dcm->dcm.vehicleDimensions.width); + int index = 0; + if (are_vehicles_intersecting( + trajectoryA, trajectoryA_len, facilities->vehicle.length, facilities->vehicle.width, + trajectoryB, trajectoryB_len, dcm->dcm.vehicleDimensions.length, dcm->dcm.vehicleDimensions.width, + &index) + ) { + syslog_info("[facilities] [dc] intersection danger with %ld @ (%d, %d) in %ld ms", + dcm->header.stationID, trajectoryA[index].latitude, trajectoryA[index].longitude, trajectoryA[index].timestamp - now); + } } cleanup: