PokemonGo-Bot icon indicating copy to clipboard operation
PokemonGo-Bot copied to clipboard

Use the latitude and longitude to get the altitude from Google

Open MZorzy opened this issue 10 years ago • 11 comments

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?

MZorzy avatar Aug 07 '16 11:08 MZorzy

Would be great to implement the altitude in the followpath there is altitude data in gpsies <ele>580.00000</ele>

AcorpBG avatar Aug 07 '16 11:08 AcorpBG

Something like this: https://www.daftlogic.com/sandbox-google-maps-find-altitude.htm would be better. It fetches the altitude of a given point.

brantje avatar Aug 07 '16 11:08 brantje

Google altitude api is 2500 uses. Runing a bot will use that in no time.

AcorpBG avatar Aug 07 '16 11:08 AcorpBG

Didn't seen that, maybe we can use another source?

brantje avatar Aug 07 '16 11:08 brantje

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

PeterTor avatar Aug 07 '16 12:08 PeterTor

The google api is a day rate, we could cache two points and gradually morph as we move between them

mildfuzz avatar Aug 08 '16 11:08 mildfuzz

Does this solution just ignore the rate limit? Interpolating between points would be better, no?

mildfuzz avatar Aug 13 '16 14:08 mildfuzz

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...

jboffel avatar Aug 17 '16 01:08 jboffel

Related #2762, #3621, #3808, #4114. It will probably take me more time to write than some of our more skilled devs.

  1. Add a wrapper for api.set_position in api wrapper (parameters: long/lat)
  2. Swap all calls to api.set_position with new wrapper
  3. 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?

mjmadsen avatar Aug 17 '16 14:08 mjmadsen

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.

oNIenSis avatar Aug 18 '16 00:08 oNIenSis