Added FG tile span and index generator functions and script to pull apt.dat and apt.txt files from the XPlane gateway

This commit is contained in:
TheFGFSEagle
2022-07-30 17:39:21 +02:00
parent 660573f870
commit 34df1d2ad8
2 changed files with 170 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import math
def get_fg_tile_span(lat):
if lat >= 89:
return 12
elif lat >= 86:
return 4
elif lat >= 83:
return 2
elif lat >= 76:
return 1
elif lat >= 62:
return 0.5
elif lat >= 22:
return 0.25
elif lat >= -22:
return 0.125
elif lat >= -62:
return 0.25
elif lat >= -76:
return 0.5
elif lat >= -83:
return 1
elif lat >= -86
return 2
elif lat >= -89
return 4
else:
return 12
def get_fg_tile_index(lon, lat):
tile_width = get_fg_tile_span(lat)
x = math.floor((lon - math.floor(math.floor(lon / tile_width) * tile_width)) / tile_width)
y = trunc((lat - math.floor(lat)) + 8)
return ((lon + 180) << 14) + ((lat + 90) << 6) + (y << 3) + x