def test_get_coord_one(self): """Test get coordinate from tile method.""" merc = Mercator() z = x = y = 0 mx, my = merc.get_coord(z, x, y) mx = merc.truncate(mx) my = merc.truncate(my) assert float(mx) == -20037508.34 and \ float(my) == -20037508.34
def test_tile_to_meters_one(self): """Test conversion from tile coordinate to meters.""" merc = Mercator() z = x = y = 0 mx, my = merc.tile_to_meters(z, x, y) mx = merc.truncate(mx) my = merc.truncate(my) assert float(mx) == -20037508.34 and \ float(my) == -20037508.34
def test_tile_to_meters_two(self): """Test conversion with a different tile coord to meters.""" merc = Mercator() z = 0 x = y = 1 mx, my = merc.tile_to_meters(z, x, y) mx = merc.truncate(mx) my = merc.truncate(my) assert float(mx) == 20037508.34 and \ float(my) == 20037508.34
def test_get_coord_two(self): """Test get coord with a random tile.""" merc = Mercator() z = 14 x = 11332 y = 9870 mx, my = merc.get_coord(z, x, y) mx = merc.truncate(mx) my = merc.truncate(my) assert float(mx) == 7680392.60 and \ float(my) == 4104362.67
def test_tile_to_meters_four(self): """Test another corner of a random tile to meters.""" merc = Mercator() z = 14 x = 11333 y = 9871 mx, my = merc.tile_to_meters(z, x, y) mx = merc.truncate(mx) my = merc.truncate(my) assert float(mx) == 7682838.58 and \ float(my) == 4106808.65
def test_tile_to_meters_three(self): """Test a random tile to meters.""" merc = Mercator() z = 14 x = 11332 y = 9870 mx, my = merc.tile_to_meters(z, x, y) mx = merc.truncate(mx) my = merc.truncate(my) assert float(mx) == 7680392.60 and \ float(my) == 4104362.67
def test_truncate(self): """Test mercator accuracy truncation.""" merc = Mercator() f = 1234.567890123 result = merc.truncate(f) assert float(result) == 1234.56