Esempio n. 1
0
 def test_z_speed(self):
     n = 100000
     tests = (
         ('wgs2gcj',
          lambda: eviltransform.wgs2gcj(TESTS[0][0], TESTS[0][1])),
         ('gcj2wgs',
          lambda: eviltransform.gcj2wgs(TESTS[0][0], TESTS[0][1])),
         ('gcj2wgs_exact',
          lambda: eviltransform.gcj2wgs_exact(TESTS[0][0], TESTS[0][1])),
         ('distance', lambda: eviltransform.distance(*TESTS[0])))
     print('\n' + '=' * 30)
     for name, func in tests:
         sec = timeit.timeit(func, number=n)
         print('%s\t%.2f ns/op' % (name, sec * 1e9 / n))
Esempio n. 2
0
 def test_z_speed(self):
     n = 100000
     tests = (
         ('wgs2gcj',
             lambda: eviltransform.wgs2gcj(TESTS[0][0], TESTS[0][1])),
         ('gcj2wgs',
             lambda: eviltransform.gcj2wgs(TESTS[0][0], TESTS[0][1])),
         ('gcj2wgs_exact',
             lambda: eviltransform.gcj2wgs_exact(TESTS[0][0], TESTS[0][1])),
         ('distance', lambda: eviltransform.distance(*TESTS[0]))
     )
     print('\n' + '='*30)
     for name, func in tests:
         sec = timeit.timeit(func, number=n)
         print('%s\t%.2f ns/op' % (name, sec * 1e9 / n))
Esempio n. 3
0
 def test_gcj2wgs_exact(self):
     for wgsLat, wgsLng, gcjLat, gcjLng in TESTS:
         ret = eviltransform.gcj2wgs_exact(gcjLat, gcjLng)
         self.assertLess(
             eviltransform.distance(ret[0], ret[1], wgsLat, wgsLng), .5)
Esempio n. 4
0
 def test_gcj2wgs_exact(self):
     for wgsLat, wgsLng, gcjLat, gcjLng in TESTS:
         ret = eviltransform.gcj2wgs_exact(gcjLat, gcjLng)
         self.assertLess(eviltransform.distance(
             ret[0], ret[1], wgsLat, wgsLng), .5)
Esempio n. 5
0
 def compute_distance(latitude_1, longitude_1, latitude_2, longitude_2):
     # the unit of distance is meter.
     distance = eviltransform.distance(latitude_1, longitude_1, latitude_2,
                                       longitude_2)
     return int(distance)