Ticket #859: poi_filter_with_address_search3.2.diff

File poi_filter_with_address_search3.2.diff, 29.3 KB (added by http://wiki.navit-project.org/index.php/user:tryagain, 11 months ago)

Fixes error in fake function.

  • navit/maptool/osm.c

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    351351        { 999,"Unknown"}, 
    352352}; 
    353353 
     354// first char - item type 
     355//   =w - ways 
     356//   =? - used both for nodes and ways 
     357//   otherwise - nodes 
    354358 
    355359static char *attrmap={ 
    356360        "n      *=*                     point_unkn\n" 
    357361//      "n      Annehmlichkeit=Hochsitz poi_hunting_stand\n" 
    358         "n      addr:housenumber=*      house_number\n" 
    359         "n      aeroway=aerodrome       poi_airport\n" 
    360         "n      aeroway=airport         poi_airport\n" 
    361         "n      aeroway=helipad         poi_heliport\n" 
    362         "n      aeroway=terminal        poi_airport\n" 
    363         "n      amenity=atm             poi_bank\n" 
    364         "n      amenity=bank            poi_bank\n" 
    365         "n      amenity=bar             poi_bar\n" 
     362        "?      addr:housenumber=*      house_number\n" 
     363        "?      aeroway=aerodrome       poi_airport\n" 
     364        "?      aeroway=airport         poi_airport\n" 
     365        "?      aeroway=helipad         poi_heliport\n" 
     366        "?      aeroway=terminal        poi_airport\n" 
     367        "?      amenity=atm             poi_bank\n" 
     368        "?      amenity=bank            poi_bank\n" 
     369        "?      amenity=bar             poi_bar\n" 
    366370        "n      amenity=bench           poi_bench\n" 
    367         "n      amenity=biergarten      poi_biergarten\n" 
    368         "n      amenity=bus_station     poi_bus_station\n" 
    369         "n      amenity=cafe            poi_cafe\n" 
    370         "n      amenity=car_wash        poi_car_wash\n" 
    371         "n      amenity=cinema          poi_cinema\n" 
    372         "n      amenity=college         poi_school_college\n" 
    373         "n      amenity=courthouse      poi_justice\n" 
    374         "n      amenity=drinking_water  poi_potable_water\n" 
    375         "n      amenity=fast_food       poi_fastfood\n" 
    376         "n      amenity=fire_station    poi_firebrigade\n" 
    377         "n      amenity=fountain        poi_fountain\n" 
    378         "n      amenity=fuel            poi_fuel\n" 
    379         "n      amenity=grave_yard      poi_cemetery\n" 
    380         "n      amenity=hospital        poi_hospital\n" 
    381         "n      amenity=hunting_stand   poi_hunting_stand\n" 
    382         "n      amenity=kindergarten    poi_kindergarten\n" 
    383         "n      amenity=library         poi_library\n" 
    384         "n      amenity=nightclub       poi_nightclub\n" 
    385         "n      amenity=park_bench      poi_bench\n" 
    386         "n      amenity=parking         poi_car_parking\n" 
    387         "n      amenity=pharmacy        poi_pharmacy\n" 
    388         "n      amenity=place_of_worship,religion=christian     poi_church\n" 
    389         "n      amenity=place_of_worship                        poi_worship\n" 
    390         "n      amenity=police          poi_police\n" 
    391         "n      amenity=post_box        poi_post_box\n" 
    392         "n      amenity=post_office     poi_post_office\n" 
    393         "n      amenity=prison          poi_prison\n" 
    394         "n      amenity=pub             poi_pub\n" 
    395         "n      amenity=public_building poi_public_office\n" 
    396         "n      amenity=recycling       poi_recycling\n" 
    397         "n      amenity=restaurant,cuisine=fine_dining          poi_dining\n" 
    398         "n      amenity=restaurant                              poi_restaurant\n" 
    399         "n      amenity=school          poi_school\n" 
    400         "n      amenity=shelter         poi_shelter\n" 
    401         "n      amenity=taxi            poi_taxi\n" 
    402         "n      amenity=tec_common      tec_common\n" 
    403         "n      amenity=telephone       poi_telephone\n" 
    404         "n      amenity=theatre         poi_theater\n" 
    405         "n      amenity=toilets         poi_restroom\n" 
    406         "n      amenity=townhall        poi_townhall\n" 
    407         "n      amenity=university      poi_school_university\n" 
    408         "n      amenity=vending_machine poi_vending_machine\n" 
     371        "?      amenity=biergarten      poi_biergarten\n" 
     372        "?      amenity=bus_station     poi_bus_station\n" 
     373        "?      amenity=cafe            poi_cafe\n" 
     374        "?      amenity=car_wash        poi_car_wash\n" 
     375        "?      amenity=cinema          poi_cinema\n" 
     376        "?      amenity=college         poi_school_college\n" 
     377        "?      amenity=courthouse      poi_justice\n" 
     378        "?      amenity=drinking_water  poi_potable_water\n" 
     379        "?      amenity=fast_food       poi_fastfood\n" 
     380        "?      amenity=fire_station    poi_firebrigade\n" 
     381        "?      amenity=fountain        poi_fountain\n" 
     382        "?      amenity=fuel            poi_fuel\n" 
     383        "?      amenity=grave_yard      poi_cemetery\n" 
     384        "?      amenity=hospital        poi_hospital\n" 
     385        "?      amenity=hunting_stand   poi_hunting_stand\n" 
     386        "?      amenity=kindergarten    poi_kindergarten\n" 
     387        "?      amenity=library         poi_library\n" 
     388        "?      amenity=nightclub       poi_nightclub\n" 
     389        "?      amenity=park_bench      poi_bench\n" 
     390        "?      amenity=parking         poi_car_parking\n" 
     391        "?      amenity=pharmacy        poi_pharmacy\n" 
     392        "?      amenity=place_of_worship,religion=christian     poi_church\n" 
     393        "?      amenity=place_of_worship                        poi_worship\n" 
     394        "?      amenity=police          poi_police\n" 
     395        "?      amenity=post_box        poi_post_box\n" 
     396        "?      amenity=post_office     poi_post_office\n" 
     397        "?      amenity=prison          poi_prison\n" 
     398        "?      amenity=pub             poi_pub\n" 
     399        "?      amenity=public_building poi_public_office\n" 
     400        "?      amenity=recycling       poi_recycling\n" 
     401        "?      amenity=restaurant,cuisine=fine_dining          poi_dining\n" 
     402        "?      amenity=restaurant                              poi_restaurant\n" 
     403        "?      amenity=school          poi_school\n" 
     404        "?      amenity=shelter         poi_shelter\n" 
     405        "?      amenity=taxi            poi_taxi\n" 
     406        "?      amenity=tec_common      tec_common\n" 
     407        "?      amenity=telephone       poi_telephone\n" 
     408        "?      amenity=theatre         poi_theater\n" 
     409        "?      amenity=toilets         poi_restroom\n" 
     410        "?      amenity=townhall        poi_townhall\n" 
     411        "?      amenity=university      poi_school_university\n" 
     412        "?      amenity=vending_machine poi_vending_machine\n" 
    409413        "n      barrier=bollard         barrier_bollard\n" 
    410414        "n      barrier=cycle_barrier   barrier_cycle\n" 
    411415        "n      barrier=lift_gate       barrier_lift_gate\n" 
    412         "n      car=car_rental          poi_car_rent\n" 
    413         "n      highway=bus_station     poi_bus_station\n" 
    414         "n      highway=bus_stop        poi_bus_stop\n" 
     416        "?      car=car_rental          poi_car_rent\n" 
     417        "?      highway=bus_station     poi_bus_station\n" 
     418        "?      highway=bus_stop        poi_bus_stop\n" 
    415419        "n      highway=mini_roundabout mini_roundabout\n" 
    416420        "n      highway=motorway_junction       highway_exit\n" 
    417421        "n      highway=stop            traffic_sign_stop\n" 
    418422        "n      highway=toll_booth      poi_toll_booth\n" 
    419423        "n      highway=traffic_signals traffic_signals\n" 
    420424        "n      highway=turning_circle  turning_circle\n" 
    421         "n      historic=boundary_stone poi_boundary_stone\n" 
    422         "n      historic=castle         poi_castle\n" 
    423         "n      historic=memorial       poi_memorial\n" 
    424         "n      historic=monument       poi_monument\n" 
    425         "n      historic=ruins          poi_ruins\n" 
    426 //      "n      historic=*              poi_ruins\n" 
    427         "n      landuse=cemetery        poi_cemetery\n" 
    428         "n      leisure=fishing         poi_fish\n" 
    429         "n      leisure=golf_course     poi_golf\n" 
    430         "n      leisure=marina          poi_marine\n" 
    431         "n      leisure=playground      poi_playground\n" 
    432         "n      leisure=slipway         poi_boat_ramp\n" 
    433         "n      leisure=sports_centre   poi_sport\n" 
    434         "n      leisure=stadium         poi_stadium\n" 
    435         "n      man_made=tower          poi_tower\n" 
    436         "n      military=airfield       poi_military\n" 
    437         "n      military=barracks       poi_military\n" 
    438         "n      military=bunker         poi_military\n" 
    439         "n      military=danger_area    poi_danger_area\n" 
    440         "n      military=range          poi_military\n" 
    441         "n      natural=bay             poi_bay\n" 
    442         "n      natural=peak,ele=*              poi_peak\n"     // show only major peaks with elevation 
    443         "n      natural=tree            poi_tree\n" 
     425        "?      historic=boundary_stone poi_boundary_stone\n" 
     426        "?      historic=castle         poi_castle\n" 
     427        "?      historic=memorial       poi_memorial\n" 
     428        "?      historic=monument       poi_monument\n" 
     429        "?      historic=ruins          poi_ruins\n" 
     430//      "?      historic=*              poi_ruins\n" 
     431        "?      landuse=cemetery        poi_cemetery\n" 
     432        "?      leisure=fishing         poi_fish\n" 
     433        "?      leisure=golf_course     poi_golf\n" 
     434        "?      leisure=marina          poi_marine\n" 
     435        "?      leisure=playground      poi_playground\n" 
     436        "?      leisure=slipway         poi_boat_ramp\n" 
     437        "?      leisure=sports_centre   poi_sport\n" 
     438        "?      leisure=stadium         poi_stadium\n" 
     439        "?      man_made=tower          poi_tower\n" 
     440        "?      military=airfield       poi_military\n" 
     441        "?      military=barracks       poi_military\n" 
     442        "?      military=bunker         poi_military\n" 
     443        "?      military=danger_area    poi_danger_area\n" 
     444        "?      military=range          poi_military\n" 
     445        "?      natural=bay             poi_bay\n" 
     446        "?      natural=peak,ele=*              poi_peak\n"     // show only major peaks with elevation 
     447        "?      natural=tree            poi_tree\n" 
    444448        "n      place=city              town_label_2e5\n" 
    445449        "n      place=hamlet            town_label_2e2\n" 
    446450        "n      place=locality          town_label_2e0\n" 
     
    451455        "n      power=sub_station       power_substation\n" 
    452456        "n      railway=halt            poi_rail_halt\n" 
    453457        "n      railway=level_crossing  poi_level_crossing\n" 
    454         "n      railway=station         poi_rail_station\n" 
    455         "n      railway=tram_stop       poi_rail_tram_stop\n" 
    456         "n      shop=baker              poi_shop_baker\n" 
    457         "n      shop=bakery             poi_shop_baker\n" 
    458         "n      shop=beverages          poi_shop_beverages\n" 
    459         "n      shop=bicycle            poi_shop_bicycle\n" 
    460         "n      shop=butcher            poi_shop_butcher\n" 
    461         "n      shop=car                poi_car_dealer_parts\n" 
    462         "n      shop=car_repair         poi_repair_service\n" 
    463         "n      shop=clothes            poi_shop_apparel\n" 
    464         "n      shop=convenience        poi_shop_grocery\n" 
    465         "n      shop=drogist            poi_shop_drugstore\n" 
    466         "n      shop=florist            poi_shop_florist\n" 
    467         "n      shop=fruit              poi_shop_fruit\n" 
    468         "n      shop=furniture          poi_shop_furniture\n" 
    469         "n      shop=garden_centre      poi_shop_handg\n" 
    470         "n      shop=hardware           poi_shop_handg\n" 
    471         "n      shop=hairdresser        poi_hairdresser\n" 
    472         "n      shop=kiosk              poi_shop_kiosk\n" 
    473         "n      shop=optician           poi_shop_optician\n" 
    474         "n      shop=parfum             poi_shop_parfum\n" 
    475         "n      shop=photo              poi_shop_photo\n" 
    476         "n      shop=shoes              poi_shop_shoes\n" 
    477         "n      shop=supermarket        poi_shopping\n" 
    478         "n      sport=10pin             poi_bowling\n" 
    479         "n      sport=baseball          poi_baseball\n" 
    480         "n      sport=basketball        poi_basketball\n" 
    481         "n      sport=climbing          poi_climbing\n" 
    482         "n      sport=golf              poi_golf\n" 
    483         "n      sport=motor_sports      poi_motor_sport\n" 
    484         "n      sport=skiing            poi_skiing\n" 
    485         "n      sport=soccer            poi_soccer\n" 
    486         "n      sport=stadium           poi_stadium\n" 
    487         "n      sport=swimming          poi_swimming\n" 
    488         "n      sport=tennis            poi_tennis\n" 
    489         "n      tourism=attraction      poi_attraction\n" 
    490         "n      tourism=camp_site       poi_camp_rv\n" 
    491         "n      tourism=caravan_site    poi_camp_rv\n" 
    492         "n      tourism=guest_house     poi_guesthouse\n" 
    493         "n      tourism=hostel          poi_hostel\n" 
    494         "n      tourism=hotel           poi_hotel\n" 
    495         "n      tourism=information     poi_information\n" 
    496         "n      tourism=motel           poi_motel\n" 
    497         "n      tourism=museum          poi_museum_history\n" 
    498         "n      tourism=picnic_site     poi_picnic\n" 
    499         "n      tourism=theme_park      poi_resort\n" 
    500         "n      tourism=viewpoint       poi_viewpoint\n" 
    501         "n      tourism=zoo             poi_zoo\n" 
     458        "?      railway=station         poi_rail_station\n" 
     459        "?      railway=tram_stop       poi_rail_tram_stop\n" 
     460        "?      shop=baker              poi_shop_baker\n" 
     461        "?      shop=bakery             poi_shop_baker\n" 
     462        "?      shop=beverages          poi_shop_beverages\n" 
     463        "?      shop=bicycle            poi_shop_bicycle\n" 
     464        "?      shop=butcher            poi_shop_butcher\n" 
     465        "?      shop=car                poi_car_dealer_parts\n" 
     466        "?      shop=car_repair         poi_repair_service\n" 
     467        "?      shop=clothes            poi_shop_apparel\n" 
     468        "?      shop=convenience        poi_shop_grocery\n" 
     469        "?      shop=drogist            poi_shop_drugstore\n" 
     470        "?      shop=florist            poi_shop_florist\n" 
     471        "?      shop=fruit              poi_shop_fruit\n" 
     472        "?      shop=furniture          poi_shop_furniture\n" 
     473        "?      shop=garden_centre      poi_shop_handg\n" 
     474        "?      shop=hardware           poi_shop_handg\n" 
     475        "?      shop=hairdresser        poi_hairdresser\n" 
     476        "?      shop=kiosk              poi_shop_kiosk\n" 
     477        "?      shop=optician           poi_shop_optician\n" 
     478        "?      shop=parfum             poi_shop_parfum\n" 
     479        "?      shop=photo              poi_shop_photo\n" 
     480        "?      shop=shoes              poi_shop_shoes\n" 
     481        "?      shop=supermarket        poi_shopping\n" 
     482        "?      sport=10pin             poi_bowling\n" 
     483        "?      sport=baseball          poi_baseball\n" 
     484        "?      sport=basketball        poi_basketball\n" 
     485        "?      sport=climbing          poi_climbing\n" 
     486        "?      sport=golf              poi_golf\n" 
     487        "?      sport=motor_sports      poi_motor_sport\n" 
     488        "?      sport=skiing            poi_skiing\n" 
     489        "?      sport=soccer            poi_soccer\n" 
     490        "?      sport=stadium           poi_stadium\n" 
     491        "?      sport=swimming          poi_swimming\n" 
     492        "?      sport=tennis            poi_tennis\n" 
     493        "?      tourism=attraction      poi_attraction\n" 
     494        "?      tourism=camp_site       poi_camp_rv\n" 
     495        "?      tourism=caravan_site    poi_camp_rv\n" 
     496        "?      tourism=guest_house     poi_guesthouse\n" 
     497        "?      tourism=hostel          poi_hostel\n" 
     498        "?      tourism=hotel           poi_hotel\n" 
     499        "?      tourism=information     poi_information\n" 
     500        "?      tourism=motel           poi_motel\n" 
     501        "?      tourism=museum          poi_museum_history\n" 
     502        "?      tourism=picnic_site     poi_picnic\n" 
     503        "?      tourism=theme_park      poi_resort\n" 
     504        "?      tourism=viewpoint       poi_viewpoint\n" 
     505        "?      tourism=zoo             poi_zoo\n" 
    502506        "n      traffic_sign=city_limit traffic_sign_city_limit\n" 
    503507        "n      highway=speed_camera    tec_common\n" 
    504508        "w      *=*                     street_unkn\n" 
     
    713717build_attrmap_line(char *line) 
    714718{ 
    715719        char *t=NULL,*kvl=NULL,*i=NULL,*p,*kv; 
    716         struct attr_mapping ***attr_mapping_curr,*attr_mapping=g_malloc0(sizeof(struct attr_mapping)); 
    717         int idx,attr_mapping_count=0,*attr_mapping_curr_count; 
     720        struct attr_mapping /****attr_mapping_curr,*/*attr_mapping=g_malloc0(sizeof(struct attr_mapping)); 
     721        int idx,attr_mapping_count=0/*,attr_mapping_curr_count*/; 
    718722        t=line; 
    719723        p=strchr(t,'\t'); 
    720724        if (p) { 
     
    731735        if (t[0] == 'w') { 
    732736                if (! i) 
    733737                        i="street_unkn"; 
    734                 attr_mapping_curr=&attr_mapping_way; 
    735                 attr_mapping_curr_count=&attr_mapping_way_count; 
     738//              attr_mapping_curr=&attr_mapping_way; 
     739//              attr_mapping_curr_count=&attr_mapping_way_count; 
    736740        } else { 
    737741                if (! i) 
    738742                        i="point_unkn"; 
    739                 attr_mapping_curr=&attr_mapping_node; 
    740                 attr_mapping_curr_count=&attr_mapping_node_count; 
     743//              attr_mapping_curr=&attr_mapping_node; 
     744//              attr_mapping_curr_count=&attr_mapping_node_count; 
    741745        } 
    742746        attr_mapping->type=item_from_name(i); 
    743747        while ((kv=strtok(kvl, ","))) { 
     
    750754                attr_mapping->attr_present_idx[attr_mapping_count++]=idx; 
    751755                attr_mapping->attr_present_idx_count=attr_mapping_count; 
    752756        } 
    753         *attr_mapping_curr=g_realloc(*attr_mapping_curr, sizeof(**attr_mapping_curr)*(*attr_mapping_curr_count+1)); 
    754         (*attr_mapping_curr)[(*attr_mapping_curr_count)++]=attr_mapping; 
     757        if (t[0]== 'w' || t[0]== '?') { 
     758                attr_mapping_way=g_realloc(attr_mapping_way, sizeof(*attr_mapping_way)*(attr_mapping_way_count+1)); 
     759                attr_mapping_way[attr_mapping_way_count++]=attr_mapping; 
     760        } 
     761        if (t[0]!= 'w') { 
     762                attr_mapping_node=g_realloc(attr_mapping_node, sizeof(*attr_mapping_node)*(attr_mapping_node_count+1)); 
     763                attr_mapping_node[attr_mapping_node_count++]=attr_mapping; 
     764        } 
     765 
    755766} 
    756767 
    757768static void 
     
    15521563                } 
    15531564                item_bin_add_attr_string(item_bin, def_flags ? attr_street_name : attr_label, attr_strings[attr_string_label]); 
    15541565                item_bin_add_attr_string(item_bin, attr_street_name_systematic, attr_strings[attr_string_street_name_systematic]); 
     1566                item_bin_add_attr_string(item_bin, attr_house_number, attr_strings[attr_string_house_number]); 
     1567                item_bin_add_attr_string(item_bin, attr_street_name, attr_strings[attr_string_street_name]); 
     1568                item_bin_add_attr_string(item_bin, attr_phone, attr_strings[attr_string_phone]); 
     1569                item_bin_add_attr_string(item_bin, attr_fax, attr_strings[attr_string_fax]); 
     1570                item_bin_add_attr_string(item_bin, attr_email, attr_strings[attr_string_email]); 
     1571                item_bin_add_attr_string(item_bin, attr_county_name, attr_strings[attr_string_county_name]);  
     1572                item_bin_add_attr_string(item_bin, attr_url, attr_strings[attr_string_url]); 
    15551573                item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value); 
    15561574                if (debug_attr_buffer[0]) 
    15571575                        item_bin_add_attr_string(item_bin, attr_debug, debug_attr_buffer); 
  • navit/support/glib/fake.c

     
    109109#endif 
    110110} 
    111111 
     112// FIXME: should use real utf8-aware function 
     113gchar * g_utf8_casefold(const gchar *s, gssize len)  
     114{ 
     115  return g_ascii_strdown(s,len); 
     116} 
  • navit/gui/internal/gui_internal.c

     
    22402240                type_poi_peak+1, type_poi_motel-1, 
    22412241                type_poi_hostel+1,type_line-1, 
    22422242                type_none}}, 
    2243         {"unknown","Unknown",(enum item_type []){ 
     2243/*      {"unknown","Unknown",(enum item_type []){ 
    22442244                type_point_unkn,type_point_unkn, 
    2245                 type_none}}, 
     2245                type_none}},*/ 
    22462246}; 
    22472247 
    2248 union poi_param { 
    2249         guint i; 
    2250         struct { 
    2251                 unsigned char sel, selnb, pagenb, dist; 
    2252         } p; 
     2248 
     2249/* 
     2250 *  Get a utf-8 string, return the same prepared for case insensetive search. Result shoud be g_free()d after use. 
     2251 */ 
     2252 
     2253static char * 
     2254removecase(char *s)  
     2255{ 
     2256        char *r; 
     2257        r=g_utf8_casefold(s,-1); 
     2258        return r; 
     2259} 
     2260 
     2261struct poi_param { 
     2262                unsigned char sel, selnb, pagenb, dist, isAddressFilter; 
     2263                char *filterstr; /* Filter string, casefold()ed and divided into substrings at the spaces, which are replaced by ASCII 0*/ 
     2264                GList *filter; /* list of pointers to individual substrings of filterstr */ 
     2265                 
    22532266}; 
    22542267 
     2268 
     2269/** 
     2270 * @brief Free poi_param structure. 
     2271 * 
     2272 * @param p reference to the object to be freed. 
     2273 */ 
     2274static void 
     2275gui_internal_poi_param_free(void *p)  
     2276{ 
     2277        if(((struct poi_param *)p)->filterstr) 
     2278           g_free(((struct poi_param *)p)->filterstr); 
     2279        if(((struct poi_param *)p)->filter) 
     2280           g_list_free(((struct poi_param *)p)->filter); 
     2281        g_free(p); 
     2282}; 
     2283 
     2284/** 
     2285 * @brief Clone poi_param structure. 
     2286 * 
     2287 * @param p reference to the object to be cloned. 
     2288 * @return  Cloned object reference. 
     2289 */ 
     2290static struct poi_param * 
     2291gui_internal_poi_param_clone(struct poi_param *p)  
     2292{ 
     2293        struct poi_param *r=g_new(struct poi_param,1); 
     2294        GList *l=p->filter; 
     2295        memcpy(r,p,sizeof(struct poi_param)); 
     2296        r->filter=NULL; 
     2297        r->filterstr=NULL; 
     2298        if(p->filterstr) 
     2299                r->filterstr=g_strdup(p->filterstr); 
     2300        while(l) { 
     2301                r->filter=g_list_append(r->filter, r->filterstr + ((char*)(l->data) - p->filterstr) ); 
     2302                l=g_list_next(l); 
     2303        } 
     2304        return r; 
     2305}; 
     2306 
     2307 
    22552308static void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data); 
     2309static void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data); 
    22562310 
     2311 
    22572312static struct widget * 
    22582313gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int pagenb) 
    22592314{ 
     
    22692324        nrows=nitems/wl->cols + (nitems%wl->cols>0); 
    22702325        wl->h=this->icon_l*nrows; 
    22712326        for (i = 0 ; i < nitems ; i++) { 
    2272                 union poi_param p; 
    2273                 p.p.sel = 1; 
    2274                 p.p.selnb = i; 
    2275                 p.p.pagenb = pagenb; 
    2276                 p.p.dist = 0; 
     2327                struct poi_param *p=g_new(struct poi_param,1); 
     2328                p->sel = 1; 
     2329                p->selnb = i; 
     2330                p->pagenb = pagenb; 
     2331                p->dist = 0; 
     2332                p->filter=NULL; 
     2333                p->filterstr=NULL; 
    22772334                gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL, 
    22782335                        image_new_s(this, selectors[i].icon), gravity_left_center|orientation_vertical, 
    2279                         gui_internal_cmd_pois, GUINT_TO_POINTER(p.i))); 
     2336                        gui_internal_cmd_pois, p)); 
    22802337                wb->c=*c; 
     2338                wb->data_free=gui_internal_poi_param_free; 
    22812339                wb->bt=10; 
    22822340        } 
     2341 
     2342        gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL, 
     2343                        image_new_s(this, "gui_about"), gravity_left_center|orientation_vertical, 
     2344                        gui_internal_cmd_pois_filter, NULL)); 
     2345        wb->c=*c; 
     2346        wb->bt=10; 
     2347         
    22832348        gui_internal_widget_pack(this,wl); 
    22842349        return wl; 
    22852350} 
     
    23342399} 
    23352400 
    23362401static int 
    2337 gui_internal_cmd_pois_item_selected(struct selector *sel, enum item_type type) 
     2402gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item) 
    23382403{ 
    23392404        enum item_type *types; 
    2340         if (type >= type_line) 
     2405        struct selector *sel = param->sel? &selectors[param->selnb]: NULL; 
     2406        enum item_type type=item->type; 
     2407        struct attr attr; 
     2408        int match=0; 
     2409        if (type >= type_line && param->filter==NULL) 
    23412410                return 0; 
    2342         if (! sel || !sel->types) 
    2343                 return 1; 
    2344         types=sel->types; 
    2345         while (*types != type_none) { 
    2346                 if (type >= types[0] && type <= types[1]) { 
    2347                         return 1; 
     2411        if (! sel || !sel->types) { 
     2412                match=1; 
     2413        } else { 
     2414                types=sel->types; 
     2415                while (*types != type_none) { 
     2416                        if (item->type >= types[0] && item->type <= types[1]) { 
     2417                                return 1; 
     2418                        } 
     2419                        types+=2; 
    23482420                } 
    2349                 types+=2; 
    23502421        } 
    2351         return 0; 
     2422        if (param->filter) { 
     2423                char *long_name, *s; 
     2424                GList *f; 
     2425                if (param->isAddressFilter) { 
     2426                        s=g_strdup(""); 
     2427                        if(item_attr_get(item, attr_house_number, &attr))  
     2428                                s=g_strjoin(" ",s,attr.u.str,NULL); 
     2429                        if(item_attr_get(item, attr_street_name, &attr))  
     2430                                s=g_strjoin(" ",s,attr.u.str,NULL); 
     2431                        if(item_attr_get(item, attr_street_name_systematic, &attr))  
     2432                                s=g_strjoin(" ",s,attr.u.str,NULL); 
     2433                        if(item_attr_get(item, attr_district_name, &attr))  
     2434                                s=g_strjoin(" ",s,attr.u.str,NULL); 
     2435                        if(item_attr_get(item, attr_town_name, &attr))  
     2436                                s=g_strjoin(" ",s,attr.u.str,NULL); 
     2437                        if(item_attr_get(item, attr_county_name, &attr))  
     2438                                s=g_strjoin(" ",s,attr.u.str,NULL); 
     2439                        if(item_attr_get(item, attr_country_name, &attr))  
     2440                                s=g_strjoin(" ",s,attr.u.str,NULL); 
     2441                         
     2442                        if(item_attr_get(item, attr_address, &attr))  
     2443                                s=g_strjoin(" ",s,"|",attr.u.str,NULL); 
     2444                         
     2445                } else if (item_attr_get(item, attr_label, &attr)) { 
     2446                        s=g_strdup_printf("%s %s", item_to_name(item->type), attr.u.str); 
     2447                } else { 
     2448                        s=g_strdup(item_to_name(item->type)); 
     2449                } 
     2450                long_name=removecase(s); 
     2451                g_free(s); 
     2452                item_attr_rewind(item); 
     2453                 
     2454                for(s=long_name,f=param->filter;f && s;f=g_list_next(f)) { 
     2455                        s=strstr(s,f->data); 
     2456                        if(!s)  
     2457                                break; 
     2458                        s=g_utf8_strchr(s,-1,' '); 
     2459                } 
     2460                if(f) 
     2461                        match=0; 
     2462                g_free(long_name); 
     2463        } 
     2464        return match; 
    23522465} 
    23532466 
    23542467struct item_data { 
     
    23722485        w->data=wm->data; 
    23732486        w->c=wm->c; 
    23742487        w->w=wm->w; 
     2488        wm->data_free=NULL; 
    23752489        gui_internal_back(this, NULL, NULL); 
    2376         gui_internal_cmd_pois(this, w, NULL); 
     2490        gui_internal_cmd_pois(this, w, w->data); 
    23772491        free(w); 
    23782492} 
    23792493 
     2494/** 
     2495 * @brief apply POIs text filter. 
     2496 * 
     2497 * @param this The graphics context. 
     2498 * @param wm called widget. 
     2499 * @param data event data (pointer to editor widget containg filter text). 
     2500 */ 
     2501static void 
     2502gui_internal_cmd_pois_filter_do(struct gui_priv *this, struct widget *wm, void *data)  
     2503{ 
     2504        struct widget *w=data; 
     2505        struct poi_param *param; 
     2506        char *s1, *s2; 
     2507         
     2508        if(!w->text) 
     2509                return; 
     2510         
     2511        if(w->data) { 
     2512                param=gui_internal_poi_param_clone(w->data); 
     2513                param->pagenb=0; 
     2514        } else { 
     2515                param=g_new0(struct poi_param,1); 
     2516        } 
     2517        param->filterstr=removecase(w->text); 
     2518        param->isAddressFilter=strcmp(wm->name,"AddressFilter")==0; 
     2519        s1=param->filterstr; 
     2520        do { 
     2521                s2=g_utf8_strchr(s1,-1,' '); 
     2522                if(s2) 
     2523                        *s2++=0; 
     2524                param->filter=g_list_append(param->filter,s1); 
     2525                if(s2) { 
     2526                        while(*s2==' ') 
     2527                                s2++; 
     2528                } 
     2529                s1=s2; 
     2530        } while(s2 && *s2); 
    23802531 
     2532        gui_internal_cmd_pois(this,w,param); 
     2533        gui_internal_poi_param_free(param); 
     2534} 
     2535 
     2536/** 
     2537 * @brief POIs filter dialog. 
     2538 * Event to handle '\r' '\n' keys pressed. 
     2539 *  
     2540 */ 
     2541 
    23812542static void 
     2543gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, void *data) 
     2544{ 
     2545        int len; 
     2546        if (wm->text) { 
     2547                len=strlen(wm->text); 
     2548                dbg(1,"len=%d\n", len); 
     2549                if (len && (wm->text[len-1] == '\n' || wm->text[len-1] == '\r')) { 
     2550                        wm->text[len-1]='\0'; 
     2551                        //gui_internal_cmd_pois_filter_do(this, wm, wm); // Doesnt clean filter editor from the screen. How to disable it redrawing after POI list is drawn? 
     2552                } 
     2553        } 
     2554} 
     2555 
     2556 
     2557/** 
     2558 * @brief POIs filter dialog. 
     2559 * 
     2560 * @param this The graphics context. 
     2561 * @param wm called widget. 
     2562 * @param data event data. 
     2563 */ 
     2564static void 
     2565gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data)  
     2566{ 
     2567        struct widget *wb, *w, *wr, *wk, *we; 
     2568        int keyboard_mode=2; 
     2569        wb=gui_internal_menu(this,"Filter"); 
     2570        w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill); 
     2571        gui_internal_widget_append(wb, w); 
     2572        wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill); 
     2573        gui_internal_widget_append(w, wr); 
     2574        we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill); 
     2575        gui_internal_widget_append(wr, we); 
     2576 
     2577        gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL)); 
     2578        wk->state |= STATE_EDIT|STATE_EDITABLE; 
     2579        wk->func=gui_internal_cmd_pois_filter_changed; 
     2580        wk->background=this->background; 
     2581        wk->flags |= flags_expand|flags_fill; 
     2582        wk->name=g_strdup("POIsFilter"); 
     2583        wk->c=wm->c; 
     2584        gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_active"))); 
     2585        wb->state |= STATE_SENSITIVE; 
     2586        wb->func = gui_internal_cmd_pois_filter_do; 
     2587        wb->name=g_strdup("NameFilter"); 
     2588        wb->data=wk; 
     2589        gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "post"))); 
     2590        wb->state |= STATE_SENSITIVE; 
     2591        wb->name=g_strdup("AddressFilter"); 
     2592        wb->func = gui_internal_cmd_pois_filter_do; 
     2593        wb->data=wk; 
     2594         
     2595        if (this->keyboard) 
     2596                gui_internal_widget_append(w, gui_internal_keyboard(this,keyboard_mode)); 
     2597        gui_internal_menu_render(this); 
     2598 
     2599 
     2600} 
     2601 
     2602/** 
     2603 * @brief Do POI search specified by poi_param and display POIs found 
     2604 * 
     2605 * @param this The graphics context. 
     2606 * @param wm called widget. 
     2607 * @param data event data, reference to poi_param or NULL. 
     2608 */ 
     2609static void 
    23822610gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data) 
    23832611{ 
    23842612        struct map_selection *sel,*selm; 
     
    23892617        struct item *item; 
    23902618        struct widget *wi,*w,*w2,*wb, *wtable, *row; 
    23912619        enum projection pro=wm->c.pro; 
    2392         union poi_param param = {.i = GPOINTER_TO_UINT(wm->data)}; 
    2393         int idist,dist=10000*(param.p.dist+1); 
    2394         struct selector *isel = param.p.sel? &selectors[param.p.selnb]: NULL; 
    2395         int pagenb = param.p.pagenb; 
    2396         int prevdist=param.p.dist*10000; 
     2620        struct poi_param *param; 
     2621        int param_free=0; 
     2622        int idist,dist; 
     2623        struct selector *isel; 
     2624        int pagenb; 
     2625        int prevdist; 
    23972626        const int pagesize = 50; // Starting value and increment of count of items to be extracted 
    2398         int maxitem = pagesize*(pagenb+1), it = 0, i; 
    2399         struct item_data *items= g_new0( struct item_data, maxitem); 
     2627        int maxitem, it = 0, i; 
     2628        struct item_data *items; 
    24002629        struct fibheap* fh = fh_makekeyheap(); 
    24012630        int cnt = 0; 
    24022631        struct table_data *td; 
    24032632        int width=wm->w; 
    2404         dbg(2, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i\n", 
    2405                 param.p.sel, param.p.selnb, param.p.pagenb, param.p.dist); 
     2633         
     2634         
     2635        if(data) { 
     2636          param = data; 
     2637        } else { 
     2638          param = g_new0(struct poi_param,1); 
     2639          param_free=1; 
     2640        } 
     2641         
     2642        dist=10000*(param->dist+1); 
     2643        isel = param->sel? &selectors[param->selnb]: NULL; 
     2644        pagenb = param->pagenb; 
     2645        prevdist=param->dist*10000; 
     2646        maxitem = pagesize*(pagenb+1); 
     2647        items= g_new0( struct item_data, maxitem); 
     2648         
     2649         
     2650        dbg(0, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, isAddressFilter= %d\n", 
     2651                param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->isAddressFilter); 
    24062652 
    24072653        wb=gui_internal_menu(this, isel ? isel->name : _("POIs")); 
    24082654        w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill); 
    24092655        gui_internal_widget_append(wb, w); 
    2410         if (!isel) 
     2656        if (!isel && !param->filter) 
    24112657                gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c,pagenb)); 
    24122658        w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill); 
    24132659        gui_internal_widget_append(w, w2); 
     
    24222668                dbg(2,"mr=%p\n", mr); 
    24232669                if (mr) { 
    24242670                        while ((item=map_rect_get_item(mr))) { 
    2425                                 if (gui_internal_cmd_pois_item_selected(isel, item->type) && 
     2671                                if (gui_internal_cmd_pois_item_selected(param, item) && 
    24262672                                    item_coord_get_pro(item, &c, 1, pro) && 
    24272673                                    coord_rect_contains(&sel->u.c_rect, &c)  && 
    24282674                                    (idist=transform_distance(pro, &center, &c)) < dist) { 
     
    25042750        // Add an entry for more POI 
    25052751        struct widget *wl,*wt; 
    25062752        char buffer[32]; 
     2753        struct poi_param *paramnew; 
     2754        paramnew=gui_internal_poi_param_clone(param); 
    25072755        wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill); 
    25082756        if (it == maxitem) { 
    2509                 param.p.pagenb++; 
    2510                 snprintf(buffer, sizeof(buffer), "Get more (up to %d items)...", (param.p.pagenb+1)*pagesize); 
     2757                paramnew->pagenb++; 
     2758                snprintf(buffer, sizeof(buffer), "Get more (up to %d items)...", (paramnew->pagenb+1)*pagesize); 
    25112759        } else { 
    2512                 param.p.dist++; 
    2513                 snprintf(buffer, sizeof(buffer), "Set search distance to %i km", 10*(param.p.dist+1)); 
     2760                paramnew->dist++; 
     2761                snprintf(buffer, sizeof(buffer), "Set search distance to %i km", 10*(paramnew->dist+1)); 
    25142762        } 
    25152763        wt=gui_internal_label_new(this, buffer); 
    25162764        gui_internal_widget_append(wl, wt); 
    25172765        wl->func=gui_internal_cmd_pois_more; 
    2518         wl->data=GUINT_TO_POINTER(param.i); 
     2766        wl->data=paramnew; 
     2767        wl->data_free=gui_internal_poi_param_free; 
    25192768        wl->state |= STATE_SENSITIVE; 
    25202769        wl->c = wm->c; 
    25212770        row = gui_internal_widget_table_row_new(this, 
     
    25372786                } 
    25382787        } 
    25392788        gui_internal_menu_render(this); 
    2540  
     2789        if(param_free) 
     2790                g_free(param); 
    25412791} 
    25422792#endif /* _MSC_VER */ 
    25432793 
  • navit/search.c

     
    428428{ 
    429429        struct pcoord *ret=g_new(struct pcoord, 1); 
    430430        ret->pro = map_projection(item->map); 
    431         if (item_is_point(*item)) { 
     431        dbg(0,"%s\n",item_to_name(item->type)); 
     432        if (item->type<type_house_number_interpolation_even || item->type>type_house_number_interpolation_alphabetic) { 
    432433                struct coord c; 
    433434                if (item_coord_get(item, &c, 1)) { 
    434435                        ret->x=c.x; 
     
    472473                        dbg(1,"remaining distance=%d from %d\n",hn_distance,distances[i]); 
    473474                        ret->x=(c[i+1].x-c[i].x)*hn_distance/distances[i]+c[i].x; 
    474475                        ret->y=(c[i+1].y-c[i].y)*hn_distance/distances[i]+c[i].y; 
     476                        g_free(distances); 
    475477                } 
     478                g_free(c); 
    476479        } 
    477480        return ret; 
    478481} 
     
    772775                                this_->item=NULL; 
    773776                                break; 
    774777                        case 3: 
    775                                 dbg(0,"case 3 HOUSENUMBER"); 
     778                                dbg(0,"case 3 HOUSENUMBER\n"); 
     779                                has_street_name=0; 
    776780 
    777781                                // if this housenumber has a streetname tag, set the name now 
    778782                                if (item_attr_get(this_->item, attr_street_name, &attr2)) 
     
    780784                                        dbg(0,"streetname: %s\n",attr2.u.str); 
    781785                                        has_street_name=1; 
    782786                                } 
    783  
     787                                 
    784788                                p=search_list_house_number_new(this_->item, &this_->inter, le->attr->u.str, le->partial); 
    785789                                if (!p) 
    786790                                { 
     
    788792                                        this_->item=NULL; 
    789793                                        continue; 
    790794                                } 
     795 
    791796                                this_->result.house_number=p; 
    792797                                if (!this_->result.house_number->interpolation) 
    793798                                { 
    794799                                        this_->item=NULL; 
     800                                } else { 
     801                                        dbg(0,"interpolation!\n"); 
    795802                                } 
     803                                 
     804                                if(le->parent && has_street_name) { 
     805                                        struct search_list_street *street=this_->levels[level-1].last->data; 
     806                                        char *s1,*s2; 
     807                                        int cmpres; 
     808                                        s1=g_utf8_casefold(street->name,-1); 
     809                                        s2=g_utf8_casefold(attr2.u.str,-1); 
     810                                        cmpres=strcmp(s1,s2); 
     811                                        dbg(1,"Compared %s with %s, got %d\n",s1,s2,cmpres); 
     812                                        g_free(s1); 
     813                                        g_free(s2); 
     814                                        if(cmpres) { 
     815                                                search_list_house_number_destroy(p); 
     816                                                //this_->item=NULL; 
     817                                                continue; 
     818                                        } 
     819                                } 
    796820 
     821 
    797822                                this_->result.house_number->common.parent=this_->levels[2].last->data; 
    798823                                this_->result.street=this_->result.house_number->common.parent; 
    799824                                this_->result.town=this_->result.street->common.parent; 
    800825                                this_->result.country=this_->result.town->common.parent; 
    801826                                this_->result.c=this_->result.house_number->common.c; 
    802827 
    803                                 if (has_street_name==1) 
    804                                 { 
    805                                         gchar *tmp_name=g_strdup(attr2.u.str); 
    806                                         this_->result.street->name=tmp_name; 
    807                                         //dbg(0,"res streetname=%s\n",this_->result.street->name); 
     828                                if(!has_street_name) { 
     829                                        static struct search_list_street null_street; 
     830                                        this_->result.street=&null_street; 
    808831                                } 
    809                                 else 
    810                                 { 
    811                                         this_->result.street->name=NULL; 
    812                                 } 
    813832                        } 
    814833                        if (p) 
    815834                        {