Skip to content

Commit

Permalink
Merge pull request #4789 from kanemasa1987/poly_alt
Browse files Browse the repository at this point in the history
Polyline altitude
  • Loading branch information
solderzzc authored Aug 27, 2016
2 parents fa2025f + fb9b1cd commit 5c97022
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 3 additions & 5 deletions pokemongo_bot/cell_workers/follow_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ def load_gpx(self):
def find_closest_point_idx(self, points):
return_idx = 0
min_distance = float("inf");

for index in range(len(points)):
point = points[index]
botlat = self.bot.api._position_lat
botlng = self.bot.api._position_lng
botlat, botlng, _ = self.bot.api.get_position()
lat = point['lat']
lng = point['lng']

Expand Down Expand Up @@ -142,9 +142,7 @@ def work(self):
if self.status == STATUS_LOITERING and time.time() < self.loiter_end_time:
return WorkerResult.SUCCESS

last_lat = self.bot.api._position_lat
last_lng = self.bot.api._position_lng
last_alt = self.bot.api._position_alt
last_lat, last_lng, last_alt = self.bot.api.get_position()

point = self.points[self.ptr]
lat = point['lat']
Expand Down
13 changes: 8 additions & 5 deletions pokemongo_bot/walkers/polyline_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class PolylineWalker(StepWalker):

def __init__(self, bot, dest_lat, dest_lng):
super(PolylineWalker, self).__init__(bot, dest_lat, dest_lng)
self.polyline_walker = PolylineObjectHandler.cached_polyline(tuple(self.api.get_position()[:2]),
(self.destLat, self.destLng), self.speed)

self.actual_pos = tuple(self.api.get_position()[:2])

self.dist = distance(
self.bot.position[0],
Expand All @@ -26,7 +26,8 @@ def __init__(self, bot, dest_lat, dest_lng):
)

def step(self):
cLat, cLng = self.api._position_lat, self.api._position_lng
self.polyline_walker = PolylineObjectHandler.cached_polyline(self.actual_pos,
(self.destLat, self.destLng), self.speed)

if self.dist < 10: # 10m, add config? set it at constants?
return True
Expand All @@ -36,8 +37,10 @@ def step(self):
self.polyline_walker.pause()

cLat, cLng = self.polyline_walker.get_pos()
alt = uniform(self.bot.config.alt_min, self.bot.config.alt_max)
self.api.set_position(cLat, cLng, alt)
cAlt = self.polyline_walker.get_alt()
self.api.set_position(cLat, cLng, cAlt)
self.actual_pos = (cLat, cLng) # might be a case this instance is reused in the future...

self.bot.heartbeat()
return False

0 comments on commit 5c97022

Please sign in to comment.