Add:option to configure multiple maps with similar attributes with one tag
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 20 Jun 2012 08:44:49 +0000 (08:44 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Wed, 20 Jun 2012 08:44:49 +0000 (08:44 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@5155 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/navit/CMakeLists.txt
navit/navit/Makefile.am
navit/navit/attr_def.h
navit/navit/maps.c [new file with mode: 0644]
navit/navit/xmlconfig.c
navit/navit/xmlconfig.h

index cf573c2..e159222 100644 (file)
@@ -6,7 +6,7 @@ include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/support")
 
 # navit cre
 set(NAVIT_SRC announcement.c atom.c attr.c cache.c callback.c command.c compass.c config_.c coord.c country.c data_window.c debug.c 
-   event.c file.c graphics.c gui.c item.c layout.c log.c main.c map.c obj_filter.c
+   event.c file.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c obj_filter.c
    linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c
    profile.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.c sunriset.c transform.c track.c 
    util.c vehicle.c vehicleprofile.c xmlconfig.c )
index 8c60b0a..a90f129 100644 (file)
@@ -49,7 +49,7 @@ pkgdata_DATA = navit.xml
 EXTRA_DIST = navit_shipped.xml navit.dtd
 
 lib@LIBNAVIT@_la_SOURCES = announcement.c atom.c attr.c cache.c callback.c obj_filter.c command.c compass.c config_.c coord.c country.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 \
+       event.c event_glib.h file.c graphics.c gui.c item.c layout.c log.c main.c map.c maps.c \
        linguistics.c mapset.c maptype.c menu.c messages.c bookmarks.c bookmarks.h navit.c navigation.c osd.c param.c phrase.c plugin.c popup.c \
        profile.c projection.c roadprofile.c route.c routech.c search.c speech.c start_real.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 obj_filter.h command.h compass.h config_.h coord.h country.h \
index dfa4a16..80bfcea 100644 (file)
@@ -431,6 +431,7 @@ ATTR(roadprofile)
 ATTR(announcement)
 ATTR(cursor)
 ATTR(config)
+ATTR(maps)
 ATTR2(0x0008ffff,type_object_end)
 ATTR2(0x00090000,type_coord_begin)
 ATTR2(0x0009ffff,type_coord_end)
diff --git a/navit/navit/maps.c b/navit/navit/maps.c
new file mode 100644 (file)
index 0000000..84b3416
--- /dev/null
@@ -0,0 +1,83 @@
+/**
+ * Navit, a modular navigation system.
+ * Copyright (C) 2005-2012 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 "item.h"
+#include "debug.h"
+#include "file.h"
+#include "map.h"
+#include "mapset.h"
+#include "xmlconfig.h"
+
+struct maps;
+
+struct maps *
+maps_new(struct attr *parent, struct attr **attrs)
+{
+       struct attr *data,**attrs_dup;
+       if (!parent) {
+               dbg(0,"No parent\n");
+               return NULL;
+       }
+       if (parent->type != attr_mapset) {
+               dbg(0,"Parent must be mapset\n");
+               return NULL;
+       }
+       dbg(0,"enter\n");
+       attrs_dup=attr_list_dup(attrs);
+       data=attr_search(attrs_dup, NULL, attr_data);
+       if (data) {
+               struct file_wordexp *wexp=file_wordexp_new(data->u.str);
+               int i,count=file_wordexp_get_count(wexp);
+               char **array=file_wordexp_get_array(wexp);
+               for (i = 0 ; i < count ; i++) {
+                       struct attr map;
+                       g_free(data->u.str);
+                       data->u.str=g_strdup(array[i]);
+                       map.type=attr_map;
+                       map.u.map=map_new(parent, attrs_dup);
+                       if (map.u.map) {
+                               mapset_add_attr(parent->u.mapset, &map);
+                               map_unref(map.u.map);
+                       }
+                       
+               }
+               file_wordexp_destroy(wexp);     
+       } else {
+               dbg(0,"no data attribute\n");
+       }
+       attr_list_free(attrs_dup);
+       return NULL;
+}
+
+struct object_func maps_func = {
+       attr_maps,
+       (object_func_new)maps_new,
+       (object_func_get_attr)NULL,
+       (object_func_iter_new)NULL,
+       (object_func_iter_destroy)NULL,
+       (object_func_set_attr)NULL,
+       (object_func_add_attr)NULL,
+       (object_func_remove_attr)NULL,
+       (object_func_init)NULL,
+       (object_func_destroy)NULL,
+       (object_func_dup)NULL,
+       (object_func_ref)NULL,
+       (object_func_unref)NULL,
+};
index b4ec4f5..df50b98 100644 (file)
@@ -272,6 +272,8 @@ object_func_lookup(enum attr_type type)
        switch (type) {
        case attr_map:
                return &map_func;
+       case attr_maps:
+               return &maps_func;
        case attr_mapset:
                return &mapset_func;
        case attr_navit:
@@ -519,6 +521,11 @@ static void initStatic(void) {
        elements[37].parent="plugins";
        elements[37].func=NULL;
        elements[37].type=attr_plugin;
+
+       elements[38].name="maps";
+       elements[38].parent="mapset";
+       elements[38].func=NULL;
+       elements[38].type=attr_maps;
 }
 
 /**
index 88ec349..3a7079e 100644 (file)
@@ -54,7 +54,7 @@ struct object_func {
        void *(*unref)(void *);
 };
 
-extern struct object_func map_func, mapset_func, navit_func, tracking_func, vehicle_func;
+extern struct object_func map_func, mapset_func, navit_func, tracking_func, vehicle_func, maps_func;
 
 #define HAS_OBJECT_FUNC(x) ((x) == attr_map || (x) == attr_mapset || (x) == attr_navit || (x) == attr_trackingo || (x) == attr_vehicle)