Coverage for pyguymer3/openstreetmap/deg2num.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 deg2num( 

5 lon_deg, 

6 lat_deg, 

7 zoom, 

8 /, 

9): 

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

11 

12 # Import standard modules ... 

13 import math 

14 

15 lat_rad = math.radians(lat_deg) 

16 n = pow(2, zoom) 

17 xtile = int((lon_deg + 180.0) / 360.0 * n) 

18 ytile = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n) 

19 

20 # Return answer ... 

21 return xtile, ytile