Added support for getting country id from a street
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 5 Nov 2007 09:22:05 +0000 (09:22 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Mon, 5 Nov 2007 09:22:05 +0000 (09:22 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@516 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/attr_def.h
navit/src/country.c
navit/src/data/mg/street.c
navit/src/popup.c
navit/src/search.c

index 966e48f..8b52400 100644 (file)
@@ -23,10 +23,10 @@ ATTR(y)
 ATTR(flush_size)
 ATTR(flush_time)
 ATTR(zipfile_ref)
+ATTR(country_id)
 /* boolean */
 ATTR(overwrite)
 ATTR2(0x0002ffff,type_int_end)
-
 ATTR2(0x00030000,type_string_begin)
 ATTR(type)
 ATTR(label)
index f7f238f..4adf632 100644 (file)
@@ -113,7 +113,7 @@ country_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
                attr->u.str=gettext(country->name);
                this->attr_next=attr_id;
                return 1;
-       case attr_id:
+       case attr_country_id:
                attr->u.num=country->id;
                this->attr_next=country->car ? attr_country_car : attr_country_iso2;
                return 1;
@@ -152,7 +152,10 @@ country_search_new(struct attr *search, int partial)
 {
        struct country_search *ret=g_new(struct country_search, 1);
        ret->search=*search;
-       ret->len=strlen(search->u.str);
+       if (search->type != attr_country_id)
+               ret->len=strlen(search->u.str);
+       else
+               ret->len=0;
        ret->partial=partial;
        ret->count=0;
 
@@ -189,7 +192,8 @@ country_search_get_item(struct country_search *this)
                if (this->count >= sizeof(country)/sizeof(struct country))
                        return NULL;
                this->country=&country[this->count++];
-               if (match(this, attr_country_iso3, this->country->iso3) ||
+               if ((this->search.type == attr_country_id && this->search.u.num == this->country->id) ||
+                    match(this, attr_country_iso3, this->country->iso3) ||
                    match(this, attr_country_iso2, this->country->iso2) ||
                    match(this, attr_country_car, this->country->car) ||
                    match(this, attr_country_name, gettext(this->country->name))) {
index 94e0b5f..e317c07 100644 (file)
@@ -258,7 +258,16 @@ street_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
                        attr->u.num=(street->str->limit & 0x30) ? 1:0;
                        attr->u.num|=(street->str->limit & 0x03) ? 2:0;
                }
+               street->attr_next=attr_country_id;
+               return 1;
+       case attr_country_id:
                street->attr_next=attr_debug;
+               nameid=L(street->str->nameid);
+               if (! nameid)
+                       return 0;
+               if (! street->name.len)
+                       street_name_get_by_id(&street->name,street->name_file,nameid);
+               attr->u.num=street->name.country;
                return 1;
        case attr_debug:
                street->attr_next=attr_none;
index cc532b7..2ae09cc 100644 (file)
@@ -121,7 +121,7 @@ popup_show_attr_val(void *menu, struct attr *attr)
 {
        char *attr_name=attr_to_name(attr->type);
 
-       if (attr->type == attr_limit
+       if (attr->type >= attr_type_int_begin && attr->type <= attr_type_int_end
                popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num);
        else 
                popup_printf(menu, menu_type_menu, "%s: %s", attr_name, attr->u.str);
index 91f2cb3..5bca95a 100644 (file)
@@ -247,6 +247,8 @@ search_list_get_result(struct search_list *this_)
                                le->parent=NULL;
                        else {
                                leu=&this_->levels[level-1];
+                               if (! leu->curr)
+                                       break;
                                le->parent=leu->curr->data;
                                leu->last=leu->curr;
                                leu->curr=g_list_next(leu->curr);