Пример #1
0
 def test_all_lon_in_point_one_increments(self):
     acc = 3
     random.seed(360)
     total_length = 0
     count = 0
     max = 0
     min = 999999
     for i in range (-1800,1800):
         count = count + 1
         test_lat = (random.random() * 180) - 90
         test_lon = i / 10
         geohexa = latlon_to_geohexa(test_lat, test_lon, accuracy=acc)
         if (len(geohexa) > max):
             max = len(geohexa)
         if (len(geohexa) < min):
             min = len(geohexa)
         lat, lon = geohexa_to_latlon(geohexa)
         error = distance(test_lat, test_lon, lat, lon)
         self.assertTrue (error < acc)
         total_length = total_length + len(geohexa)
     self.assertEqual (max, 10)
     print('\nTotal length of geohexa for all lon in 0.1 increments at', acc, 'meter accuracy:',total_length)
     print('Average length of geohexa:', total_length/count)
     print('Min length of geohexa:', min)
     print('Max length of geohexa:', max, '\n')
Пример #2
0
 def test_many_random_lat_lons_near_north_pole(self):
     random.seed(42)
     total_length = 0
     for i in range (0,MANY):
         test_lat = (random.random() * 10) + 80
         test_lon = (random.random() * 360) - 180
         geohexa = latlon_to_geohexa(test_lat, test_lon, accuracy=ACCURACY)
         lat, lon = geohexa_to_latlon(geohexa)
         error = distance(test_lat, test_lon, lat, lon)
         self.assertTrue (error < ACCURACY)
         total_length = total_length + len(geohexa)
     print('\nTotal length of geohexa for', MANY, 'random co-ordinates near the North Pole at', ACCURACY, 'meter accuracy:',total_length)
     print('Average length of geohexa:', total_length/MANY, '\n')
Пример #3
0
 def test_latlon_to_geohexa_and_back_accuracy_for_millimeter(self):
     test_lat, test_lon = -46.896522, 168.130336 # NZ Oyster Bar
     geohexa = latlon_to_geohexa(test_lat, test_lon, accuracy=MM)
     lat, lon = geohexa_to_latlon(geohexa)
     error = distance(test_lat, test_lon, lat, lon)
     self.assertTrue (error < MM)
Пример #4
0
 def test_latlon_to_geohexa_and_back_accuracy_for_meter(self):
     test_lat, test_lon = 64.123565, -21.805507 # Reykjavik Brewery
     geohexa = latlon_to_geohexa(test_lat, test_lon, accuracy=METER)
     lat, lon = geohexa_to_latlon(geohexa)
     error = distance(test_lat, test_lon, lat, lon)
     self.assertTrue (error < METER)
Пример #5
0
 def test_latlon_to_geohexa_and_back_accuracy_for_ten_km(self):
     test_lat, test_lon = 1.285864, 103.851831 # Singapore Boat Quay
     geohexa = latlon_to_geohexa(test_lat, test_lon, accuracy=TEN_KM)
     lat, lon = geohexa_to_latlon(geohexa)
     error = distance(test_lat, test_lon, lat, lon)
     self.assertTrue (error < TEN_KM)
Пример #6
0
 def test_distance_between_two_lat_lons(self):
     # from south to north of Vauxhall Bridge - approx 200 meters
     self.assertEqual( round(distance(51.487141, -0.125873, 51.488178, -0.128224), 8), 199.48427672)