Ejemplo n.º 1
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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 4
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'
)
Ejemplo n.º 5
0
import requests
import time
import haversine
from polyline_walker import PolylineWalker
URL = 'https://maps.googleapis.com/maps/api/directions/json?origin=Baar,CH&destination=Cham,CH&mode=walking'
a = PolylineWalker([x['polyline']['points'] for x in  requests.get(URL).json()['routes'][0]['legs'][0]['steps']], 2.5)
len(a.points)
while a.points:
    before = a.points[1:]
    now = a.walk()
    print(len(a.points), len(a.points))
    after = a.points[1:]
    print('Remaining ', haversine.haversine(a.points[1], now)*1000, ' m. on current polyline. ', len(a.points), ' polylines remaining.')
    print('Estimated completion time: ', (sum([haversine.haversine(*x)*1000 for x in a.walk_steps()]) / a.speed) , ' seconds.')
    if before != after:
        print('Changed polyline: ', a.polyline)
    time.sleep(1.5)