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))
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))
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)
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)
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)