Add:Core:First steps in making routing work for various profiles
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 2 Apr 2009 12:52:03 +0000 (12:52 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Thu, 2 Apr 2009 12:52:03 +0000 (12:52 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2183 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/Makefile.am
navit/navit/announcement.c [new file with mode: 0644]
navit/navit/announcement.h [new file with mode: 0644]
navit/navit/attr.c
navit/navit/attr_def.h
navit/navit/navit.xml
navit/navit/roadprofile.c [new file with mode: 0644]
navit/navit/roadprofile.h [new file with mode: 0644]
navit/navit/vehicleprofile.c [new file with mode: 0644]
navit/navit/vehicleprofile.h [new file with mode: 0644]
navit/navit/xmlconfig.c

index 4e5d08a..7e87c96 100644 (file)
@@ -22,16 +22,16 @@ pkgdata_DATA = navit.xml
 EXTRA_DIST = navit.xml 
 
 noinst_LTLIBRARIES        = libnavit.la
-libnavit_la_SOURCES = atom.c attr.c cache.c callback.c command.c compass.c coord.c country.c cursor.c data_window.c debug.c \
+libnavit_la_SOURCES = announcement.c atom.c attr.c cache.c callback.c command.c compass.c coord.c country.c cursor.c data_window.c debug.c \
        event.c event_glib.h file.c graphics.c gui.c item.c layout.c log.c main.c map.c \
        mapset.c maptype.c menu.c messages.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
-       profile.c projection.c route.c search.c speech.c transform.c track.c \
-       util.c vehicle.c xmlconfig.c atom.h attr.h attr_def.h cache.h callback.h color.h command.h compass.h coord.h country.h \
+       profile.c projection.c roadprofile.c route.c search.c speech.c transform.c track.c \
+       util.c vehicle.c vehicleprofile.c xmlconfig.c announcement.h atom.h attr.h attr_def.h cache.h callback.h color.h command.h compass.h coord.h country.h \
        cursor.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h endianess.h event.h \
        file.h graphics.h gtkext.h gui.h item.h item_def.h keys.h log.h layer.h layout.h main.h map-share.h map.h\
        map_data.h mapset.h maptype.h menu.h messages.h navigation.h navit.h osd.h \
-       param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h search.h speech.h \
-       transform.h track.h util.h vehicle.h window.h xmlconfig.h zipfile.h \
+       param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h roadprofile.h search.h speech.h \
+       transform.h track.h util.h vehicle.h vehicleprofile.h window.h xmlconfig.h zipfile.h \
        navit_nls.h
 
 navit_SOURCES = start.c
diff --git a/navit/navit/announcement.c b/navit/navit/announcement.c
new file mode 100644 (file)
index 0000000..9ea367a
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include <glib.h>
+#include "debug.h"
+#include "item.h"
+#include "announcement.h"
+
+struct announcement {
+       struct attr **attrs;
+};
+
+struct announcement *
+announcement_new(struct attr *parent, struct attr **attrs)
+{
+       struct announcement *this_;
+       struct attr *type_attr;
+       if (! (type_attr=attr_search(attrs, NULL, attr_name))) {
+               return NULL;
+       }
+       this_=g_new0(struct announcement, 1);
+       this_->attrs=attr_list_dup(attrs);
+       return this_;
+}
+
+int
+announcement_get_attr(struct announcement *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
+{
+       return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+}
+
+int
+announcement_set_attr(struct announcement *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+       return 1;
+}
+
+int
+announcement_add_attr(struct announcement *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+       return 1;
+}
+
+int
+announcement_remove_attr(struct announcement *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+       return 1;
+}
+
diff --git a/navit/navit/announcement.h b/navit/navit/announcement.h
new file mode 100644 (file)
index 0000000..695df4b
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+struct announcement * announcement_new(struct attr *parent, struct attr **attrs);
+int announcement_get_attr(struct announcement *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+int announcement_set_attr(struct announcement *this_, struct attr *attr);
+int announcement_add_attr(struct announcement *this_, struct attr *attr);
+int announcement_remove_attr(struct announcement *this_, struct attr *attr);
index d5ba5bf..370df95 100644 (file)
@@ -312,6 +312,32 @@ attr_generic_add_attr(struct attr **attrs, struct attr *attr)
        return curr;
 }
 
+struct attr **
+attr_generic_remove_attr(struct attr **attrs, struct attr *attr)
+{
+       struct attr **curr=attrs;
+       int i,j,count=0,found=0;
+       while (curr && *curr) {
+               if ((*curr)->type == attr->type && (*curr)->u.data == attr->u.data)
+                       found=1;
+               curr++;
+               count++;
+       }
+       if (!found == -1)
+               return attrs;
+       curr=g_new0(struct attr *, count);
+       j=0;
+       for (i = 0 ; i < count ; i++) {
+               if ((*curr)->type != attr->type || (*curr)->u.data != attr->u.data)
+                       curr[j++]=attrs[i];
+               else
+                       attr_free(attrs[i]);
+       }
+       curr[j]=NULL;
+       g_free(attrs);
+       return curr;
+}
+
 enum attr_type
 attr_type_begin(enum attr_type type)
 {
@@ -361,6 +387,11 @@ attr_data_size(struct attr *attr)
                return sizeof(*attr->u.num64);
        if (attr->type == attr_order)
                return sizeof(attr->u.range);
+       if (attr->type == attr_item_types) {
+               int i=0;
+               while (attr->u.item_types[i++] != type_none);
+               return i*sizeof(enum item_type);
+       }
        dbg(0,"size for %s unknown\n", attr_to_name(attr->type));
        return 0;
 }
index b050ccf..9abc5fd 100644 (file)
@@ -109,6 +109,10 @@ ATTR(pitch)
 ATTR(roll)
 ATTR(yaw)
 ATTR(route_status)
+ATTR(route_weight)
+ATTR(distance_metric)
+ATTR(route_mode)
+ATTR(maxspeed_handling)
 
 ATTR2(0x00027500,type_rel_abs_begin)
 /* These attributes are int that can either hold relative              *
@@ -279,6 +283,9 @@ ATTR(private_data)
 ATTR(callback_list)
 ATTR(displaylist)
 ATTR(transformation)
+ATTR(vehicleprofile)
+ATTR(roadprofile)
+ATTR(announcement)
 ATTR2(0x0008ffff,type_object_end)
 ATTR2(0x00090000,type_coord_begin)
 ATTR2(0x0009ffff,type_coord_end)
index 201527e..d01ab8d 100644 (file)
                                <!-- For the cumulative displacement filter to be enabled, set cdf_hist="x" here, with x being an integer somewhere around 4 -->
         <tracking cdf_histsize="0"/>
 
+       <vehicleprofile name="car" flags="0x40000000" flags="0x4000000" flags_forward_mask="0x4000002" flags_reverse_mask="0x4000001" maxspeed_handling="0" route_mode="0">
+           <roadprofile item_types="street_0,street_1_city" speed="10" route_weight="10">
+               <announcement level="0" distance_metric="25"/>
+               <announcement level="1" distance_metric="100"/>
+               <announcement level="2" distance_metric="200"/>
+           </roadprofile>
+            <roadprofile item_types="street_2_city" speed="30" route_weight="30">
+               <announcement level="0" distance_metric="50"/>
+               <announcement level="1" distance_metric="200"/>
+               <announcement level="2" distance_metric="500"/>
+           </roadprofile>
+            <roadprofile item_types="street_3_city" speed="40" route_weight="40">
+               <announcement level="0" distance_metric="50"/>
+               <announcement level="1" distance_metric="200"/>
+               <announcement level="2" distance_metric="500"/>
+           </roadprofile>
+            <roadprofile item_types="street_4_city" speed="50" route_weight="50">
+               <announcement level="0" distance_metric="50"/>
+               <announcement level="1" distance_metric="200"/>
+               <announcement level="2" distance_metric="500"/>
+           </roadprofile>
+            <roadprofile item_types="highway_city" speed="80" route_weight="80">
+               <announcement level="0" distance_metric="100"/>
+               <announcement level="1" distance_metric="400"/>
+               <announcement level="2" distance_metric="1000"/>
+           </roadprofile>
+            <roadprofile item_types="street_1_land" speed="60" route_weight="60">
+               <announcement level="0" distance_metric="100"/>
+               <announcement level="1" distance_metric="400"/>
+               <announcement level="2" distance_metric="1000"/>
+           </roadprofile>
+            <roadprofile item_types="street_2_land" speed="65" route_weight="65">
+               <announcement level="0" distance_metric="100"/>
+               <announcement level="1" distance_metric="400"/>
+               <announcement level="2" distance_metric="1000"/>
+           </roadprofile>
+            <roadprofile item_types="street_3_land" speed="70" route_weight="70">
+               <announcement level="0" distance_metric="100"/>
+               <announcement level="1" distance_metric="400"/>
+               <announcement level="2" distance_metric="1000"/>
+           </roadprofile>
+            <roadprofile item_types="street_4_land" speed="80" route_weight="80">
+               <announcement level="0" distance_metric="100"/>
+               <announcement level="1" distance_metric="400"/>
+               <announcement level="2" distance_metric="1000"/>
+           </roadprofile>
+            <roadprofile item_types="street_n_lanes" speed="120" route_weight="120">
+               <announcement level="0" distance_metric="300"/>
+               <announcement level="1" distance_metric="1000"/>
+               <announcement level="2" distance_metric="2000"/>
+           </roadprofile>
+            <roadprofile item_types="highway_land" speed="120" route_weight="120">
+               <announcement level="0" distance_metric="300"/>
+               <announcement level="1" distance_metric="1000"/>
+               <announcement level="2" distance_metric="2000"/>
+           </roadprofile>
+            <roadprofile item_types="ramp" speed="40" route_weight="40">
+               <announcement level="0" distance_metric="50"/>
+               <announcement level="1" distance_metric="200"/>
+               <announcement level="2" distance_metric="500"/>
+           </roadprofile>
+            <roadprofile item_types="roundabout" speed="10" route_weight="10"/>
+            <roadprofile item_types="ferry" speed="40" route_weight="40"/>
+       </vehicleprofile>
+
         <route destination_distance="50">
             <speed type="street_0,street_1_city" value="10"/>
             <speed type="street_2_city" value="30"/>
diff --git a/navit/navit/roadprofile.c b/navit/navit/roadprofile.c
new file mode 100644 (file)
index 0000000..a3ce77c
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include <glib.h>
+#include "debug.h"
+#include "item.h"
+#include "roadprofile.h"
+
+struct roadprofile {
+       struct attr **attrs;
+};
+
+struct roadprofile *
+roadprofile_new(struct attr *parent, struct attr **attrs)
+{
+       struct roadprofile *this_;
+       struct attr *type_attr;
+       this_=g_new0(struct roadprofile, 1);
+       this_->attrs=attr_list_dup(attrs);
+       return this_;
+}
+
+int
+roadprofile_get_attr(struct roadprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
+{
+       return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+}
+
+int
+roadprofile_set_attr(struct roadprofile *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+       return 1;
+}
+
+int
+roadprofile_add_attr(struct roadprofile *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+       return 1;
+}
+
+int
+roadprofile_remove_attr(struct roadprofile *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+       return 1;
+}
+
diff --git a/navit/navit/roadprofile.h b/navit/navit/roadprofile.h
new file mode 100644 (file)
index 0000000..3154820
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+struct roadprofile * roadprofile_new(struct attr *parent, struct attr **attrs);
+int roadprofile_get_attr(struct roadprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+int roadprofile_set_attr(struct roadprofile *this_, struct attr *attr);
+int roadprofile_add_attr(struct roadprofile *this_, struct attr *attr);
+int roadprofile_remove_attr(struct roadprofile *this_, struct attr *attr);
diff --git a/navit/navit/vehicleprofile.c b/navit/navit/vehicleprofile.c
new file mode 100644 (file)
index 0000000..7d3f781
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include "debug.h"
+#include "item.h"
+#include "vehicleprofile.h"
+
+struct vehicleprofile {
+       struct attr **attrs;
+};
+
+struct vehicleprofile *
+vehicleprofile_new(struct attr *parent, struct attr **attrs)
+{
+       struct vehicleprofile *this_;
+       struct 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);
+       return this_;
+}
+
+int
+vehicleprofile_get_attr(struct vehicleprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
+{
+       return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
+}
+
+int
+vehicleprofile_set_attr(struct vehicleprofile *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_set_attr(this_->attrs, attr);
+       return 1;
+}
+
+int
+vehicleprofile_add_attr(struct vehicleprofile *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_add_attr(this_->attrs, attr);
+       return 1;
+}
+
+int
+vehicleprofile_remove_attr(struct vehicleprofile *this_, struct attr *attr)
+{
+       this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
+       return 1;
+}
+
diff --git a/navit/navit/vehicleprofile.h b/navit/navit/vehicleprofile.h
new file mode 100644 (file)
index 0000000..bb09f5d
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2008 Navit Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+struct vehicleprofile * vehicleprofile_new(struct attr *parent, struct attr **attrs);
+int vehicleprofile_get_attr(struct vehicleprofile *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
+int vehicleprofile_set_attr(struct vehicleprofile *this_, struct attr *attr);
+int vehicleprofile_add_attr(struct vehicleprofile *this_, struct attr *attr);
+int vehicleprofile_remove_attr(struct vehicleprofile *this_, struct attr *attr);
index e8d3203..061feda 100644 (file)
@@ -45,6 +45,9 @@
 #include "osd.h"
 #include "log.h"
 #include "cursor.h"
+#include "announcement.h"
+#include "vehicleprofile.h"
+#include "roadprofile.h"
 #include "xmlconfig.h"
 
 #ifdef HAVE_GLIB
@@ -266,6 +269,7 @@ xmlconfig_announce(struct xmlstate *state)
 #define DESTROY(x) (void (*)(void *))(x)
 
 static struct object_func object_funcs[] = {
+       { attr_announcement,NEW(announcement_new),  GET(announcement_get_attr), NULL, NULL, SET(announcement_set_attr), ADD(announcement_add_attr) },
        { attr_arrows,     NEW(arrows_new)},
        { attr_circle,     NEW(circle_new),   NULL, NULL, NULL, NULL, ADD(element_add_attr)},
        { attr_coord,      NEW(coord_new_from_attrs)},
@@ -288,11 +292,13 @@ static struct object_func object_funcs[] = {
        { attr_plugin,     NEW(plugin_new)},
        { attr_polygon,    NEW(polygon_new),  NULL, NULL, NULL, NULL, ADD(element_add_attr)},
        { attr_polyline,   NEW(polyline_new), NULL, NULL, NULL, NULL, ADD(element_add_attr)},
+       { attr_roadprofile,NEW(roadprofile_new),  GET(roadprofile_get_attr), NULL, NULL, SET(roadprofile_set_attr), ADD(roadprofile_add_attr) },
        { attr_route,      NEW(route_new), GET(route_get_attr)},
        { attr_speech,     NEW(speech_new), GET(speech_get_attr), NULL, NULL, SET(speech_set_attr)},
        { attr_text,       NEW(text_new)},
        { attr_tracking,   NEW(tracking_new)},
        { attr_vehicle,    NEW(vehicle_new),  GET(vehicle_get_attr), NULL, NULL, NULL, ADD(vehicle_add_attr) },
+       { attr_vehicleprofile, NEW(vehicleprofile_new),  GET(vehicleprofile_get_attr), NULL, NULL, SET(vehicleprofile_set_attr), ADD(vehicleprofile_add_attr) },
 };
 
 struct object_func *
@@ -341,6 +347,9 @@ struct element_func {
        { "coord", "polyline", NULL, attr_coord},
        { "arrows", "itemgra", NULL, attr_arrows},
        { "vehicle", "navit", NULL, attr_vehicle},
+       { "vehicleprofile", "navit", NULL, attr_vehicleprofile},
+       { "roadprofile", "vehicleprofile", NULL, attr_roadprofile},
+       { "announcement", "roadprofile", NULL, attr_announcement},
        { "cursor", "vehicle", NULL, attr_cursor},
        { "itemgra", "cursor", NULL, attr_itemgra},
        { "log", "vehicle", NULL, attr_log},