Add:core:Added iterator for destinations
authorakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 1 Sep 2010 07:19:12 +0000 (07:19 +0000)
committerakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 1 Sep 2010 07:19:12 +0000 (07:19 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@3542 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/route.c
navit/navit/route.h

index d0291b3..b6571b3 100644 (file)
@@ -283,6 +283,12 @@ struct route_graph_point_iterator {
        struct route_graph_segment *next;       /**< The next segment to be returned */
 };
 
+struct attr_iter {
+       union {
+               GList *list;
+       } u;
+};
+
 static struct route_info * route_find_nearest_street(struct vehicleprofile *vehicleprofile, struct mapset *ms, struct pcoord *c);
 static struct route_graph_point *route_graph_get_point(struct route_graph *this, struct coord *c);
 static void route_graph_update(struct route *this, struct callback *cb, int async);
@@ -3509,7 +3515,20 @@ route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, stru
                break;
        case attr_destination:
                if (this_->destinations) {
-                       struct route_info *dst=route_get_dst(this_);
+                       struct route_info *dst;
+                       if (iter) {
+                               if (iter->u.list) {
+                                       iter->u.list=g_list_next(iter->u.list);
+                               } else {
+                                       iter->u.list=this_->destinations;
+                               }
+                               if (!iter->u.list) {
+                                       return 0;
+                               }
+                               dst = (struct route_info*)iter->u.list->data;                           
+                       } else { //No iter handling
+                               dst=route_get_dst(this_);
+                       }
                        attr->u.pcoord=&this_->pc;
                        this_->pc.pro=projection_mg; /* fixme */
                        this_->pc.x=dst->c.x;
@@ -3547,6 +3566,18 @@ route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, stru
        return ret;
 }
 
+struct attr_iter *
+route_attr_iter_new(void)
+{
+       return g_new0(struct attr_iter, 1);
+}
+
+void
+route_attr_iter_destroy(struct attr_iter *iter)
+{
+       g_free(iter);
+}
+
 void
 route_init(void)
 {
index 71e4d4c..3878ec4 100644 (file)
@@ -123,9 +123,12 @@ struct map *route_get_map(struct route *route);
 struct map *route_get_graph_map(struct route *route);
 void route_set_projection(struct route *this_, enum projection pro);
 int route_destination_reached(struct route *);
+void route_set_destinations(struct route *this_, struct pcoord *dst, int count, int async);
 int route_set_attr(struct route *this_, struct attr *attr);
 int route_add_attr(struct route *this_, struct attr *attr);
 int route_remove_attr(struct route *this_, struct attr *attr);
+struct attr_iter * route_attr_iter_new(void);
+void route_attr_iter_destroy(struct attr_iter *iter);
 int route_get_attr(struct route *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
 void route_init(void);
 int route_pos_contains(struct route *, struct item *item);