Changeset 672d01e


Ignore:
Timestamp:
08/09/11 14:27:57 (3 years ago)
Author:
xkolman2 <xkolman2@…>
Branches:
master
Children:
b4270b3
Parents:
63246b5
git-author:
xkolman2 <xkolman2@…> (08/09/11 14:27:57)
git-committer:
xkolman2 <xkolman2@…> (08/09/11 14:27:57)
Message:

add wikipedia search

git-svn-id: https://nlp.fi.muni.cz/svn/gps_navigace/trunk@533 0858a4d0-ffff-46e5-938e-62b5ecb34222

Location:
modules
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • modules/mod_menu.py

    rf9fd6cc r672d01e  
    651651    self.clearMenu('searchWhat') 
    652652    self.addItem('searchWhat', 'online#address', 'generic', 'search:searchAddress') 
     653    self.addItem('searchWhat', 'online#wikipedia', 'generic', 'search:searchWikipedia') 
    653654    self.addItem('searchWhat', 'online#presets', 'generic', 'set:menu:searchWhere') 
    654655 
  • modules/mod_onlineServices/geocoding.py

    rf9fd6cc r672d01e  
    99    print("geocoding exception:\n", e) 
    1010    return [] 
     11   
     12def wikipediaSearch(query): 
     13  from geopy import geocoders 
     14  wiki = geocoders.MediaWiki("http://wikipedia.org/wiki/%s", exactly_one=False) 
     15#  wiki = geocoders.MediaWiki("http://en.wikipedia.org/wiki/%s", exactly_one=False) 
     16#  wiki = geocoders.MediaWiki("http://en.wikipedia.org/wiki/Special:Search/%s", exactly_one=False) 
     17  return(wiki.geocode(query) ) 
  • modules/mod_onlineServices/mod_onlineServices.py

    rf9fd6cc r672d01e  
    252252    return geocoding.geocode(address) 
    253253 
     254  def wikipediaSearch(self, query): 
     255    return geocoding.wikipediaSearch(query) 
     256 
    254257  def stop(self): 
    255258    """called either after the worker thread finishes or after pressing the cacnel button""" 
  • modules/mod_search.py

    r63246b5 r672d01e  
    238238        entry.entryBox(self, 'address',description='Enter and address or location description', persistentKey="lastAddressSearchInput") 
    239239 
     240    elif message == "searchWikipedia": 
     241      # start text input for an address 
     242      entry = self.m.get('textEntry', None) 
     243      if entry: 
     244        entry.entryBox(self, 'wikipedia',description='Enter and address or location description', persistentKey="lastWikipediaSearchInput") 
     245 
    240246    elif message == "routeToActiveResult": 
    241247      """get a route from current position to active search result 
     
    646652          print("geocoding done - nothing found") 
    647653          self.sendMessage('ml:notification:m:No results found for this address.;5') 
     654    elif key == "wikipedia": 
     655      online = self.m.get('onlineServices') 
     656      textInput = result 
     657      if online: 
     658        # geocode the text input 
     659        results = online.geocode(textInput) 
     660        print("wikipedia search done - something found") 
     661        if results: 
     662          for r in results: 
     663            print(r) 
     664          place, (lat, lon) = results[0] 
     665          z = self.get('z', 15) 
     666          self.sendMessage('mapView:recentre %f %f %d|set:menu:None|ml:notification:m:%s;5' % (lat, lon, z, place)) 
     667        else: 
     668          print("wikipedia search done - nothing found") 
     669          self.sendMessage('ml:notification:m:No results found for this query.;5') 
    648670 
    649671      else: 
Note: See TracChangeset for help on using the changeset viewer.