Corrections projet
This commit is contained in:
@@ -683,29 +683,6 @@ bool isOnRoadArc(/* IN */
|
||||
return true;
|
||||
}
|
||||
|
||||
int isOnTLight(int x, int y, int rd, float dir_x, float dir_y)
|
||||
{
|
||||
if (map->tlight_arr == NULL ||
|
||||
map->tlight_sz <= 0)
|
||||
return -1;
|
||||
//no traffic light
|
||||
|
||||
for (int i = 0; i < map->tlight_sz; i++) {
|
||||
tlight_t *tl = &map->tlight_arr[i];
|
||||
if (tl->road != rd)
|
||||
continue;
|
||||
double d = distance(x, y, tl->tl.ptl_pos.x, tl->tl.ptl_pos.y);
|
||||
|
||||
/* double cosdir = dirCos(tl->tl.ptl_pos.y - y, x - tl->tl.ptl_pos.x,
|
||||
dir_x, dir_y); */ //MS
|
||||
double cosdir = dirCos(tl->tl.ptl_pos.x-x, tl->tl.ptl_pos.y-y,
|
||||
dir_x, dir_y); //EA
|
||||
if (d < TL_VIEW && cosdir > TL_COSDIR)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool isAfterStop(int x, int y, int rid, float dir_x, float dir_y, int* tl)
|
||||
{
|
||||
(*tl) = -1;
|
||||
@@ -822,7 +799,7 @@ isPositionOnPoint(float x, float y, road_t* rd, position_t* p, double pWidth)
|
||||
}
|
||||
}
|
||||
|
||||
Globals__color getColorPoint(int rid, float x, float y) {
|
||||
Globals__color getColorPoint(int rid, float x, float y, int* tl) {
|
||||
// first go through waypoints
|
||||
log_debug("[geometry] looking for waypoints at (%.2f, %.2f) on road %d\n",
|
||||
x, y, rid);
|
||||
@@ -855,6 +832,7 @@ Globals__color getColorPoint(int rid, float x, float y) {
|
||||
// stop points are ruban
|
||||
if (isPositionOnPoint(x, y, rd, &sp->position, RD_SIZE_STOP)) {
|
||||
log_debug("[geometry] (%.2f, %.2f) at stop %d\n", x, y, i);
|
||||
*tl = sp->sema;
|
||||
return COL_STOP;
|
||||
//one stop by position
|
||||
}
|
||||
@@ -909,28 +887,22 @@ DEFINE_HEPT_FUN(Map, lookup_pos, (Globals__position pos)) {
|
||||
out->data.dir_x = dir_X;
|
||||
out->data.dir_y = dir_Y;
|
||||
out->data.max_speed = map->road_arr[min_rd].max_speed;
|
||||
/* Update color when a waypoint or stop. */
|
||||
col = getColorPoint(rid, x, y);
|
||||
if (colors_equal(&col, &COL_OUT))
|
||||
out->data.color = out->data.color;
|
||||
else if (colors_equal(&col, &COL_STOP)) {
|
||||
/* TODO: update red color */
|
||||
out->data.color = col;
|
||||
}
|
||||
else {
|
||||
/* TODO: update green color */
|
||||
out->data.color = col;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Update color when a waypoint or stop. */
|
||||
int tl = -1;
|
||||
if (min_rd >= 0) {
|
||||
Globals__color col = getColorPoint(min_rd, x, y, &tl);
|
||||
if (!colors_equal(&col, &COL_OUT))
|
||||
out->data.color = col;
|
||||
}
|
||||
|
||||
/* Compute the return type. */
|
||||
if (min_rd >= 0) {
|
||||
log_debug("[geometry] (%.2f, %.2f) is on road %d\n", x, y, min_rd);
|
||||
out->data.on_road = true;
|
||||
int tl = -1;
|
||||
out->data.tl_number =
|
||||
isOnTLight(x, y, min_rd, out->data.dir_x, out->data.dir_y);
|
||||
out->data.tl_number = tl;
|
||||
out->data.tl_required = isAfterStop(x, y, min_rd,
|
||||
out->data.dir_x, out->data.dir_y, &tl);
|
||||
if(out->data.tl_required) {
|
||||
|
||||
Reference in New Issue
Block a user