Use the latitude and longitude to get the altitude from Google
look is time to remove zero 'altitude' here&there and check position
exemple: step_walkwe.py line 41 set alt to zero ? other
https://github.com/PokemonGoF/PokemonGo-Bot/search?utf8=%E2%9C%93&q=position and set alt in config?
Would be great to implement the altitude in the followpath there is altitude data in gpsies <ele>580.00000</ele>
Something like this: https://www.daftlogic.com/sandbox-google-maps-find-altitude.htm would be better. It fetches the altitude of a given point.
Google altitude api is 2500 uses. Runing a bot will use that in no time.
Didn't seen that, maybe we can use another source?
you could calculate an reference ellipsoid like wgs84 for your current lat/long and approximate the altitude. For example http://geographiclib.sourceforge.net/cgi-bin/GeoidEval
The google api is a day rate, we could cache two points and gradually morph as we move between them
Does this solution just ignore the rate limit? Interpolating between points would be better, no?
I may suggest something like that in: PokemonGo-Bot\pokemongo_bot__init__.py
import googlemaps
class PokemonGoBot(object):
@property
def position(self):
logger = logging.getLogger('AltitudeFaker')
logger.setLevel(logging.INFO)
# logger.info('Start to capture altitude for current location!')
alt = 0
if self.alt_cache.has_key((self.api._position_lat, self.api._position_lng)):
alt = self.alt_cache[(self.api._position_lat, self.api._position_lng)]
else:
# logger.info('Not in cache yet')
try:
gmaps = googlemaps.Client(key=self.config.gmapkey)
# logger.info('Got client')
alt = gmaps.elevation((self.api._position_lat, self.api._position_lng))
# logger.info('Got response')
alt = alt[0]['elevation']
# logger.info('Show response: {}'.format(alt))
self.alt_cache[(self.api._position_lat, self.api._position_lng)] = alt
except IOError as e:
logger.info('Cannot get alt: %s' % e)
alt = 0
# logger.info('Current lng: {}, lat: {} then alt: {}'.format(self.api._position_lat, self.api._position_lng, alt))
return self.api._position_lat, self.api._position_lng, alt
.....
I didn't take a close look at everything in the code but it was looking like a central place to retrieve current bot position to be used as input for most of the call.
But I guess there are some place in the code where the returned alt value was ignored and or overwritten eventually...
Related #2762, #3621, #3808, #4114. It will probably take me more time to write than some of our more skilled devs.
- Add a wrapper for api.set_position in api wrapper (parameters: long/lat)
- Swap all calls to api.set_position with new wrapper
- Use geocoder to fetch altitide from long/lat using something similar to below:
import geocoder g = geocoder.google([long, lat], method='elevation') alt = g.meters
Send api.set_position with altitude
(Source https://geocoder.readthedocs.io/providers/Google.html#elevation)
Has anyone looked at the response on the app if alt is in m or km?
Paths created by gpsies already have altitude for every position on the path. Would be good to implement this in two steps - one to send the altitude to the api using data already at hand (when using a path) or a default, and secondly to populate the altitude if it's not already known using a geocoder.