Logo Search packages:      
Sourcecode: navit version File versions

static int route_check_roundabout ( struct route_graph_segment seg,
int  level,
int  direction,
struct route_graph_segment origin 
) [static]

Checks if a segment is part of a roundabout.

This function checks if a segment is part of a roundabout.

Parameters:
seg The segment to be checked
level How deep to scan the route graph
direction Set this to 1 if we're entering the segment through its end, to 0 otherwise
origin Used internally, set to NULL
Returns:
1 If a roundabout was detected, 0 otherwise

Definition at line 412 of file route.c.

References route_graph_segment::data, route_graph_segment::end, route_segment_data::flags, route_segment_data::item, rp_iterator_end(), rp_iterator_new(), rp_iterator_next(), and route_graph_segment::start.

Referenced by route_path_add_item_from_graph().

{
      struct route_graph_point_iterator it,it2;
      struct route_graph_segment *cur;
      int count=0;

      if (!level) {
            return 0;
      }
      if (!direction && !(seg->data.flags & AF_ONEWAY)) {
            return 0;
      }
      if (direction && !(seg->data.flags & AF_ONEWAYREV)) {
            return 0;
      }
      
      if (!origin) {
            origin = seg;
      }

      if (!direction) {
            it = rp_iterator_new(seg->end);
      } else {
            it = rp_iterator_new(seg->start);
      }
      it2=it;
      
      while ((cur = rp_iterator_next(&it2)))
            count++;

      if (count > 3)
            return 0;
      cur = rp_iterator_next(&it);
      while (cur) {
            if (cur == seg) {
                  cur = rp_iterator_next(&it);
                  continue;
            }

            if (cur->data.item.type != origin->data.item.type) {
                  // This street is of another type, can't be part of the roundabout
                  cur = rp_iterator_next(&it);
                  continue;
            }

            if (cur == origin) {
                  seg->data.flags |= AF_ROUNDABOUT;
                  return 1;
            }

            if (route_check_roundabout(cur, (level-1), rp_iterator_end(&it), origin)) {
                  seg->data.flags |= AF_ROUNDABOUT;
                  return 1;
            }

            cur = rp_iterator_next(&it);
      }

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index