Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the latitude and longitude to get the altitude from Google #2762

Closed
MZorzy opened this issue Aug 7, 2016 · 11 comments
Closed

Use the latitude and longitude to get the altitude from Google #2762

MZorzy opened this issue Aug 7, 2016 · 11 comments

Comments

@MZorzy
Copy link

MZorzy commented Aug 7, 2016

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?

@AcorpBG
Copy link
Contributor

AcorpBG commented Aug 7, 2016

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

@brantje
Copy link
Contributor

brantje commented Aug 7, 2016

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

@AcorpBG
Copy link
Contributor

AcorpBG commented Aug 7, 2016

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

@brantje
Copy link
Contributor

brantje commented Aug 7, 2016

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

@PeterTor
Copy link

PeterTor commented Aug 7, 2016

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

@mildfuzz
Copy link

mildfuzz commented Aug 8, 2016

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

@k4n30
Copy link
Contributor

k4n30 commented Aug 13, 2016

PokemonGo-Map's Solution

@k4n30 k4n30 changed the title altitude Use the latitude and longitude to get the altitude from Google Aug 13, 2016
@mildfuzz
Copy link

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

@jboffel
Copy link

jboffel commented Aug 17, 2016

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

@mjmadsen
Copy link
Contributor

mjmadsen commented Aug 17, 2016

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?

@oNIenSis
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants