Coverage for pyguymer3/openstreetmap/num2deg.py: 14%

7 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-08 18:47 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def num2deg( 

5 xtile, 

6 ytile, 

7 zoom, 

8 /, 

9): 

10 """ 

11 This function returns the NW corner of the tile. 

12 """ 

13 

14 # NOTE: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Python 

15 

16 # Import standard modules ... 

17 import math 

18 

19 n = pow(2, zoom) 

20 lon_deg = xtile / n * 360.0 - 180.0 # [°] 

21 lat_rad = math.atan(math.sinh(math.pi * (1.0 - 2.0 * ytile / n))) 

22 lat_deg = math.degrees(lat_rad) # [°] 

23 

24 # Return answer ... 

25 return lon_deg, lat_deg