修改getquery函数
This commit is contained in:
parent
9e73aa8488
commit
13814579e6
|
@ -74,7 +74,7 @@ bus_query_t *SSTFGetQuery()
|
|||
int a,b,length,min;
|
||||
a = the_bus->rail_node_pos->id; //是当前公交车的位置,而不是站点位置,应该两者差别不大
|
||||
b = rails->last_node->id;//总的站点数
|
||||
if (1 <= a <= b/2)//判断当前站点的位置
|
||||
if (a >= 1 && a <= (b/2))//判断当前站点的位置
|
||||
{
|
||||
if (abs(a+b-queries->node->id) < abs(a-queries->node->id) ) //因为是环形轨道,用id相减的方式来计算距离的话,相减的方法不同
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ bus_query_t *SSTFGetQuery()
|
|||
min = abs(a-queries->node->id);
|
||||
}
|
||||
}
|
||||
else if (b/2 < a <=b)
|
||||
else if (a > (b/2) && a <=b)
|
||||
{
|
||||
if (abs(queries->node->id+b-a) < abs(a-queries->node->id))
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ bus_query_t *SSTFGetQuery()
|
|||
bus_query_t *result = queries;//如果第一个请求即最近的那一个,result=第一个请求
|
||||
while (p->time <= bus_time)//在当前的时间找到所有请求中最近的一个
|
||||
{
|
||||
if (1 <= a <= b/2)//对当前站点所在的位置进行分类讨论
|
||||
if (a >= 1 && a <= (b/2))//对当前站点所在的位置进行分类讨论
|
||||
{
|
||||
if (abs(a+b-p->node->id) <= abs(a-p->node->id) )
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ bus_query_t *SSTFGetQuery()
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (b/2 < a <=b)
|
||||
else if (a > (b/2) && a <=b)
|
||||
{
|
||||
if (abs(p->node->id+b-a) <= abs(a-p->node->id))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user