def test_split_lat_coordinate_7(self):
     value = '0.04567'
     n, a, b, c, d, e, f, g = GeoCoordinate.split_lat_coordinate(value)
     self.assertEqual(n, False)
     self.assertEqual(a, 0)
     self.assertEqual(b, 0)
     self.assertEqual(c, 0)
     self.assertEqual(d, 4)
     self.assertEqual(e, 5)
     self.assertEqual(f, 6)
     self.assertEqual(g, 7)
 def test_split_lat_coordinate_5(self):
     value = '-0.34567'
     n, a, b, c, d, e, f, g = GeoCoordinate.split_lat_coordinate(value)
     self.assertEqual(n, True)
     self.assertEqual(a, 0)
     self.assertEqual(b, 0)
     self.assertEqual(c, 3)
     self.assertEqual(d, 4)
     self.assertEqual(e, 5)
     self.assertEqual(f, 6)
     self.assertEqual(g, 7)
 def test_split_lat_coordinate_1(self):
     value = '12.34567'
     n, a, b, c, d, e, f, g = GeoCoordinate.split_lat_coordinate(value)
     self.assertEqual(n, False)
     self.assertEqual(a, 1)
     self.assertEqual(b, 2)
     self.assertEqual(c, 3)
     self.assertEqual(d, 4)
     self.assertEqual(e, 5)
     self.assertEqual(f, 6)
     self.assertEqual(g, 7)
 def test_split_lon_coordinate_1(self):
     value = '123.45678'
     n, a, b, c, d, e, f, g, h = GeoCoordinate.split_lon_coordinate(value)
     self.assertEqual(n, False)
     self.assertEqual(a, 1)
     self.assertEqual(b, 2)
     self.assertEqual(c, 3)
     self.assertEqual(d, 4)
     self.assertEqual(e, 5)
     self.assertEqual(f, 6)
     self.assertEqual(g, 7)
     self.assertEqual(h, 8)
 def test_split_lon_coordinate_6(self):
     value = '0.34567'
     n, a, b, c, d, e, f, g, h = GeoCoordinate.split_lon_coordinate(value)
     self.assertEqual(n, False)
     self.assertEqual(a, 0)
     self.assertEqual(b, 0)
     self.assertEqual(c, 0)
     self.assertEqual(d, 3)
     self.assertEqual(e, 4)
     self.assertEqual(f, 5)
     self.assertEqual(g, 6)
     self.assertEqual(h, 7)
 def test_split_lon_coordinate_5(self):
     value = '-3.45678'
     n, a, b, c, d, e, f, g, h = GeoCoordinate.split_lon_coordinate(value)
     self.assertEqual(n, True)
     self.assertEqual(a, 0)
     self.assertEqual(b, 0)
     self.assertEqual(c, 3)
     self.assertEqual(d, 4)
     self.assertEqual(e, 5)
     self.assertEqual(f, 6)
     self.assertEqual(g, 7)
     self.assertEqual(h, 8)
Пример #7
0
 def get_or_create_geocoordinate(self, lat, lon):
     lat_neg, lat_tens, lat_ones, lat_tenths, lat_hundredths, lat_thousands, lat_ten_thousands, other2 = GeoCoordinate.split_lat_coordinate(
         str(lat))
     lon_neg, lon_hundreds, lon_tens, lon_ones, lon_tenths, lon_hundredths, lon_thousands, lon_ten_thousands, other2 = GeoCoordinate.split_lon_coordinate(
         str(lon))
     coord = GeoCoordinate.objects.filter(
         lat_neg=lat_neg,
         lat_tens=lat_tens,
         lat_ones=lat_ones,
         lat_tenths=lat_tenths,
         lat_hundredths=lat_hundredths,
         lat_thousands=lat_thousands,
         lat_ten_thousands=lat_ten_thousands,
         lon_neg=lon_neg,
         lon_hundreds=lon_hundreds,
         lon_tens=lon_tens,
         lon_ones=lon_ones,
         lon_tenths=lon_tenths,
         lon_hundredths=lon_hundredths,
         lon_ten_thousands=lon_ten_thousands).first()
     if not coord:
         coord = GeoCoordinate()
         coord.lat = lat
         coord.lon = lon
         coord.save()
     return coord