def destination_location_test(): dist = 0.25 rotchild12 = Location(32.06279, 34.77048) #we choose 0 as angle to cancel the angular distance dest = GeoService.get_destination_location(rotchild12, dist, 0) calc_dist = GeoService.get_distance(rotchild12, dest) assert int(dist * 1000) == int(calc_dist * 1000)
def simple_distance_test(): """ simple air distance test between 2 locations """ rotchild12 = Location(32.06279, 34.77048) habima = Location(32.0721, 34.7790) dist = GeoService.get_distance(rotchild12, habima) meters_dist = int(dist * 1000) print(meters_dist) assert meters_dist == 1310
#dist = GeoService.get_distance(loc1, loc2) #new_location = GeoService.get_destination_location(loc1, 0.2, 30) #new_lat = GeoService.get_destination_location2(loc1, 0.2, 30) #print("original location is: %s" % repr(loc1)) #print("new location is: %s" % repr(new_location)) #print("new lat is: %f" % new_lat) print repr(loc1) angle = 45 bearing = 270 speed = 10 first_time = True sleep_interval = 1000 / 1000 new_location = Location(0,0,0) start_time = datetime.datetime.now() while first_time or new_location.alt > 0: first_time = False current_time = datetime.datetime.now() td = current_time - start_time new_location = GeoService.get_object_current_location(loc1, angle, bearing, speed, td.total_seconds()) print("object location after %f seconds: %s" % (td.total_seconds(),repr(new_location))) print("\n") sleep(sleep_interval)