summaryrefslogtreecommitdiff
path: root/navit/mapset.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-18 10:01:53 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2008-05-18 10:01:53 +0000
commit0b74d7f4ee6d448ac811e2741e8cb1ed04f5ce76 (patch)
treebe7bb1cb1020f4022e41c004e2fa9d561ea3580d /navit/mapset.c
parentf46eb419c46011d6d103b7f06cb2c842a2cbe6c9 (diff)
downloadnavit-0b74d7f4ee6d448ac811e2741e8cb1ed04f5ce76.tar.gz
Fix:Core:Renamed src to navit for cleanup of includes
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1059 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/mapset.c')
-rw-r--r--navit/mapset.c120
1 files changed, 120 insertions, 0 deletions
diff --git a/navit/mapset.c b/navit/mapset.c
new file mode 100644
index 000000000..5c805cbb4
--- /dev/null
+++ b/navit/mapset.c
@@ -0,0 +1,120 @@
+#include <string.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+#include "debug.h"
+#include "item.h"
+#include "mapset.h"
+#include "projection.h"
+#include "map.h"
+
+struct mapset {
+ GList *maps;
+};
+
+struct mapset *mapset_new(void)
+{
+ struct mapset *ms;
+
+ ms=g_new0(struct mapset, 1);
+
+ return ms;
+}
+
+void mapset_add(struct mapset *ms, struct map *m)
+{
+ ms->maps=g_list_append(ms->maps, m);
+}
+
+#if 0
+static void mapset_maps_free(struct mapset *ms)
+{
+ /* todo */
+}
+#endif
+
+void mapset_destroy(struct mapset *ms)
+{
+ g_free(ms);
+}
+
+struct mapset_handle {
+ GList *l;
+};
+
+struct mapset_handle *
+mapset_open(struct mapset *ms)
+{
+ struct mapset_handle *ret;
+
+ ret=g_new(struct mapset_handle, 1);
+ ret->l=ms->maps;
+
+ return ret;
+}
+
+struct map * mapset_next(struct mapset_handle *msh, int active)
+{
+ struct map *ret;
+
+ for (;;) {
+ if (!msh->l)
+ return NULL;
+ ret=msh->l->data;
+ msh->l=g_list_next(msh->l);
+ if (!active || map_get_active(ret))
+ return ret;
+ }
+}
+
+void
+mapset_close(struct mapset_handle *msh)
+{
+ g_free(msh);
+}
+
+struct mapset_search {
+ GList *map;
+ struct map_search *ms;
+ struct item *item;
+ struct attr *search_attr;
+ int partial;
+};
+
+struct mapset_search *
+mapset_search_new(struct mapset *ms, struct item *item, struct attr *search_attr, int partial)
+{
+ struct mapset_search *this;
+ dbg(1,"enter(%p,%p,%p,%d)\n", ms, item, search_attr, partial);
+ this=g_new0(struct mapset_search,1);
+ this->map=ms->maps;
+ this->item=item;
+ this->search_attr=search_attr;
+ this->partial=partial;
+ this->ms=map_search_new(this->map->data, item, search_attr, partial);
+ return this;
+}
+
+struct item *
+mapset_search_get_item(struct mapset_search *this)
+{
+ struct item *ret;
+ while (!(ret=map_search_get_item(this->ms))) {
+ if (this->search_attr->type >= attr_country_all && this->search_attr->type <= attr_country_name)
+ break;
+ do {
+ this->map=g_list_next(this->map);
+ } while (this->map && ! map_get_active(this->map->data));
+ if (! this->map)
+ break;
+ map_search_destroy(this->ms);
+ this->ms=map_search_new(this->map->data, this->item, this->search_attr, this->partial);
+ }
+ return ret;
+}
+
+void
+mapset_search_destroy(struct mapset_search *this)
+{
+ map_search_destroy(this->ms);
+ g_free(this);
+}