Fix:maptool:Another name for faroe islands
[navit-package] / navit / roadprofile.c
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_route_weight:
33                 this->route_weight=attr->u.num;
34                 break;
35         default:
36                 break;
37         }
38 }
39
40 struct roadprofile *
41 roadprofile_new(struct attr *parent, struct attr **attrs)
42 {
43         struct roadprofile *this_;
44         struct attr **attr;
45         this_=g_new0(struct roadprofile, 1);
46         this_->attrs=attr_list_dup(attrs);
47         for (attr=attrs;*attr; attr++) 
48                 roadprofile_set_attr_do(this_, *attr);
49         return this_;
50 }
51
52 int
53 roadprofile_get_attr(struct roadprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
54 {
55         return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
56 }
57
58 int
59 roadprofile_set_attr(struct roadprofile *this_, struct attr *attr)
60 {
61         roadprofile_set_attr_do(this_, attr);
62         this_->attrs=attr_generic_set_attr(this_->attrs, attr);
63         return 1;
64 }
65
66 int
67 roadprofile_add_attr(struct roadprofile *this_, struct attr *attr)
68 {
69         this_->attrs=attr_generic_add_attr(this_->attrs, attr);
70         return 1;
71 }
72
73 int
74 roadprofile_remove_attr(struct roadprofile *this_, struct attr *attr)
75 {
76         this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
77         return 1;
78 }
79