def test_value_can_be_retrieved_via_vector_in_tile0_center(self): m = GreyCubeMap(width=1536, height=1024) m.set_xy((255, 255), 127.8) m.set_xy((255, 256), 127.8) m.set_xy((256, 256), 127.8) m.set_xy((256, 255), 127.8) v = m.v_from_vector((1, 0, 0)) self.assertAlmostEqual(127.8, v, 5)
def test_vector_from_xy_returns_approximately_correct_value_in_tile3(self): m = GreyCubeMap(width=1536, height=1024) vec = m.vector_from_xy((256, 768)) self.assertTrue(-0.01 < vec.x < 0.01) self.assertGreater(vec.y, 0.99) self.assertTrue(-0.01 < vec.z < 0.01)
def test_vector_from_xy_returns_approximately_correct_value_in_tile2(self): m = GreyCubeMap(width=1536, height=1024) vec = m.vector_from_xy((1280, 256)) self.assertLess(vec.x, -0.99) self.assertTrue(-0.01 < vec.y < 0.01, vec.y) self.assertTrue(-0.01 < vec.z < 0.01, vec.z)
def test_tile_from_lat_lon_returns_correctly_center_tile_5(self): m = GreyCubeMap(width=1536, height=1024) i = m.tile_from_lat_lon((radians(-80), -radians(-40))).cube_face self.assertEqual(5, i)
def test_tile_from_lat_lon_returns_correctly_near_center_tile_4(self): m = GreyCubeMap(width=1536, height=1024) i = m.tile_from_lat_lon((radians(85), radians(0))).cube_face self.assertEqual(4, i)
def test_tile_from_lat_lon_returns_correctly_near_tile_5_edge(self): m = GreyCubeMap(width=1536, height=1024) i = m.tile_from_lat_lon((radians(40), -radians(50))).cube_face self.assertEqual(4, i)
def test_tile_from_xy_returns_correctly5(self): m = GreyCubeMap(width=1536, height=1024) i = m.tile_from_xy((1535, 1023)) self.assertEqual(5, i.cube_face)
def test_tile_from_xy_returns_correctly3(self): m = GreyCubeMap(width=1536, height=1024) i = m.tile_from_xy((0, 512)) self.assertEqual(3, i.cube_face)
def test_reference_positions_returns_correct_value_for_tile5(self): cm = GreyCubeMap(width=1536, height=1024) m = cm.get_tile(5) ref_pos = m.reference_position self.assertEqual(1024, ref_pos[0]) self.assertEqual(512, ref_pos[1])
def test_value_can_be_stored_and_retrieved_in_tile0_up_right(self): m = GreyCubeMap(width=1536, height=1024) m.set_xy((500, 510), 127.8) v = m.v_from_xy((500, 510)) self.assertAlmostEqual(127.8, v, 5)
def test_cube_is_instantiated_with_correct_height(self): m = GreyCubeMap(width=1536, height=1024) self.assertEqual(1024, m.height)
def test_xy_from_vector_returns_approximately_correct_tile0_center(self): m = GreyCubeMap(width=1536, height=1024) p = m.xy_from_vector(Vector((1, 0, 0))) self.assertAlmostEqual(255.5, p[0], 2) self.assertAlmostEqual(255.5, p[1], 2)
def test_values_are_blended_between_stored_values_in_array2(self): m = GreyCubeMap(width=1536, height=1024) m.set_xy((255, 255), 2) m.set_xy((256, 255), 3) self.assertAlmostEqual(2.75, m.v_from_xy((255.75, 255)), 5)