Completed camera control server in lua and more work on merging algorithm

This commit is contained in:
Pax1601
2024-02-28 18:58:40 +01:00
parent 05e0cc393a
commit 832568aa00
14 changed files with 403 additions and 65 deletions

View File

@@ -0,0 +1,37 @@
import sys
from fastkml import kml
from pygeoif.geometry import Polygon
import json
import math
# constants
C = 40075016.686 # meters, Earth equatorial circumference
R = C / (2 * math.pi) # meters, Earth equatorial radius
W = 10000 # meters, size of the square around the airbase
if len(sys.argv) == 1:
print("Please provide a json file as first argument. You can also drop the json file on this script to run it.")
else:
input_file = sys.argv[1]
k = kml.KML()
ns = '{http://www.opengis.net/kml/2.2}'
d = kml.Document(ns, 'docid', 'doc name', 'doc description')
k.append(d)
with open(input_file) as jp:
j = json.load(jp)
for point in j['airbases'].values():
p = kml.Placemark(ns, 'id', 'name', 'description')
lat = point['latitude']
lng = point['longitude']
latDelta = math.degrees(W / R)
lngDelta = math.degrees(W / (R * math.cos(math.radians(lat))))
p.geometry = Polygon([(lng - lngDelta, lat - latDelta), (lng - lngDelta, lat + latDelta), (lng + lngDelta, lat + latDelta), (lng + lngDelta, lat - latDelta)])
d.append(p)
with open(input_file.removesuffix('.json')+'.kml', 'w') as kp:
kp.writelines(k.to_string(prettyprint=True))