-
-
Save th0ma5w/c0c8e11cae493d1cf206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json, datetime | |
from dateutil import parser | |
#https://th0ma5w.github.io/Cesium/Apps/CesiumViewer/index.html?source=/Cesium/Apps/CesiumViewer/Gallery/complete_solo.czml&lookAt=Aircraft/N566FD | |
document= { | |
"id":"document", | |
"name":"complete_solo", | |
"clock":{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"currentTime":"2014-05-26T18:49:51-04:00", | |
"multiplier":10, | |
"range":"LOOP_STOP", | |
"step":"SYSTEM_CLOCK_MULTIPLIER" | |
} | |
} | |
plane = { | |
"id": "Aircraft/N566FD", | |
"name": "N566FD", | |
"availability":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"billboard":{ | |
"color":[ | |
{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"rgba":[ | |
255,255,0,255 | |
] | |
} | |
], | |
"eyeOffset":{ | |
"cartesian":[ | |
0,0,0 | |
] | |
}, | |
"horizontalOrigin":"CENTER", | |
"image":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAA/SURBVChTlctJDgAgCARB//9ptBM0cQGZOmmYbi82+LOGAP7NzaEc4BudAzlAGEUHOcB1y8aQA6xNZYwtqDPrPNWDfZ+6CooAAAAASUVORK5CYIIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", | |
"pixelOffset":{ | |
"cartesian2":[ | |
0,0 | |
] | |
}, | |
"scale":1, | |
"show":[ | |
{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"boolean":True | |
} | |
], | |
"verticalOrigin":"CENTER" | |
}, | |
"label":{ | |
"fillColor":[ | |
{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"rgba":[ | |
255,255,0,255 | |
] | |
} | |
], | |
"font":"bold 21pt Lucida Console", | |
"horizontalOrigin":"LEFT", | |
"outlineColor":{ | |
"rgba":[ | |
0,0,0,255 | |
] | |
}, | |
"outlineWidth":2, | |
"scale":0.5, | |
"show":[ | |
{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"boolean":True | |
} | |
], | |
"style":"FILL_AND_OUTLINE", | |
"text":"N566FD", | |
"verticalOrigin":"CENTER" | |
}, | |
"position": { | |
#"interpolationAlgorithm":"LAGRANGE", | |
#"interpolationDegree":3, | |
"cartographicDegrees":[] | |
}, | |
"path":{ | |
"color":[ | |
{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"rgba":[ | |
255,0,255,255 | |
] | |
} | |
], | |
"width":[ | |
{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"number":2 | |
} | |
], | |
"resolution":600, | |
"show":[ | |
{ | |
"interval":"2014-05-26T18:49:51-04:00/2014-05-26T19:38:17-04:00", | |
"boolean":True | |
} | |
] | |
} | |
} | |
infile = "complete_solo_out.csv" | |
with open(infile) as f: | |
filecontents=f.read() | |
lines=filecontents.split('\n')[1:] | |
data = [x.strip().split(',') for x in lines] | |
clean_data=[] | |
for d in data[:-1]: | |
lat=float(d[1]) | |
lon=float(d[2]) | |
alt=float(d[4])-35 | |
date=d[5] | |
time=d[6].split(".")[0] | |
ds=date+ " " +time+" EDT" | |
dt=parser.parse(ds) | |
iso=dt.isoformat() | |
clean_data.append([lat,lon,alt,iso]) | |
data=clean_data | |
adddatum = lambda x: plane['position']['cartographicDegrees'].append(x) | |
for d in data: | |
adddatum(d[3]) | |
adddatum(d[1]) | |
adddatum(d[0]) | |
adddatum(d[2]) | |
czml=[document,plane] | |
f=open('complete_solo.czml','wb') | |
f.write(json.dumps(czml,indent=True)) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment