Advertisement
hfreni

arrGen.py

May 14th, 2015
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 10.10 KB | None | 0 0
  1. #!/usr/bin/python
  2. import base64
  3. import json
  4. import requests
  5. import simplejson
  6.  
  7. POSITIONS = 99
  8. WIDTH = 2
  9.  
  10. def main():
  11.     data = '{"position0":{"incident":54.94205927287,"speed":10.3515625,"valid":true,"length":195.3976213},"position1":{"incident":54.801830981962,"speed":10.302734375,"valid":true,"length":193.983522005},"position2":{"incident":54.659847101335,"speed":10.25390625,"valid":true,"length":192.569424389},"position3":{"incident":54.443499959965,"speed":10.1806640625,"valid":true,"length":191.155328489},"position4":{"incident":54.222993806415,"speed":10.107421875,"valid":true,"length":189.741234342},"position5":{"incident":54.073613628308,"speed":10.05859375,"valid":true,"length":188.327141989},"position6":{"incident":53.922284890448,"speed":10.009765625,"valid":true,"length":186.913051469},"position7":{"incident":53.691545150827,"speed":9.9365234375,"valid":true,"length":185.498962826},"position8":{"incident":53.535156541413,"speed":9.8876953125,"valid":true,"length":184.084876102},"position9":{"incident":53.296615489001,"speed":9.814453125,"valid":true,"length":182.670791342},"position10":{"incident":53.134879449965,"speed":9.765625,"valid":true,"length":181.256708592},"position11":{"incident":52.970918378845,"speed":9.716796875,"valid":true,"length":179.842627899},"position12":{"incident":52.804680527201,"speed":9.66796875,"valid":true,"length":178.428549312},"position13":{"incident":52.55093707147,"speed":9.5947265625,"valid":true,"length":177.014472882},"position14":{"incident":52.378768669166,"speed":9.5458984375,"valid":true,"length":175.60039866},"position15":{"incident":52.115860559752,"speed":9.47265625,"valid":true,"length":174.186326701},"position16":{"incident":51.937395488996,"speed":9.423828125,"valid":true,"length":172.77225706},"position17":{"incident":51.756301541551,"speed":9.375,"valid":true,"length":171.358189794},"position18":{"incident":51.572512148302,"speed":9.326171875,"valid":true,"length":169.944124964},"position19":{"incident":51.291622133631,"speed":9.2529296875,"valid":true,"length":168.530062629},"position20":{"incident":51.100785724801,"speed":9.2041015625,"valid":true,"length":167.116002853},"position21":{"incident":50.808976105232,"speed":9.130859375,"valid":true,"length":165.701945703},"position22":{"incident":50.610616318251,"speed":9.08203125,"valid":true,"length":164.287891245},"position23":{"incident":50.409102814811,"speed":9.033203125,"valid":true,"length":162.87383955},"position24":{"incident":50.204347935418,"speed":8.984375,"valid":true,"length":161.45979069},"position25":{"incident":49.996260310734,"speed":8.935546875,"valid":true,"length":160.045744741},"position26":{"incident":49.677670400258,"speed":8.8623046875,"valid":true,"length":158.63170178},"position27":{"incident":49.460824876128,"speed":8.8134765625,"valid":true,"length":157.217661888},"position28":{"incident":49.240294405997,"speed":8.7646484375,"valid":true,"length":155.803625149},"position29":{"incident":48.902345429714,"speed":8.69140625,"valid":true,"length":154.389591649},"position30":{"incident":48.672106164797,"speed":8.642578125,"valid":true,"length":152.975561478},"position31":{"incident":48.437770854192,"speed":8.59375,"valid":true,"length":151.56153473},"position32":{"incident":48.199209388899,"speed":8.544921875,"valid":true,"length":150.1475115},"position33":{"incident":47.956285376589,"speed":8.49609375,"valid":true,"length":148.733491889},"position34":{"incident":47.708855734573,"speed":8.447265625,"valid":true,"length":147.319476002},"position35":{"incident":47.328932558376,"speed":8.3740234375,"valid":true,"length":145.905463947},"position36":{"incident":47.069564879353,"speed":8.3251953125,"valid":true,"length":144.491455836},"position37":{"incident":46.805131402687,"speed":8.2763671875,"valid":true,"length":143.077451786},"position38":{"incident":46.535452933988,"speed":8.2275390625,"valid":true,"length":141.663451919},"position39":{"incident":46.260340661454,"speed":8.1787109375,"valid":true,"length":140.249456361},"position40":{"incident":45.837045289478,"speed":8.10546875,"valid":true,"length":138.835465244},"position41":{"incident":45.547452925692,"speed":8.056640625,"valid":true,"length":137.421478706},"position42":{"incident":45.251679603173,"speed":8.0078125,"valid":true,"length":136.007496888},"position43":{"incident":44.949483696167,"speed":7.958984375,"valid":true,"length":134.593519939},"position44":{"incident":44.640609268916,"speed":7.91015625,"valid":true,"length":133.179548016},"position45":{"incident":44.324784937149,"speed":7.861328125,"valid":true,"length":131.765581278},"position46":{"incident":44.001722614531,"speed":7.8125,"valid":true,"length":130.351619896},"position47":{"incident":43.671116129726,"speed":7.763671875,"valid":true,"length":128.937664046},"position48":{"incident":43.332639697577,"speed":7.71484375,"valid":true,"length":127.523713911},"position49":{"incident":42.985946225352,"speed":7.666015625,"valid":true,"length":126.109769683},"position50":{"incident":42.630665431975,"speed":7.6171875,"valid":true,"length":124.695831565},"position51":{"incident":42.266401754608,"speed":7.568359375,"valid":true,"length":123.281899765},"position52":{"incident":41.892732012649,"speed":7.51953125,"valid":true,"length":121.867974504},"position53":{"incident":41.509202794105,"speed":7.470703125,"valid":true,"length":120.454056011},"position54":{"incident":41.115327523103,"speed":7.421875,"valid":true,"length":119.04014453},"position55":{"incident":40.710583159867,"speed":7.373046875,"valid":true,"length":117.626240311},"position56":{"incident":40.294406475354,"speed":7.32421875,"valid":true,"length":116.21234362},"position57":{"incident":39.866189831662,"speed":7.275390625,"valid":true,"length":114.798454735},"position58":{"incident":39.425276385588,"speed":7.2265625,"valid":true,"length":113.384573949},"position59":{"incident":38.970954615794,"speed":7.177734375,"valid":true,"length":111.970701568},"position60":{"incident":38.502452052858,"speed":7.12890625,"valid":true,"length":110.556837914},"position61":{"incident":38.018928064945,"speed":7.080078125,"valid":true,"length":109.142983327},"position62":{"incident":37.51946551824,"speed":7.03125,"valid":true,"length":107.729138164},"position63":{"incident":37.003061088399,"speed":6.982421875,"valid":true,"length":106.315302801},"position64":{"incident":36.468613944154,"speed":6.93359375,"valid":true,"length":104.901477633},"position65":{"incident":35.914912452584,"speed":6.884765625,"valid":true,"length":103.487663079},"position66":{"incident":35.340618461644,"speed":6.8359375,"valid":true,"length":102.07385958},"position67":{"incident":34.744248591024,"speed":6.787109375,"valid":true,"length":100.660067602},"position68":{"incident":34.124151795415,"speed":6.73828125,"valid":true,"length":99.2462876365},"position69":{"incident":33.478482237388,"speed":6.689453125,"valid":true,"length":97.8325202048},"position70":{"incident":33.145419589161,"speed":6.6650390625,"valid":true,"length":96.4187658582},"position71":{"incident":32.45742055077,"speed":6.6162109375,"valid":true,"length":95.0050251809},"position72":{"incident":31.738145320296,"speed":6.5673828125,"valid":true,"length":93.5912987922},"position73":{"incident":30.984749349497,"speed":6.5185546875,"valid":true,"length":92.1775873497},"position74":{"incident":30.193966308803,"speed":6.4697265625,"valid":true,"length":90.7638915518},"position75":{"incident":29.783396233688,"speed":6.4453125,"valid":true,"length":89.3502121409},"position76":{"incident":28.929249848783,"speed":6.396484375,"valid":true,"length":87.9365499074},"position77":{"incident":28.02702151091,"speed":6.34765625,"valid":true,"length":86.5229056933},"position78":{"incident":27.071017350675,"speed":6.298828125,"valid":true,"length":85.1092803966},"position79":{"incident":26.570761820584,"speed":6.2744140625,"valid":true,"length":83.6956749756},"position80":{"incident":25.520783143701,"speed":6.2255859375,"valid":true,"length":82.2820904548},"position81":{"incident":24.685372889974,"speed":6.18896484375,"valid":true,"length":80.8685279303},"position82":{"incident":23.803630307568,"speed":6.15234375,"valid":true,"length":79.454988576},"position83":{"incident":22.545739028147,"speed":6.103515625,"valid":true,"length":78.041473651},"position84":{"incident":21.876745779194,"speed":6.0791015625,"valid":true,"length":76.6279845071},"position85":{"incident":20.445023051035,"speed":6.0302734375,"valid":true,"length":75.2145225978},"position86":{"incident":19.675301798404,"speed":6.005859375,"valid":true,"length":73.801089488},"position87":{"incident":18.440677327883,"speed":5.96923828125,"valid":true,"length":72.3876868647},"position88":{"incident":17.091415080802,"speed":5.9326171875,"valid":true,"length":70.9743165492},"position89":{"incident":16.114264513506,"speed":5.908203125,"valid":true,"length":69.5609805108},"position90":{"incident":15.061287332976,"speed":5.8837890625,"valid":true,"length":68.1476808822},"position91":{"incident":13.301040200109,"speed":5.84716796875,"valid":true,"length":66.7344199767},"position92":{"incident":11.967057888073,"speed":5.82275390625,"valid":true,"length":65.3212003076},"position93":{"incident":10.450175103492,"speed":5.79833984375,"valid":true,"length":63.9080246105},"position94":{"incident":8.6583310967448,"speed":5.77392578125,"valid":true,"length":62.4948958685},"position95":{"incident":7.602000174069,"speed":5.76171875,"valid":true,"length":61.0818173405},"position96":{"incident":5.6585349158604,"speed":5.743408203125,"valid":true,"length":59.668792594},"position97":{"incident":3.8600831006074,"speed":5.731201171875,"valid":true,"length":58.2558255423},"position98":{"incident":2.5295141585662,"speed":5.72509765625,"valid":true,"length":56.8429204881},"position99":{"incident":0.29459238435469,"speed":5.7205200195312,"valid":true,"length":55.4300821722}}'
  12.     j = json.loads(data)
  13.     json_string = json.dumps(j,sort_keys=True,indent=2)
  14.     print 'long posSPDGraph[' + str(POSITIONS) + '] [' + str(WIDTH) + '] = {'
  15.     for y in range(0, 99):
  16.         parent = j['position' + str(y)]
  17.         if y == 99:
  18.             print '{' + str(parent['length']) + ',' + str(parent['speed']) + '}'
  19.         else:
  20.             print '{' + str(parent['length']) + ',' + str(parent['speed']) + '},'
  21.     print '};'
  22. if __name__ == "__main__":
  23.    main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement