summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-06-24 13:27:35 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-06-24 13:27:35 +0000
commit38154a42acc58f35daf76d14cb62611f0d20bbc4 (patch)
tree08e9e25b4c46ffc624dcbe44190f79443512167b
parentfdd59adee6f6c3c68f29c6806baf3f7870efdd67 (diff)
downloadnavit-38154a42acc58f35daf76d14cb62611f0d20bbc4.tar.gz
Fix:map_binfile:Use special char conversion and word stems for searching
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2364 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r--navit/linguistics.c14
-rw-r--r--navit/linguistics.h3
-rw-r--r--navit/map/binfile/binfile.c49
-rw-r--r--navit/start.c1
4 files changed, 59 insertions, 8 deletions
diff --git a/navit/linguistics.c b/navit/linguistics.c
index f8651f285..464296a0e 100644
--- a/navit/linguistics.c
+++ b/navit/linguistics.c
@@ -128,3 +128,17 @@ linguistics_expand_special(char *str, int mode)
}
return ret;
}
+
+char *
+linguistics_next_word(char *str)
+{
+ int len=strcspn(str, " -");
+ if (!str[len] || !str[len+1])
+ return NULL;
+ return str+len+1;
+}
+
+void
+linguistics_init(void)
+{
+}
diff --git a/navit/linguistics.h b/navit/linguistics.h
index abd23d379..5fe534f19 100644
--- a/navit/linguistics.h
+++ b/navit/linguistics.h
@@ -1 +1,4 @@
char *linguistics_expand_special(char *str, int mode);
+char *linguistics_next_word(char *str);
+void linguistics_init(void);
+
diff --git a/navit/map/binfile/binfile.c b/navit/map/binfile/binfile.c
index dff966e5e..d6a192ecc 100644
--- a/navit/map/binfile/binfile.c
+++ b/navit/map/binfile/binfile.c
@@ -34,6 +34,7 @@
#include "transform.h"
#include "file.h"
#include "zipfile.h"
+#include "linguistics.h"
#include "endianess.h"
static int map_id;
@@ -84,6 +85,9 @@ struct map_rect_priv {
struct tile *t;
int country_id;
char *url;
+#ifdef DEBUG_SIZE
+ int size;
+#endif
};
struct map_search_priv {
@@ -706,6 +710,9 @@ push_zipfile_tile(struct map_rect_priv *mr, int zipfile)
struct zip_cd *cd=(struct zip_cd *)(file_data_read(f, m->eoc->zipeofst + zipfile*m->cde_size, sizeof(struct zip_cd)));
cd_to_cpu(cd);
dbg(1,"enter %p %d\n", mr, zipfile);
+#ifdef DEBUG_SIZE
+ mr->size+=cd->zipcunc;
+#endif
t.zipfile_num=zipfile;
if (zipfile_to_tile(f, cd, &t))
push_tile(mr, &t);
@@ -799,6 +806,9 @@ map_rect_destroy_binfile(struct map_rect_priv *mr)
{
write_changes(mr->m);
while (pop_tile(mr));
+#ifdef DEBUG_SIZE
+ dbg(0,"size=%d kb\n",mr->size/1024);
+#endif
file_data_free(mr->m->fi, (unsigned char *)(mr->tiles[0].start));
g_free(mr->url);
g_free(mr);
@@ -1061,9 +1071,17 @@ binmap_search_get_item(struct map_search_priv *map_search)
case attr_town_name:
case attr_district_name:
case attr_town_or_district_name:
- if ((item_is_town(*it) && map_search->search->type != attr_district_name) || (item_is_district(*it) && map_search->search->type != attr_town_name)) {
+ if (item_is_town(*it) && map_search->search->type != attr_district_name) {
+ struct attr at;
+ if (binfile_attr_get(it->priv_data, attr_town_name_match, &at) || binfile_attr_get(it->priv_data, attr_town_name, &at)) {
+ if (!ascii_cmp(at.u.str, map_search->search->u.str, map_search->partial)) {
+ return it;
+ }
+ }
+ }
+ if (item_is_district(*it) && map_search->search->type != attr_town_name) {
struct attr at;
- if (binfile_attr_get(it->priv_data, attr_label, &at)) {
+ if (binfile_attr_get(it->priv_data, attr_district_name_match, &at) || binfile_attr_get(it->priv_data, attr_district_name, &at)) {
if (!ascii_cmp(at.u.str, map_search->search->u.str, map_search->partial)) {
return it;
}
@@ -1074,13 +1092,28 @@ binmap_search_get_item(struct map_search_priv *map_search)
if ((it->type == type_street_3_city) || (it->type == type_street_2_city) || (it->type == type_street_1_city)) {
struct attr at;
if (map_selection_contains_item_rect(map_search->mr->sel, it) && binfile_attr_get(it->priv_data, attr_label, &at)) {
- if (!ascii_cmp(at.u.str, map_search->search->u.str, map_search->partial)) {
- if (!g_hash_table_lookup(map_search->search_results, at.u.str)) {
- item_coord_rewind(it);
- item_attr_rewind(it);
- g_hash_table_insert(map_search->search_results, g_strdup(at.u.str), "");
- return it;
+ int i,match=0;
+ char *str=g_strdup(at.u.str);
+ char *word=str;
+ do {
+ for (i = 0 ; i < 3 ; i++) {
+ char *name=linguistics_expand_special(word,i);
+ if (name && !ascii_cmp(name, map_search->search->u.str, map_search->partial))
+ match=1;
+ g_free(name);
+ if (match)
+ break;
}
+ if (match)
+ break;
+ word=linguistics_next_word(word);
+ } while (word);
+ g_free(str);
+ if (match && !g_hash_table_lookup(map_search->search_results, at.u.str)) {
+ item_coord_rewind(it);
+ item_attr_rewind(it);
+ g_hash_table_insert(map_search->search_results, g_strdup(at.u.str), "");
+ return it;
}
}
}
diff --git a/navit/start.c b/navit/start.c
index d877af925..f31631bb3 100644
--- a/navit/start.c
+++ b/navit/start.c
@@ -102,6 +102,7 @@ int main(int argc, char **argv)
navigation_init();
tracking_init();
search_init();
+ linguistics_init();
config_file=NULL;
opterr=0; //don't bomb out on errors.
if (argc > 1) {