Logo Search packages:      
Sourcecode: navit version File versions

static void route_process_street_graph ( struct route_graph this,
struct item *  item 
) [static]

Adds an item to the route graph.

This adds an item (e.g. a street) to the route graph, creating as many segments as needed for a segmented item.

Parameters:
this The route graph to add to
item The item to add

Definition at line 1589 of file route.c.

References map_projection(), route_graph_add_point(), and route_graph_add_segment().

{
#ifdef AVOID_FLOAT
      int len=0;
#else
      double len=0;
#endif
      struct route_graph_point *s_pnt,*e_pnt;
      struct coord c,l;
      struct attr flags_attr, maxspeed_attr;
      int flags = 0;
      int segmented = 0;
      int offset = 1;
      int maxspeed = -1;

      if (item_coord_get(item, &l, 1)) {
            int *default_flags=item_get_default_flags(item->type);
            if (! default_flags)
                  return;
            if (item_attr_get(item, attr_flags, &flags_attr)) {
                  flags = flags_attr.u.num;
                  if (flags & AF_SEGMENTED)
                        segmented = 1;
            } else
                  flags = *default_flags;
            

            if (flags & AF_SPEED_LIMIT) {
                  if (item_attr_get(item, attr_maxspeed, &maxspeed_attr)) {
                        maxspeed = maxspeed_attr.u.num;
                  }
            }

            s_pnt=route_graph_add_point(this,&l);
            if (!segmented) {
                  while (item_coord_get(item, &c, 1)) {
                        len+=transform_distance(map_projection(item->map), &l, &c);
                        l=c;
                  }
                  e_pnt=route_graph_add_point(this,&l);
                  dbg_assert(len >= 0);
                  if (!route_graph_segment_is_duplicate(s_pnt, item, flags, offset))
                        route_graph_add_segment(this, s_pnt, e_pnt, len, item, flags, offset, maxspeed);
            } else {
                  int isseg,rc;
                  int sc = 0;
                  do {
                        isseg = item_coord_is_node(item);
                        rc = item_coord_get(item, &c, 1);
                        if (rc) {
                              len+=transform_distance(map_projection(item->map), &l, &c);
                              l=c;
                              if (isseg) {
                                    e_pnt=route_graph_add_point(this,&l);
                                    if (!route_graph_segment_is_duplicate(s_pnt, item, flags, offset))
                                          route_graph_add_segment(this, s_pnt, e_pnt, len, item, flags, offset, maxspeed);
                                    offset++;
                                    s_pnt=route_graph_add_point(this,&l);
                                    len = 0;
                              }
                        }
                  } while(rc);
                  e_pnt=route_graph_add_point(this,&l);
                  dbg_assert(len >= 0);
                  sc++;
                  if (!route_graph_segment_is_duplicate(s_pnt, item, flags, offset))
                        route_graph_add_segment(this, s_pnt, e_pnt, len, item, flags, offset, maxspeed);
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index