/[zanavi_public1]/navit/navit/roadprofile.c
ZANavi

Contents of /navit/navit/roadprofile.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations) (download)
Tue Aug 11 18:50:37 2015 UTC (8 years, 8 months ago) by zoff99
File MIME type: text/plain
File size: 2213 byte(s)
many fixes, and new features
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #include <glib.h>
21 #include "debug.h"
22 #include "item.h"
23 #include "roadprofile.h"
24
25 static void
26 roadprofile_set_attr_do(struct roadprofile *this, struct attr *attr)
27 {
28 switch (attr->type) {
29 case attr_speed:
30 this->speed=attr->u.num;
31 break;
32 case attr_maxspeed:
33 this->maxspeed=attr->u.num;
34 break;
35 case attr_route_weight:
36 this->route_weight=attr->u.num;
37 break;
38 case attr_route_prio_weight:
39 this->route_prio_weight=attr->u.num;
40 break;
41 default:
42 break;
43 }
44 }
45
46 struct roadprofile *
47 roadprofile_new(struct attr *parent, struct attr **attrs)
48 {
49 struct roadprofile *this_;
50 struct attr **attr;
51 this_=g_new0(struct roadprofile, 1);
52 this_->attrs=attr_list_dup(attrs);
53 this_->maxspeed=0;
54
55 for (attr=attrs;*attr; attr++)
56 {
57 roadprofile_set_attr_do(this_, *attr);
58 }
59
60 return this_;
61 }
62
63 int
64 roadprofile_get_attr(struct roadprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
65 {
66 return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
67 }
68
69 int
70 roadprofile_set_attr(struct roadprofile *this_, struct attr *attr)
71 {
72 roadprofile_set_attr_do(this_, attr);
73 this_->attrs=attr_generic_set_attr(this_->attrs, attr);
74 return 1;
75 }
76
77 int
78 roadprofile_add_attr(struct roadprofile *this_, struct attr *attr)
79 {
80 this_->attrs=attr_generic_add_attr(this_->attrs, attr);
81 return 1;
82 }
83
84 int
85 roadprofile_remove_attr(struct roadprofile *this_, struct attr *attr)
86 {
87 this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
88 return 1;
89 }
90

   
Visit the ZANavi Wiki