Switched Geocoding library to OpenStreetMap's Nominatim API. Closes #390

This commit is contained in:
Manuel Cortez 2021-08-26 08:56:51 -05:00
parent f4ecf10885
commit 3d8519313e
3 changed files with 10 additions and 12 deletions

View File

@ -9,6 +9,7 @@
* There are some changes to the autocomplete users feature:
* Now users can search for twitter screen names or display names in the database.
* It is possible to undefine keystrokes in the current keymap in TWBlue. This allows you, for example, to redefine keystrokes completely.
* We have changed our Geocoding service to the Nominatim API from OpenStreetMap. Addresses present in tweets are going to be determined by this service, as the Google Maps API now requires an API key. ([#390](https://github.com/manuelcortez/TWBlue/issues/390))
* Added a limited version of the Twitter's Streaming API: The Streaming API will work only for tweets, and will receive tweets only by people you follow. Protected users are not possible to be streamed. It is possible that during high tweet traffic, the Stream might get disconnected at times, but TWBlue should be capable of detecting this problem and reconnecting the stream again. ([#385](https://github.com/manuelcortez/TWBlue/pull/385))
* Fixed an issue that made TWBlue to not show a dialog when attempting to show a profile for a suspended user. ([#387](https://github.com/manuelcortez/TWBlue/issues/387))
* Added support for Twitter audio and videos: Tweets which contains audio or videos will be detected as audio items, and you can playback those with the regular command to play audios. ([#384,](https://github.com/manuelcortez/TWBlue/pull/384))

View File

@ -9,7 +9,7 @@ oauthlib
requests-oauthlib
requests-toolbelt
pypubsub
pygeocoder
geopy
arrow
python-dateutil
futures

View File

@ -35,17 +35,16 @@ from mysc.repeating_timer import RepeatingTimer
from mysc import restart
import config
import widgetUtils
import pygeocoder
from pygeolib import GeocoderError
import logging
import webbrowser
from geopy.geocoders import Nominatim
from mysc import localization
import os
import languageHandler
log = logging.getLogger("mainController")
geocoder = pygeocoder.Geocoder()
geocoder = Nominatim(user_agent="TWBlue")
class Controller(object):
@ -1001,19 +1000,17 @@ class Controller(object):
if tweet.coordinates != None:
x = tweet.coordinates["coordinates"][0]
y = tweet.coordinates["coordinates"][1]
address = geocoder.reverse_geocode(y, x, language = languageHandler.curLang)
if event == None: output.speak(address[0].__str__())
else: self.view.show_address(address[0].__str__())
address = geocoder.reverse("{}, {}".format(y, x), language = languageHandler.curLang)
if event == None: output.speak(address.address)
else: self.view.show_address(address.address)
else:
output.speak(_(u"There are no coordinates in this tweet"))
except GeocoderError:
output.speak(_(u"There are no results for the coordinates in this tweet"))
except ValueError:
output.speak(_(u"Error decoding coordinates. Try again later."))
except KeyError:
pass
# except KeyError:
# pass
except AttributeError:
pass
output.speak(_("Unable to find address in OpenStreetMap."))
def view_reverse_geocode(self, event=None):
try: