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) |
|---|
-
navit/maptool/osm.c
Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
351 351 { 999,"Unknown"}, 352 352 }; 353 353 354 // first char - item type 355 // =w - ways 356 // =? - used both for nodes and ways 357 // otherwise - nodes 354 358 355 359 static char *attrmap={ 356 360 "n *=* point_unkn\n" 357 361 // "n Annehmlichkeit=Hochsitz poi_hunting_stand\n" 358 " naddr:housenumber=* house_number\n"359 " naeroway=aerodrome poi_airport\n"360 " naeroway=airport poi_airport\n"361 " naeroway=helipad poi_heliport\n"362 " naeroway=terminal poi_airport\n"363 " namenity=atm poi_bank\n"364 " namenity=bank poi_bank\n"365 " namenity=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" 366 370 "n amenity=bench poi_bench\n" 367 " namenity=biergarten poi_biergarten\n"368 " namenity=bus_station poi_bus_station\n"369 " namenity=cafe poi_cafe\n"370 " namenity=car_wash poi_car_wash\n"371 " namenity=cinema poi_cinema\n"372 " namenity=college poi_school_college\n"373 " namenity=courthouse poi_justice\n"374 " namenity=drinking_water poi_potable_water\n"375 " namenity=fast_food poi_fastfood\n"376 " namenity=fire_station poi_firebrigade\n"377 " namenity=fountain poi_fountain\n"378 " namenity=fuel poi_fuel\n"379 " namenity=grave_yard poi_cemetery\n"380 " namenity=hospital poi_hospital\n"381 " namenity=hunting_stand poi_hunting_stand\n"382 " namenity=kindergarten poi_kindergarten\n"383 " namenity=library poi_library\n"384 " namenity=nightclub poi_nightclub\n"385 " namenity=park_bench poi_bench\n"386 " namenity=parking poi_car_parking\n"387 " namenity=pharmacy poi_pharmacy\n"388 " namenity=place_of_worship,religion=christian poi_church\n"389 " namenity=place_of_worship poi_worship\n"390 " namenity=police poi_police\n"391 " namenity=post_box poi_post_box\n"392 " namenity=post_office poi_post_office\n"393 " namenity=prison poi_prison\n"394 " namenity=pub poi_pub\n"395 " namenity=public_building poi_public_office\n"396 " namenity=recycling poi_recycling\n"397 " namenity=restaurant,cuisine=fine_dining poi_dining\n"398 " namenity=restaurant poi_restaurant\n"399 " namenity=school poi_school\n"400 " namenity=shelter poi_shelter\n"401 " namenity=taxi poi_taxi\n"402 " namenity=tec_common tec_common\n"403 " namenity=telephone poi_telephone\n"404 " namenity=theatre poi_theater\n"405 " namenity=toilets poi_restroom\n"406 " namenity=townhall poi_townhall\n"407 " namenity=university poi_school_university\n"408 " namenity=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" 409 413 "n barrier=bollard barrier_bollard\n" 410 414 "n barrier=cycle_barrier barrier_cycle\n" 411 415 "n barrier=lift_gate barrier_lift_gate\n" 412 " ncar=car_rental poi_car_rent\n"413 " nhighway=bus_station poi_bus_station\n"414 " nhighway=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" 415 419 "n highway=mini_roundabout mini_roundabout\n" 416 420 "n highway=motorway_junction highway_exit\n" 417 421 "n highway=stop traffic_sign_stop\n" 418 422 "n highway=toll_booth poi_toll_booth\n" 419 423 "n highway=traffic_signals traffic_signals\n" 420 424 "n highway=turning_circle turning_circle\n" 421 " nhistoric=boundary_stone poi_boundary_stone\n"422 " nhistoric=castle poi_castle\n"423 " nhistoric=memorial poi_memorial\n"424 " nhistoric=monument poi_monument\n"425 " nhistoric=ruins poi_ruins\n"426 // " nhistoric=* poi_ruins\n"427 " nlanduse=cemetery poi_cemetery\n"428 " nleisure=fishing poi_fish\n"429 " nleisure=golf_course poi_golf\n"430 " nleisure=marina poi_marine\n"431 " nleisure=playground poi_playground\n"432 " nleisure=slipway poi_boat_ramp\n"433 " nleisure=sports_centre poi_sport\n"434 " nleisure=stadium poi_stadium\n"435 " nman_made=tower poi_tower\n"436 " nmilitary=airfield poi_military\n"437 " nmilitary=barracks poi_military\n"438 " nmilitary=bunker poi_military\n"439 " nmilitary=danger_area poi_danger_area\n"440 " nmilitary=range poi_military\n"441 " nnatural=bay poi_bay\n"442 " nnatural=peak,ele=* poi_peak\n" // show only major peaks with elevation443 " nnatural=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" 444 448 "n place=city town_label_2e5\n" 445 449 "n place=hamlet town_label_2e2\n" 446 450 "n place=locality town_label_2e0\n" … … 451 455 "n power=sub_station power_substation\n" 452 456 "n railway=halt poi_rail_halt\n" 453 457 "n railway=level_crossing poi_level_crossing\n" 454 " nrailway=station poi_rail_station\n"455 " nrailway=tram_stop poi_rail_tram_stop\n"456 " nshop=baker poi_shop_baker\n"457 " nshop=bakery poi_shop_baker\n"458 " nshop=beverages poi_shop_beverages\n"459 " nshop=bicycle poi_shop_bicycle\n"460 " nshop=butcher poi_shop_butcher\n"461 " nshop=car poi_car_dealer_parts\n"462 " nshop=car_repair poi_repair_service\n"463 " nshop=clothes poi_shop_apparel\n"464 " nshop=convenience poi_shop_grocery\n"465 " nshop=drogist poi_shop_drugstore\n"466 " nshop=florist poi_shop_florist\n"467 " nshop=fruit poi_shop_fruit\n"468 " nshop=furniture poi_shop_furniture\n"469 " nshop=garden_centre poi_shop_handg\n"470 " nshop=hardware poi_shop_handg\n"471 " nshop=hairdresser poi_hairdresser\n"472 " nshop=kiosk poi_shop_kiosk\n"473 " nshop=optician poi_shop_optician\n"474 " nshop=parfum poi_shop_parfum\n"475 " nshop=photo poi_shop_photo\n"476 " nshop=shoes poi_shop_shoes\n"477 " nshop=supermarket poi_shopping\n"478 " nsport=10pin poi_bowling\n"479 " nsport=baseball poi_baseball\n"480 " nsport=basketball poi_basketball\n"481 " nsport=climbing poi_climbing\n"482 " nsport=golf poi_golf\n"483 " nsport=motor_sports poi_motor_sport\n"484 " nsport=skiing poi_skiing\n"485 " nsport=soccer poi_soccer\n"486 " nsport=stadium poi_stadium\n"487 " nsport=swimming poi_swimming\n"488 " nsport=tennis poi_tennis\n"489 " ntourism=attraction poi_attraction\n"490 " ntourism=camp_site poi_camp_rv\n"491 " ntourism=caravan_site poi_camp_rv\n"492 " ntourism=guest_house poi_guesthouse\n"493 " ntourism=hostel poi_hostel\n"494 " ntourism=hotel poi_hotel\n"495 " ntourism=information poi_information\n"496 " ntourism=motel poi_motel\n"497 " ntourism=museum poi_museum_history\n"498 " ntourism=picnic_site poi_picnic\n"499 " ntourism=theme_park poi_resort\n"500 " ntourism=viewpoint poi_viewpoint\n"501 " ntourism=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" 502 506 "n traffic_sign=city_limit traffic_sign_city_limit\n" 503 507 "n highway=speed_camera tec_common\n" 504 508 "w *=* street_unkn\n" … … 713 717 build_attrmap_line(char *line) 714 718 { 715 719 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*/; 718 722 t=line; 719 723 p=strchr(t,'\t'); 720 724 if (p) { … … 731 735 if (t[0] == 'w') { 732 736 if (! i) 733 737 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; 736 740 } else { 737 741 if (! i) 738 742 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; 741 745 } 742 746 attr_mapping->type=item_from_name(i); 743 747 while ((kv=strtok(kvl, ","))) { … … 750 754 attr_mapping->attr_present_idx[attr_mapping_count++]=idx; 751 755 attr_mapping->attr_present_idx_count=attr_mapping_count; 752 756 } 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 755 766 } 756 767 757 768 static void … … 1552 1563 } 1553 1564 item_bin_add_attr_string(item_bin, def_flags ? attr_street_name : attr_label, attr_strings[attr_string_label]); 1554 1565 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]); 1555 1573 item_bin_add_attr_longlong(item_bin, attr_osm_wayid, osmid_attr_value); 1556 1574 if (debug_attr_buffer[0]) 1557 1575 item_bin_add_attr_string(item_bin, attr_debug, debug_attr_buffer); -
navit/support/glib/fake.c
109 109 #endif 110 110 } 111 111 112 // FIXME: should use real utf8-aware function 113 gchar * g_utf8_casefold(const gchar *s, gssize len) 114 { 115 return g_ascii_strdown(s,len); 116 } -
navit/gui/internal/gui_internal.c
2240 2240 type_poi_peak+1, type_poi_motel-1, 2241 2241 type_poi_hostel+1,type_line-1, 2242 2242 type_none}}, 2243 {"unknown","Unknown",(enum item_type []){2243 /* {"unknown","Unknown",(enum item_type []){ 2244 2244 type_point_unkn,type_point_unkn, 2245 type_none}}, 2245 type_none}},*/ 2246 2246 }; 2247 2247 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 2253 static char * 2254 removecase(char *s) 2255 { 2256 char *r; 2257 r=g_utf8_casefold(s,-1); 2258 return r; 2259 } 2260 2261 struct 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 2253 2266 }; 2254 2267 2268 2269 /** 2270 * @brief Free poi_param structure. 2271 * 2272 * @param p reference to the object to be freed. 2273 */ 2274 static void 2275 gui_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 */ 2290 static struct poi_param * 2291 gui_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 2255 2308 static void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data); 2309 static void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data); 2256 2310 2311 2257 2312 static struct widget * 2258 2313 gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int pagenb) 2259 2314 { … … 2269 2324 nrows=nitems/wl->cols + (nitems%wl->cols>0); 2270 2325 wl->h=this->icon_l*nrows; 2271 2326 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; 2277 2334 gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL, 2278 2335 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)); 2280 2337 wb->c=*c; 2338 wb->data_free=gui_internal_poi_param_free; 2281 2339 wb->bt=10; 2282 2340 } 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 2283 2348 gui_internal_widget_pack(this,wl); 2284 2349 return wl; 2285 2350 } … … 2334 2399 } 2335 2400 2336 2401 static int 2337 gui_internal_cmd_pois_item_selected(struct selector *sel, enum item_type type)2402 gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item) 2338 2403 { 2339 2404 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) 2341 2410 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; 2348 2420 } 2349 types+=2;2350 2421 } 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; 2352 2465 } 2353 2466 2354 2467 struct item_data { … … 2372 2485 w->data=wm->data; 2373 2486 w->c=wm->c; 2374 2487 w->w=wm->w; 2488 wm->data_free=NULL; 2375 2489 gui_internal_back(this, NULL, NULL); 2376 gui_internal_cmd_pois(this, w, NULL);2490 gui_internal_cmd_pois(this, w, w->data); 2377 2491 free(w); 2378 2492 } 2379 2493 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 */ 2501 static void 2502 gui_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); 2380 2531 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 2381 2542 static void 2543 gui_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 */ 2564 static void 2565 gui_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 */ 2609 static void 2382 2610 gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data) 2383 2611 { 2384 2612 struct map_selection *sel,*selm; … … 2389 2617 struct item *item; 2390 2618 struct widget *wi,*w,*w2,*wb, *wtable, *row; 2391 2619 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; 2397 2626 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; 2400 2629 struct fibheap* fh = fh_makekeyheap(); 2401 2630 int cnt = 0; 2402 2631 struct table_data *td; 2403 2632 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); 2406 2652 2407 2653 wb=gui_internal_menu(this, isel ? isel->name : _("POIs")); 2408 2654 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill); 2409 2655 gui_internal_widget_append(wb, w); 2410 if (!isel )2656 if (!isel && !param->filter) 2411 2657 gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c,pagenb)); 2412 2658 w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill); 2413 2659 gui_internal_widget_append(w, w2); … … 2422 2668 dbg(2,"mr=%p\n", mr); 2423 2669 if (mr) { 2424 2670 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) && 2426 2672 item_coord_get_pro(item, &c, 1, pro) && 2427 2673 coord_rect_contains(&sel->u.c_rect, &c) && 2428 2674 (idist=transform_distance(pro, ¢er, &c)) < dist) { … … 2504 2750 // Add an entry for more POI 2505 2751 struct widget *wl,*wt; 2506 2752 char buffer[32]; 2753 struct poi_param *paramnew; 2754 paramnew=gui_internal_poi_param_clone(param); 2507 2755 wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill); 2508 2756 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); 2511 2759 } 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)); 2514 2762 } 2515 2763 wt=gui_internal_label_new(this, buffer); 2516 2764 gui_internal_widget_append(wl, wt); 2517 2765 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; 2519 2768 wl->state |= STATE_SENSITIVE; 2520 2769 wl->c = wm->c; 2521 2770 row = gui_internal_widget_table_row_new(this, … … 2537 2786 } 2538 2787 } 2539 2788 gui_internal_menu_render(this); 2540 2789 if(param_free) 2790 g_free(param); 2541 2791 } 2542 2792 #endif /* _MSC_VER */ 2543 2793 -
navit/search.c
428 428 { 429 429 struct pcoord *ret=g_new(struct pcoord, 1); 430 430 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) { 432 433 struct coord c; 433 434 if (item_coord_get(item, &c, 1)) { 434 435 ret->x=c.x; … … 472 473 dbg(1,"remaining distance=%d from %d\n",hn_distance,distances[i]); 473 474 ret->x=(c[i+1].x-c[i].x)*hn_distance/distances[i]+c[i].x; 474 475 ret->y=(c[i+1].y-c[i].y)*hn_distance/distances[i]+c[i].y; 476 g_free(distances); 475 477 } 478 g_free(c); 476 479 } 477 480 return ret; 478 481 } … … 772 775 this_->item=NULL; 773 776 break; 774 777 case 3: 775 dbg(0,"case 3 HOUSENUMBER"); 778 dbg(0,"case 3 HOUSENUMBER\n"); 779 has_street_name=0; 776 780 777 781 // if this housenumber has a streetname tag, set the name now 778 782 if (item_attr_get(this_->item, attr_street_name, &attr2)) … … 780 784 dbg(0,"streetname: %s\n",attr2.u.str); 781 785 has_street_name=1; 782 786 } 783 787 784 788 p=search_list_house_number_new(this_->item, &this_->inter, le->attr->u.str, le->partial); 785 789 if (!p) 786 790 { … … 788 792 this_->item=NULL; 789 793 continue; 790 794 } 795 791 796 this_->result.house_number=p; 792 797 if (!this_->result.house_number->interpolation) 793 798 { 794 799 this_->item=NULL; 800 } else { 801 dbg(0,"interpolation!\n"); 795 802 } 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 } 796 820 821 797 822 this_->result.house_number->common.parent=this_->levels[2].last->data; 798 823 this_->result.street=this_->result.house_number->common.parent; 799 824 this_->result.town=this_->result.street->common.parent; 800 825 this_->result.country=this_->result.town->common.parent; 801 826 this_->result.c=this_->result.house_number->common.c; 802 827 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; 808 831 } 809 else810 {811 this_->result.street->name=NULL;812 }813 832 } 814 833 if (p) 815 834 {
