def _walk_to(self, speed, lat, lng, alt):
     origin = ",".join([str(self.api._position_lat), str(self.api._position_lng)])
     destination = ",".join([str(lat), str(lng)])
     polyline_walker = PolylineWalker(origin, destination, self.speed)
     proposed_origin = polyline_walker.points[0]
     proposed_destination = polyline_walker.points[-1]
     proposed_lat = proposed_origin[0]
     proposed_lng = proposed_origin[1]
     if proposed_lat != lat and proposed_lng != lng:
         self._old_walk_to(speed, proposed_lat, proposed_lng, alt)
     while proposed_destination != polyline_walker.get_pos()[0]:
         cLat, cLng = polyline_walker.get_pos()[0]
         self.api.set_position(cLat, cLng, alt)
         self.bot.heartbeat()
         self._work_at_position(i2f(self.api._position_lat), i2f(self.api._position_lng), alt, False)
         sleep(1)  # sleep one second plus a random delta
     if proposed_lat != self.api._position_lat and proposed_lng != self.api._position_lng:
         self._old_walk_to(speed, lat, lng, alt)
示例#2
0
 def _walk_to(self, speed, lat, lng, alt):
     origin = ','.join([str(self.api._position_lat), str(self.api._position_lng)])
     destination = ','.join([str(lat), str(lng)])
     polyline_walker = PolylineWalker(origin, destination, self.speed)
     proposed_origin = polyline_walker.points[0]
     proposed_destination = polyline_walker.points[-1]
     proposed_lat = proposed_origin[0]
     proposed_lng = proposed_origin[1]
     if proposed_lat != lat and proposed_lng != lng:
         self._old_walk_to(speed, proposed_lat, proposed_lng, alt)
     while proposed_destination != polyline_walker.get_pos()[0]:
         cLat, cLng = polyline_walker.get_pos()[0]
         self.api.set_position(cLat, cLng, alt)
         self.bot.heartbeat()
         self._work_at_position(i2f(self.api._position_lat), i2f(self.api._position_lng), alt, False)
         sleep(1)  # sleep one second plus a random delta
     if proposed_lat != self.api._position_lat and proposed_lng != self.api._position_lng:
         self._old_walk_to(speed, lat, lng, alt)
示例#3
0
import time
import haversine
import polyline
from math import ceil
from polyline_walker import PolylineWalker
a = PolylineWalker('Poststrasse+20,Zug,CH', 'Guggiweg+7,Zug,CH', 100)
print('Walking polyline: ', a.polyline)
print('Encoded level: ','B'*len(a.points))
print('Initialted with speed: ', a.speed, 'm/s')
print('Walking time: ', ceil(sum([haversine.haversine(*x)*1000/a.speed for x in a.walk_steps()])), ' sec.')
generated_polyline = []
while a.points[-1] != a.get_pos()[0]:
    pos = a.get_pos()
    generated_polyline += pos
    print(pos)
    time.sleep(0.1)
else:
    print("We have reached our destination.")
print(polyline.encode(generated_polyline))
print('Encoded level: ','B'*len(generated_polyline))
print('Verify at: ', 'https://developers.google.com/maps/documentation/utilities/polylineutility')
import time
import haversine
import polyline
from math import ceil
from polyline_walker import PolylineWalker
a = PolylineWalker('Poststrasse+20,Zug,CH', 'Guggiweg+7,Zug,CH', 100)
print('Walking polyline: ', a.polyline)
print('Encoded level: ', 'B' * len(a.points))
print('Initialted with speed: ', a.speed, 'm/s')
print(
    'Walking time: ',
    ceil(
        sum([haversine.haversine(*x) * 1000 / a.speed
             for x in a.walk_steps()])), ' sec.')
generated_polyline = []
while a.points[-1] != a.get_pos()[0]:
    pos = a.get_pos()
    generated_polyline += pos
    print(pos)
    time.sleep(0.1)
else:
    print("We have reached our destination.")
print(polyline.encode(generated_polyline))
print('Encoded level: ', 'B' * len(generated_polyline))
print(
    'Verify at: ',
    'https://developers.google.com/maps/documentation/utilities/polylineutility'
)