From: martin-s Date: Thu, 2 Apr 2009 12:52:03 +0000 (+0000) Subject: Add:Core:First steps in making routing work for various profiles X-Git-Tag: navit-0.5.0.5194svn~2975 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b086fb6f5fd2ab98b5f8f4aaf8bd8894aa473aee;p=profile%2Fivi%2Fnavit.git Add:Core:First steps in making routing work for various profiles git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2183 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/navit/navit/Makefile.am b/navit/navit/Makefile.am index 4e5d08a..7e87c96 100644 --- a/navit/navit/Makefile.am +++ b/navit/navit/Makefile.am @@ -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 index 0000000..9ea367a --- /dev/null +++ b/navit/navit/announcement.c @@ -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 +#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 index 0000000..695df4b --- /dev/null +++ b/navit/navit/announcement.h @@ -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); diff --git a/navit/navit/attr.c b/navit/navit/attr.c index d5ba5bf..370df95 100644 --- a/navit/navit/attr.c +++ b/navit/navit/attr.c @@ -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; } diff --git a/navit/navit/attr_def.h b/navit/navit/attr_def.h index b050ccf..9abc5fd 100644 --- a/navit/navit/attr_def.h +++ b/navit/navit/attr_def.h @@ -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) diff --git a/navit/navit/navit.xml b/navit/navit/navit.xml index 201527e..d01ab8d 100644 --- a/navit/navit/navit.xml +++ b/navit/navit/navit.xml @@ -107,6 +107,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/navit/navit/roadprofile.c b/navit/navit/roadprofile.c new file mode 100644 index 0000000..a3ce77c --- /dev/null +++ b/navit/navit/roadprofile.c @@ -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 +#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 index 0000000..3154820 --- /dev/null +++ b/navit/navit/roadprofile.h @@ -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 index 0000000..7d3f781 --- /dev/null +++ b/navit/navit/vehicleprofile.c @@ -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 +#include +#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 index 0000000..bb09f5d --- /dev/null +++ b/navit/navit/vehicleprofile.h @@ -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); diff --git a/navit/navit/xmlconfig.c b/navit/navit/xmlconfig.c index e8d3203..061feda 100644 --- a/navit/navit/xmlconfig.c +++ b/navit/navit/xmlconfig.c @@ -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},