コード例 #1
0
ファイル: test_point.py プロジェクト: kif/pycaching
    def test_from_tile(self):
        """Test coordinate creation from tile"""
        p = Point.from_tile(8800, 5574, 14)
        p_pos = Point(49.752879934150215, 13.359375, 0.0)
        p2 = Point.from_tile(x=8801, y=5575, z=14)
        p_half = Point.from_tile(8800, 5574, 14, 1, 1, 2)

        # Check creation
        for att in ['latitude', 'longitude']:
            with self.subTest("Assumed location: {}".format(att)):
                self.assertAlmostEqual(getattr(p, att), getattr(p_pos, att))

        with self.subTest("Fractional tiles: y-axis addition"):
            self.assertEqual(Point.from_tile(8800, 5574, 14, 0, 32, 32),
                             Point.from_tile(x=8800, y=5575, z=14))
        with self.subTest("Fractional tiles: x-axis addition"):
            self.assertAlmostEqual(Point.from_tile(8800, 5574, 14, 32, 0, 32),
                                   Point.from_tile(x=8801, y=5574, z=14))
        with self.subTest("Fractional tiles: addition on both axes"):
            self.assertEqual(Point.from_tile(8800, 5574, 14, 32, 32, 32), p2)

        with self.subTest("y increases -> latitude decreases"):
            self.assertGreater(p.latitude, p_half.latitude)
        with self.subTest("x increases -> latitude increases"):
            self.assertLess(p.longitude, p_half.longitude)
コード例 #2
0
ファイル: test_point.py プロジェクト: kumy/pycaching
    def test_from_tile(self):
        """Test coordinate creation from tile"""
        p = Point.from_tile(8800, 5574, 14)
        p_pos = Point(49.752879934150215, 13.359375, 0.0)
        p2 = Point.from_tile(x=8801, y=5575, z=14)
        p_half = Point.from_tile(8800, 5574, 14, 1, 1, 2)

        # Check creation
        for att in ['latitude', 'longitude']:
            with self.subTest("Assumed location: {}".format(att)):
                self.assertAlmostEqual(getattr(p, att), getattr(p_pos, att))

        with self.subTest("Fractional tiles: y-axis addition"):
            self.assertEqual(Point.from_tile(8800, 5574, 14, 0, 32, 32),
                             Point.from_tile(x=8800, y=5575, z=14))
        with self.subTest("Fractional tiles: x-axis addition"):
            self.assertAlmostEqual(Point.from_tile(8800, 5574, 14, 32, 0, 32),
                                   Point.from_tile(x=8801, y=5574, z=14))
        with self.subTest("Fractional tiles: addition on both axes"):
            self.assertEqual(Point.from_tile(8800, 5574, 14, 32, 32, 32), p2)

        with self.subTest("y increases -> latitude decreases"):
            self.assertGreater(p.latitude, p_half.latitude)
        with self.subTest("x increases -> latitude increases"):
            self.assertLess(p.longitude, p_half.longitude)
コード例 #3
0
ファイル: test_point.py プロジェクト: kif/pycaching
    def test_to_map_tile(self):
        t = (8800, 5574, 14)
        point_in_t = Point(49.75, 13.36)

        with self.subTest("From tile and back"):
            self.assertEqual(Point.from_tile(*t).to_map_tile(t[-1]), t)

        with self.subTest("Random point"):
            self.assertEqual(point_in_t.to_map_tile(14), t)

        with self.subTest("Increase in latitude: decrease in y value"):
            self.assertLess(Point(50., 13.36).to_map_tile(14)[1], t[1])

        with self.subTest("Increase in longitude: increase in x value"):
            self.assertGreater(Point(49.75, 14.).to_map_tile(14)[0], t[0])
コード例 #4
0
ファイル: test_point.py プロジェクト: kumy/pycaching
    def test_to_map_tile(self):
        t = (8800, 5574, 14)
        point_in_t = Point(49.75, 13.36)

        with self.subTest("From tile and back"):
            self.assertEqual(Point.from_tile(*t).to_map_tile(t[-1]), t)

        with self.subTest("Random point"):
            self.assertEqual(point_in_t.to_map_tile(14), t)

        with self.subTest("Increase in latitude: decrease in y value"):
            self.assertLess(Point(50., 13.36).to_map_tile(14)[1], t[1])

        with self.subTest("Increase in longitude: increase in x value"):
            self.assertGreater(Point(49.75, 14.).to_map_tile(14)[0], t[0])