summaryrefslogtreecommitdiff
path: root/navit/vehicleprofile.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-04-12 06:37:36 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-04-12 06:37:36 +0000
commite474f8b91608e8aa23c5e5d0297e9fc0f2bd0828 (patch)
treed374b97c40b326ee01496587ed46f99b2c4f4e58 /navit/vehicleprofile.c
parent9ecdf6aec3d0fea7b84dc1cb38b81414a7c617db (diff)
downloadnavit-e474f8b91608e8aa23c5e5d0297e9fc0f2bd0828.tar.gz
Fix:Core:Made routing more flexible
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2203 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/vehicleprofile.c')
-rw-r--r--navit/vehicleprofile.c52
1 files changed, 48 insertions, 4 deletions
diff --git a/navit/vehicleprofile.c b/navit/vehicleprofile.c
index 7d3f7812c..31c9bc9a5 100644
--- a/navit/vehicleprofile.c
+++ b/navit/vehicleprofile.c
@@ -23,20 +23,43 @@
#include "item.h"
#include "vehicleprofile.h"
-struct vehicleprofile {
- struct attr **attrs;
-};
+void
+vehicleprofile_set_attr_do(struct vehicleprofile *this_, struct attr *attr)
+{
+ switch (attr->type) {
+ case attr_flags:
+ this_->flags=attr->u.num;
+ break;
+ case attr_flags_forward_mask:
+ this_->flags_forward_mask=attr->u.num;
+ break;
+ case attr_flags_reverse_mask:
+ this_->flags_forward_mask=attr->u.num;
+ break;
+ case attr_maxspeed_handling:
+ this_->maxspeed_handling=attr->u.num;
+ break;
+ case attr_route_mode:
+ this_->mode=attr->u.num;
+ break;
+ default:
+ break;
+ }
+}
struct vehicleprofile *
vehicleprofile_new(struct attr *parent, struct attr **attrs)
{
struct vehicleprofile *this_;
- struct attr *type_attr;
+ struct attr **attr, *type_attr;
if (! (type_attr=attr_search(attrs, NULL, attr_name))) {
return NULL;
}
this_=g_new0(struct vehicleprofile, 1);
this_->attrs=attr_list_dup(attrs);
+ this_->roadprofile_hash=g_hash_table_new(NULL, NULL);
+ for (attr=attrs;*attr; attr++)
+ vehicleprofile_set_attr_do(this_, *attr);
return this_;
}
@@ -49,6 +72,7 @@ vehicleprofile_get_attr(struct vehicleprofile *this_, enum attr_type type, struc
int
vehicleprofile_set_attr(struct vehicleprofile *this_, struct attr *attr)
{
+ vehicleprofile_set_attr_do(this_, attr);
this_->attrs=attr_generic_set_attr(this_->attrs, attr);
return 1;
}
@@ -57,6 +81,21 @@ int
vehicleprofile_add_attr(struct vehicleprofile *this_, struct attr *attr)
{
this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+ struct attr item_types_attr;
+ switch (attr->type) {
+ case attr_roadprofile:
+ if (roadprofile_get_attr(attr->u.roadprofile, attr_item_types, &item_types_attr)) {
+ enum item_type *types=item_types_attr.u.item_types;
+ while (*types != type_none) {
+ g_hash_table_insert(this_->roadprofile_hash, (void *)(long)(*types), attr->u.roadprofile);
+ types++;
+ }
+ dbg(0,"ok\n");
+ }
+ break;
+ default:
+ break;
+ }
return 1;
}
@@ -67,3 +106,8 @@ vehicleprofile_remove_attr(struct vehicleprofile *this_, struct attr *attr)
return 1;
}
+struct roadprofile_data *
+vehicleprofile_get_roadprofile(struct vehicleprofile *this_, enum item_type type)
+{
+ return g_hash_table_lookup(this_->roadprofile_hash, (void *)(long)type);
+}