Skip to content

Commit

Permalink
Fixed args PolylineWalker to match the super StepWalker class (#1621)
Browse files Browse the repository at this point in the history
* * Removed pokemongo_bot/polyline_stepper.py - old Stepper() class
* Fixed args PolylineWalker to match the super StepWalker class
* Added a check to Polynine() point tinitalization, if no route was
  found then, we will return no points between orig, dest thus will
  walk in straight line - expected behaviour will teleport in small
  steps

* * fix typo
  • Loading branch information
th3w4y authored and douglascamata committed Jul 29, 2016
1 parent c548334 commit dfa4f78
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 47 deletions.
40 changes: 0 additions & 40 deletions pokemongo_bot/polyline_stepper.py

This file was deleted.

8 changes: 6 additions & 2 deletions pokemongo_bot/walkers/polyline_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ def __init__(self, origin, destination, speed):
self.URL = '{}&origin={}&destination={}'.format(self.DISTANCE_API_URL,
'{},{}'.format(*self.origin),
'{},{}'.format(*self.destination))
self.polyline_points = [x['polyline']['points'] for x in
requests.get(self.URL).json()['routes'][0]['legs'][0]['steps']]
self.request_responce = requests.get(self.URL).json()
try:
self.polyline_points = [x['polyline']['points'] for x in
self.request_responce['routes'][0]['legs'][0]['steps']]
except IndexError:
self.polyline_points = self.request_responce['routes']
self.speed = float(speed)
self.points = [self.origin] + self.get_points(self.polyline_points) + [self.destination]
self.lat, self.long = self.points[0][0], self.points[0][1]
Expand Down
8 changes: 3 additions & 5 deletions pokemongo_bot/walkers/polyline_walker.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# -*- coding: utf-8 -*-
from polyline_generator import Polyline
from math import ceil
from pokemongo_bot.human_behaviour import sleep
from pokemongo_bot.cell_workers.utils import i2f
from pokemongo_bot.step_walker import StepWalker
from pokemongo_bot import logger

class PolylineWalker(StepWalker):

def __init__(self, bot, speed, initLat, initLng, destLat, destLng):
super(PolylineWalker, self).__init__(bot, speed, initLat, initLng, destLat, destLng)
self.polyline_walker = Polyline((i2f(self.api._position_lat), i2f(self.api._position_lng)),
def __init__(self, bot, speed, destLat, destLng):
super(PolylineWalker, self).__init__(bot, speed, destLat, destLng)
self.polyline_walker = Polyline((self.api._position_lat, self.api._position_lng),
(self.destLat, self.destLng), self.speed)
logger.log('[#] {}'.format(self.polyline_walker.URL))

Expand Down

0 comments on commit dfa4f78

Please sign in to comment.