Commit 8a6f13af authored by p x's avatar p x
Browse files

车辆位姿http SSE

parent 427e3530
{"rs":[[116.50238005214746,39.81014469509955],[116.50236486876796,39.81013731694055],[116.50234968537274,39.81012993879976],[116.50233450197756,39.8101225606582],[116.50231931858238,39.81011518251584],[116.5023041333868,39.81010780655952],[116.50229565547512,39.81010368888862],[116.50228036234131,39.810096445719445],[116.50226506920752,39.8100892025495],[116.50224985746125,39.81008185923798],[116.50223467091115,39.81007448492373],[116.5022194843611,39.81006711060869],[116.502204297811,39.81005973629286],[116.50218911126096,39.81005236197624],[116.50217392471086,39.81004498765881],[116.50215873816082,39.810037613340604],[116.50214354204267,39.81003025071994],[116.50212940967664,39.81002347155654],[116.50211414052076,39.810016198589445],[116.50209895321649,39.81000882529198],[116.50208377514453,39.8100014406772],[116.5020685970726,39.809994056061605],[116.50205341900066,39.80998667144523],[116.50203824092873,39.809979286828046],[116.50202306285678,39.80997190221008],[116.50200788607032,39.80996451603342],[116.50199271461229,39.809957123398306],[116.50197175150723,39.80994690865124],[116.5019565677659,39.809939530910334],[116.50194138402462,39.809932153168646],[116.5019261959587,39.80992478068344],[116.50191100349002,39.809917413549634],[116.50189579233196,39.809910069682026],[116.50188040671078,39.80990294300845],[116.50186502108963,39.80989581633414],[116.50184281562053,39.80988553068078],[116.50182802471463,39.809877696172016],[116.50181322516318,39.80986987170683],[116.50179804843465,39.80986248544798],[116.50178280602617,39.80985518091484],[116.50176075352947,39.80984499368132],[116.50174177475655,39.809835769889],[116.5017274954714,39.80982739397197],[116.50171740536683,39.80981635635335],[116.50171295482671,39.809803030251885],[116.50171301661533,39.80978929564729],[116.50171746496443,39.80977596765635],[116.5017259444861,39.8097638114287],[116.5017379185738,39.80974819470519],[116.50174729851142,39.80973642369948],[116.50175667844906,39.80972465269176],[116.50176605838669,39.80971288168202],[116.50177543832429,39.809701110670275],[116.50178481826192,39.8096893396565],[116.50179419819955,39.80967756864072],[116.50180357813717,39.809665797622905],[116.5018129580748,39.8096540266031],[116.50182233801245,39.80964225558127],[116.50183171795007,39.80963048455742],[116.50184109788769,39.809618713531556],[116.5018504778253,39.80960694250368],[116.50185985776292,39.80959517147379],[116.50186923770057,39.80958340044187],[116.5018786176382,39.80957162940795],[116.50188799757582,39.80955985837201],[116.50189737751344,39.80954808733406],[116.50190675745107,39.80953631629408],[116.50191613738868,39.8095245452521],[116.5019255173263,39.80951277420809],[116.50193493157849,39.80950101936984],[116.50194437236506,39.80948927706254],[116.50195381315163,39.80947753475324],[116.5019632539382,39.80946579244194],[116.50197269472476,39.809454050128615],[116.50198213551133,39.809442307813306],[116.5019915762979,39.80943056549599],[116.50200101708447,39.80941882317666],[116.50201045787104,39.809407080855316],[116.50201989865761,39.809395338531964],[116.50202933944418,39.80938359620662],[116.50203878023075,39.80937185387928],[116.50204822101732,39.809360111549914],[116.50205766180389,39.809348369218554],[116.50206710259046,39.809336626885184],[116.50207654337703,39.80932488454981],[116.50208598416357,39.809313142212424],[116.50209542495014,39.80930139987304],[116.50210499804051,39.809289720982065],[116.50211458612095,39.80927804927806],[116.50212417420141,39.80926637757208],[116.50213376228183,39.80925470586412],[116.50214335036227,39.809243034154164],[116.50215293844273,39.80923136244224],[116.50216252652316,39.809219690728334],[116.5021721146036,39.809208019012445],[116.50218170268406,39.809196347294574],[116.5021912907645,39.80918467557471],[116.50220087884492,39.80917300385288],[116.50221046692533,39.80916133212906],[116.50222194778321,39.80914735629438],[116.50223079042868,39.80913537219419],[116.50224437375732,39.80912656561062],[116.5022616599528,39.80912330256496],[116.50227897733187,39.809126399012214],[116.50229461795695,39.80913317723447],[116.50231015045868,39.80914011342922],[116.5023256829604,39.80914704962326],[116.50234121546217,39.80915398581661],[116.50235709967029,39.80916040951712],[116.50237406319151,39.80916484398448],[116.50239187097037,39.80916636876694],[116.50240970211905,39.80916504764615],[116.50242686120255,39.80916110814383],[116.50244272398614,39.809154696622954],[116.50245637374258,39.80914577271494],[116.50246747881728,39.809134975672535],[116.50247697374292,39.80912326014347],[116.50248632266518,39.80911147447951],[116.5024956715874,39.80909968881352],[116.50250735122155,39.80908496494592],[116.50251677946527,39.80907321662218],[116.50252620770894,39.80906146829645],[116.50253563595264,39.8090497199687],[116.50254394816011,39.809039362307594]]}
\ No newline at end of file
{
"rs": [
[
116.50238005214746,
39.81014469509955,
237.6829820703691
],
[
116.50236486876796,
39.81013731694055,
237.68307561987575
],
[
116.50234968537274,
39.81012993879976,
237.6830756097038
],
[
116.50233450197756,
39.8101225606582,
237.68307554373752
],
[
116.50231931858238,
39.81011518251584,
237.6938174827698
],
[
116.5023041333868,
39.81010780655952,
237.69591515912174
],
[
116.50229565547512,
39.81010368888862,
238.3437364798304
],
[
116.50228036234131,
39.810096445719445,
238.3437364455466
],
[
116.50226506920752,
39.8100892025495,
237.85362814526735
],
[
116.50224985746125,
39.81008185923798,
237.70190041312034
],
[
116.50223467091115,
39.81007448492373,
237.70190034557228
],
[
116.5022194843611,
39.81006711060869,
237.70190039564733
],
[
116.502204297811,
39.81005973629286,
237.70190033926013
],
[
116.50218911126096,
39.81005236197624,
237.70190040049607
],
[
116.50217392471086,
39.81004498765881,
237.7019002784291
],
[
116.50215873816082,
39.810037613340604,
237.75925608043258
],
[
116.50214354204267,
39.81003025071994,
238.01696949712567
],
[
116.50212940967664,
39.81002347155654,
238.19833426358676
],
[
116.50211414052076,
39.810016198589445,
237.70677835452744
],
[
116.50209895321649,
39.81000882529198,
237.65133473173375
],
[
116.50208377514453,
39.8100014406772,
237.65133465944604
],
[
116.5020685970726,
39.809994056061605,
237.65133467519559
],
[
116.50205341900066,
39.80998667144523,
237.6513346240156
],
[
116.50203824092873,
39.809979286828046,
237.65133466207467
],
[
116.50202306285678,
39.80997190221008,
237.6436772388487
],
[
116.50200788607032,
39.80996451603342,
237.61193653625492
],
[
116.50199271461229,
39.809957123398306,
237.61193837906546
],
[
116.50197175150723,
39.80994690865124,
237.6851403015522
],
[
116.5019565677659,
39.809939530910334,
237.68514031338162
],
[
116.50194138402462,
39.809932153168646,
237.71095815409723
],
[
116.5019261959587,
39.80992478068344,
237.73724224420545
],
[
116.50191100349002,
39.809917413549634,
237.85073976040232
],
[
116.50189579233196,
39.809910069682026,
238.91028611911815
],
[
116.50188040671078,
39.80990294300845,
238.91028614503145
],
[
116.50186502108963,
39.80989581633414,
238.9102882886388
],
[
116.50184281562053,
39.80988553068078,
235.4122851196367
],
[
116.50182802471463,
39.809877696172016,
235.4622667362538
],
[
116.50181322516318,
39.80986987170683,
237.64332857152914
],
[
116.50179804843465,
39.80986248544798,
238.0420609398446
],
[
116.50178280602617,
39.80985518091484,
238.97871780698017
],
[
116.50176075352947,
39.80984499368132,
237.6794114813822
],
[
116.50174177475655,
39.809835769889,
232.6346154985382
],
[
116.5017274954714,
39.80982739397197,
215.07770889258606
],
[
116.50171740536683,
39.80981635635335,
194.38881781174774
],
[
116.50171295482671,
39.809803030251885,
179.80199650469456
],
[
116.50171301661533,
39.80978929564729,
165.61992089690648
],
[
116.50171746496443,
39.80977596765635,
151.81596405333198
],
[
116.5017259444861,
39.8097638114287,
149.50207750396544
],
[
116.5017379185738,
39.80974819470519,
148.52778764862148
],
[
116.50174729851142,
39.80973642369948,
148.52778758147338
],
[
116.50175667844906,
39.80972465269176,
148.52778759732007
],
[
116.50176605838669,
39.80971288168202,
148.52778770332623
],
[
116.50177543832429,
39.809701110670275,
148.52778767064717
],
[
116.50178481826192,
39.8096893396565,
148.5277876382395
],
[
116.50179419819955,
39.80967756864072,
148.5277876954492
],
[
116.50180357813717,
39.809665797622905,
148.52778762857406
],
[
116.5018129580748,
39.8096540266031,
148.5277875821091
],
[
116.50182233801245,
39.80964225558127,
148.5277876671654
],
[
116.50183171795007,
39.80963048455742,
148.5277876347593
],
[
116.50184109788769,
39.809618713531556,
148.52778765750259
],
[
116.5018504778253,
39.80960694250368,
148.52778763199086
],
[
116.50185985776292,
39.80959517147379,
148.5277875993147
],
[
116.50186923770057,
39.80958340044187,
148.52778766369175
],
[
116.5018786176382,
39.80957162940795,
148.52778763818105
],
[
116.50188799757582,
39.80955985837201,
148.52778764713867
],
[
116.50189737751344,
39.80954808733406,
148.5277876767775
],
[
116.50190675745107,
39.80953631629408,
148.5277876236933
],
[
116.50191613738868,
39.8095245452521,
148.52778768090718
],
[
116.5019255173263,
39.80951277420809,
148.3993248448242
],
[
116.50193493157849,
39.80950101936984,
148.299988529318
],
[
116.50194437236506,
39.80948927706254,
148.29998850427387
],
[
116.50195381315163,
39.80947753475324,
148.2999884310068
],
[
116.5019632539382,
39.80946579244194,
148.29998861342312
],
[
116.50197269472476,
39.809454050128615,
148.2999884846501
],
[
116.50198213551133,
39.809442307813306,
148.29998850123724
],
[
116.5019915762979,
39.80943056549599,
148.29998851782466
],
[
116.50200101708447,
39.80941882317666,
148.29998852747417
],
[
116.50201045787104,
39.809407080855316,
148.2999885371239
],
[
116.50201989865761,
39.809395338531964,
148.29998850514414
],
[
116.50202933944418,
39.80938359620662,
148.29998849397964
],
[
116.50203878023075,
39.80937185387928,
148.29998852444533
],
[
116.50204822101732,
39.809360111549914,
148.2999885063432
],
[
116.50205766180389,
39.809348369218554,
148.29998851599464
],
[
116.50206710259046,
39.809336626885184,
148.29998851870812
],
[
116.50207654337703,
39.80932488454981,
148.29998858352178
],
[
116.50208598416357,
39.809313142212424,
148.29998851025937
],
[
116.50209542495014,
39.80930139987304,
147.80258536886106
],
[
116.50210499804051,
39.809289720982065,
147.74623006383433
],
[
116.50211458612095,
39.80927804927806,
147.74623007056869
],
[
116.50212417420141,
39.80926637757208,
147.7462301177402
],
[
116.50213376228183,
39.80925470586412,
147.74623008403853
],
[
116.50214335036227,
39.809243034154164,
147.74623006258776
],
[
116.50215293844273,
39.80923136244224,
147.7462300552304
],
[
116.50216252652316,
39.809219690728334,
147.7462301446825
],
[
116.5021721146036,
39.809208019012445,
147.74623004051665
],
[
116.50218170268406,
39.809196347294574,
147.74623007543954
],
[
116.5021912907645,
39.80918467557471,
147.746230143753
],
[
116.50220087884492,
39.80917300385288,
147.7462301293507
],
[
116.50221046692533,
39.80916133212906,
147.7462294387051
],
[
116.50222194778321,
39.80914735629438,
150.45482594530847
],
[
116.50223079042868,
39.80913537219419,
130.16403373831827
],
[
116.50224437375732,
39.80912656561062,
103.80579695054894
],
[
116.5022616599528,
39.80912330256496,
76.89685891576113
],
[
116.50227897733187,
39.809126399012214,
60.570293126005936
],
[
116.50229461795695,
39.80913317723447,
59.829656142251
],
[
116.50231015045868,
39.80914011342922,
59.82965618751763
],
[
116.5023256829604,
39.80914704962326,
59.829656193658195
],
[
116.50234121546217,
39.80915398581661,
62.23549249524524
],
[
116.50235709967029,
39.80916040951712,
71.2065606517699
],
[
116.50237406319151,
39.80916484398448,
83.63983258266211
],
[
116.50239187097037,
39.80916636876694,
95.50909787603081
],
[
116.50240970211905,
39.80916504764615,
106.6398691894982
],
[
116.50242686120255,
39.80916110814383,
117.75155381771447
],
[
116.50244272398614,
39.809154696622954,
130.40018165667937
],
[
116.50245637374258,
39.80914577271494,
141.68783579051768
],
[
116.50246747881728,
39.809134975672535,
148.09452716931543
],
[
116.50247697374292,
39.80912326014347,
148.64368608711084
],
[
116.50248632266518,
39.80911147447951,
148.64368616831428
],
[
116.5024956715874,
39.80909968881352,
148.64368534784933
],
[
116.50250735122155,
39.80908496494592,
148.34699064777806
],
[
116.50251677946527,
39.80907321662218,
148.3469906874264
],
[
116.50252620770894,
39.80906146829645,
148.34699065821923
],
[
116.50253563595264,
39.8090497199687,
148.3469909977715
],
[
116.50254394816011,
39.809039362307594,
148.3469909977715
]
]
}
\ No newline at end of file
import json
import math
def calculate_heading(lat1, lon1, lat2, lon2):
"""
计算两点之间的航向角
返回角度值(0-360度)
"""
# 将经纬度从度转换为弧度
lat1 = math.radians(lat1)
lon1 = math.radians(lon1)
lat2 = math.radians(lat2)
lon2 = math.radians(lon2)
# 计算经度差
dLon = lon2 - lon1
# 使用反正切函数计算航向角
y = math.sin(dLon) * math.cos(lat2)
x = math.cos(lat1) * math.sin(lat2) - math.sin(lat1) * math.cos(lat2) * math.cos(dLon)
bearing = math.atan2(y, x)
# 将弧度转换为度数
bearing = math.degrees(bearing)
# 确保结果在0-360度范围内
bearing = (bearing + 360) % 360
return bearing
def process_gps_data_with_headings(input_data):
"""
处理GPS数据,为每个点添加航向角
"""
processed_data = []
points = input_data["rs"]
for i in range(len(points)):
lon, lat = points[i][0], points[i][1] # 数据中是[lon, lat]格式
if i == len(points) - 1:
# 最后一个点没有下一个点,使用前一个点的方向
if i > 0:
prev_lon, prev_lat = points[i-1][0], points[i-1][1]
heading = calculate_heading(prev_lat, prev_lon, lat, lon)
else:
# 只有一个点的情况,设为0度
heading = 0
else:
# 计算到下一个点的航向角
next_lon, next_lat = points[i+1][0], points[i+1][1]
heading = calculate_heading(lat, lon, next_lat, next_lon)
processed_data.append([lon, lat, heading])
# 创建新的数据结构
result = {"rs": processed_data}
return result
# 新的GPS数据(从Car_fangzhen_call.txt获取)
new_original_data = {
"rs": [
[116.5024625,39.8090317],[116.50246452571352,39.809032676237166],[116.50246655142706,39.80903365247434],[116.5024685771406,39.80903462871151],[116.50247060285415,39.80903560494868],[116.50247262856767,39.80903658118585],[116.50247465428123,39.809037557423025],[116.50247667999476,39.80903853366019],[116.5024787057083,39.80903950989737],[116.50248073142184,39.809040486134535],[116.50248275713537,39.80904146237171],[116.50248478284891,39.80904243860888],[116.50248554937339,39.80904280015562],[116.50248625256704,39.8090431183115],[116.50248696285315,39.809043426953984],[116.50248768001542,39.80904372598901],[116.50248840383534,39.80904401532554],[116.50248913409246,39.80904429487541],[116.50248987056432,39.80904456455347],[116.50249061302658,39.809044824277564],[116.50249136125309,39.80904507396862],[116.50249211501594,39.809045313550534],[116.5024928740855,39.809045542950344],[116.50249363823058,39.809045762098165],[116.50249440721838,39.80904597092725],[116.50249518081468,39.809046169374014],[116.50249595878384,39.80904635737795],[116.50249674088887,39.80904653488182],[116.50249752689155,39.80904670183156],[116.50249831655243,39.809046858176316],[116.50249910963099,39.80904700386845],[116.50249990588564,39.8090471388636],[116.50250070507383,39.80904726312063],[116.50250150695214,39.8090473766017],[116.50250231127629,39.80904747927224],[116.50250311780128,39.809047571100976],[116.50250392628145,39.80904765205992],[116.5025047364705,39.80904772212444],[116.50250554812165,39.80904778127317],[116.50250636098767,39.8090478294881],[116.50250717482095,39.809047866754554],[116.50250798937358,39.80904789306116],[116.50250880439745,39.80904790839994],[116.50250961964429,39.809047912766175],[116.50251043486577,39.80904790615856],[116.50251124981355,39.809047888579094],[116.50251206423943,39.80904786003317],[116.50251287789527,39.80904782052943],[116.50251369053326,39.80904777007994],[116.50251450190586,39.80904770870008],[116.5025153117659,39.80904763640851],[116.50251611986671,39.80904755322727],[116.50251692596213,39.8090474591817],[116.5025177298066,39.809047354300446],[116.50251853115527,39.80904723861545],[116.50251932976404,39.80904711216196],[116.50252012538965,39.80904697497849],[116.50252091778974,39.80904682710682],[116.50252170672294,39.80904666859201],[116.50252249194894,39.80904649948232],[116.50252327322852,39.80904631982929],[116.50252405032373,39.80904612968762],[116.50252482299786,39.809045929115264],[116.50252559101551,39.809045718173266],[116.50252635414277,39.80904549692593],[116.50252711214716,39.80904526544063],[116.50252786479781,39.80904502378788],[116.50252861186543,39.80904477204128],[116.50252935312245,39.80904451027753],[116.50253008834312,39.80904423857637],[116.50253081730344,39.80904395702054],[116.50253153978137,39.80904366569581],[116.50253225555686,39.80904336469095],[116.50253296441184,39.80904305409761],[116.50253366613042,39.80904273401042],[116.50253436049884,39.80904240452689],[116.50253504730557,39.80904206574736],[116.50253572634142,39.809041717775045],[116.50253639739954,39.80904136071593],[116.50253706027554,39.80904099467878],[116.50253771476747,39.8090406197751],[116.50253836067598,39.809040236119095],[116.50253899780434,39.80903984382761],[116.50253962595843,39.80903944302016],[116.50254024494696,39.809039033818834],[116.50254085458133,39.809038616348246],[116.50254145467586,39.80903819073561],[116.50254204504778,39.80903775711055],[116.50254262551721,39.80903731560515],[116.50254319590738,39.80903686635389],[116.5025437560445,39.80903640949364],[116.502544305758,39.809035945163544],[116.50254484488038,39.80903547350505],[116.50254537324744,39.809034994661815],[116.50254589069823,39.80903450877972],[116.50254639707514,39.80903401600677],[116.5025468922239,39.80903351649306],[116.50254873251244,39.80903121870854],[116.50255048525985,39.80902903906369],[116.50255215519805,39.809026971172585],[116.50255374705901,39.80902500864927],[116.50255526557463,39.809023145107844],[116.50255671547697,39.80902137416238],[116.50255810149788,39.80901968942692],[116.50255942836942,39.80901808451557],[116.5025607008234,39.80901655304239],[116.50256192359191,39.80901508862146],[116.50256310140682,39.80901368486684],[116.50256423900012,39.8090123353926],[116.50256534110378,39.80901103381284],[116.50256641244967,39.80900977374158],[116.50256745776986,39.809008548792946],[116.50256848179617,39.80900735258098],[116.50256948926067,39.80900617871975],[116.50257048489526,39.80900502082334],[116.50257147343187,39.809003872505826],[116.50257245960252,39.80900272738129],[116.50257344813913,39.809001579063775],[116.50257444377361,39.80900042116737],[116.50257545123799,39.80899924730615],[116.50257647526416,39.80899805109418],[116.50257752058411,39.80899682614553],[116.50257859192976,39.80899556607427],[116.5025796940331,39.808994264494494],[116.50258083162609,39.808992915020255],[116.50258200944063,39.80899151126563],[116.50258323220868,39.808990046844684],[116.50258450466227,39.808988515371496],[116.50258583153325,39.80898691046014],[116.50258721755367,39.80898522572469],[116.5025886674554,39.80898345477921],[116.50259018597043,39.808981591237774],[116.5025917778307,39.808979628714454],[116.50259344776819,39.80897756082334],[116.50259520051483,39.80897538117847],[116.50259704080258,39.80897308339394],
[116.50260652829927, 39.80896138259575],
[116.50261595656403, 39.80894963426086],
[116.50262538482876, 39.80893788592398],
[116.50263481309352, 39.80892613758509],
[116.50264424135828, 39.80891438924419],
[116.50265366962303, 39.80890264090128],
[116.50266309788779, 39.80889089255635],
[116.50267252615251, 39.808879144209435],
[116.50268195441728, 39.808867395860496],
[116.50269138268203, 39.80885564750955],
[116.50270081094675, 39.8088438991566],
[116.50271023921152, 39.80883215080165],
[116.50271966747628, 39.80882040244469],
[116.50272909574102, 39.8088086540857],
[116.50273852400579, 39.80879690572473],
[116.50274795227055, 39.80878515736174],
[116.50275738053527, 39.808773408996736],
[116.50276680880005, 39.80876166062974],
[116.5027762370648, 39.80874991226073],
[116.50278566532953, 39.80873816388972],
[116.50279420230066, 39.80872752614001],
[116.50280353151834, 39.80871573236971],
[116.50281048428627, 39.80870303338525],
[116.50281405862891, 39.80868953352494],
[116.50281404037212, 39.80867575730624],
[116.50281046861977, 39.80866225701582],
[116.50280343493115, 39.808649585669684],
[116.50279324712442, 39.80863824913313],
[116.50278027954208, 39.80862873543999],
[116.50276508406697, 39.80862142721356],
[116.50274825941413, 39.80861675684903],
[116.5027303799696, 39.808616110118535],
[116.50271293867053, 39.808619088363244],
[116.50269720864796, 39.80862564603595],
[116.50268447677053, 39.80863527937748],
[116.50267341280619, 39.80864615002302],
[116.50266212329731, 39.80865688638265],
[116.5026508337884, 39.80866762274061],
[116.50263954427948, 39.80867835909688],
[116.50262525253801, 39.80869195058276],
[116.50262524257603, 39.808691950612655],
[116.50261580612782, 39.80870369511379],
[116.50260636967965, 39.80871543961292],
[116.50259693323143, 39.80872718411004],
[116.50258749678324, 39.80873892860516],
[116.50257806033504, 39.808750673098274],
[116.50256862388684, 39.80876241758937],
[116.50255918743866, 39.808774162078464],
[116.50254974864124, 39.808785905451415],
[116.50254030866101, 39.8087976482614],
[116.50253086868078, 39.80880939106937],
[116.50252142870058, 39.80882113387535],
[116.50251198872037, 39.8088328766793],
[116.50250254874015, 39.80884461948126],
[116.50249310875992, 39.808856362281205],
[116.50248366877972, 39.80886810507916],
[116.5024742287995, 39.8088798478751],
[116.5024647888193, 39.808891590669035],
[116.50245534883908, 39.80890333346096],
[116.50244590885885, 39.80891507625088],
[116.50243648704945, 39.80892682764632],
[116.50242706678878, 39.80893857977338],
[116.50241764652812, 39.80895033189842],
[116.50240822626745, 39.808962084021466],
[116.50239880600678, 39.808973836142506],
[116.50238938574607, 39.80898558826153],
[116.5023799654854, 39.808997340378546],
[116.50237054522474, 39.809009092493554],
[116.50236112496407, 39.80902084460654],
[116.5023518081128, 39.80903246771061],
[116.50234241407298, 39.80904423219872],
[116.50233302003318, 39.80905599668481],
[116.50232362599334, 39.8090677611689],
[116.50231410317872, 39.80907946408927],
[116.50230451214804, 39.80909113439654],
[116.50229492111734, 39.80910280470181],
[116.50228571333837, 39.809114655344956],
[116.50227653686962, 39.80912652071914],
[116.50226736040084, 39.80913838609128],
[116.5022581839321, 39.80915025146137],
[116.50224999247808, 39.809160843184586],
[116.50224042543937, 39.80917252509297],
[116.50223085840065, 39.80918420699937],
[116.50222129136195, 39.80919588890379],
[116.50221172432323, 39.809207570806215],
[116.50220215728451, 39.809219252706654],
[116.50219259024581, 39.80923093460512],
[116.5021830232071, 39.809242616501585],
[116.50217345616836, 39.80925429839608],
[116.50216388912965, 39.80926598028858],
[116.50215432209092, 39.80927766217909],
[116.50214475505221, 39.80928934406762],
[116.5021351880135, 39.80930102595418],
[116.50212562097478, 39.809312707838735],
[116.5021161682309, 39.80932444445018],
[116.50210672752434, 39.80933618682361],
[116.50209728681781, 39.80934792919502],
[116.50208784611127, 39.80935967156444],
[116.50207840540475, 39.809371413931835],
[116.50206896469822, 39.80938315629724],
[116.50205952399168, 39.809394898660635],
[116.50205008328514, 39.809406641022015],
[116.5020406425786, 39.80941838338139],
[116.50203120187207, 39.809430125738764],
[116.50202176116555, 39.80944186809414],
[116.50201232045903, 39.809453610447505],
[116.50200287975248, 39.80946535279886],
[116.50199343904592, 39.80947709514822],
[116.50198399833941, 39.809488837495564],
[116.50197455763286, 39.80950057984091],
[116.50196511692633, 39.80951232218425],
[116.50195568818478, 39.80952407018145],
[116.50194629734833, 39.80953583609448],
[116.50193690651183, 39.80954760200551],
[116.50192751567536, 39.80955936791453],
[116.50191812483887, 39.80957113382152],
[116.5019087340024, 39.8095828997265],
[116.50189934316592, 39.80959466562948],
[116.50188995232944, 39.80960643153043],
[116.50188056149298, 39.80961819742937],
[116.50187117065649, 39.80962996332631],
[116.50186177982, 39.80964172922121],
[116.50185238898351, 39.80965349511412],
[116.50184299814707, 39.80966526100501],
[116.50183360731057, 39.80967702689388],
[116.50182421647412, 39.80968879278074],
[116.50181482563762, 39.809700558665575],
[116.50180543480116, 39.809712324548414],
[116.50179604396466, 39.809724090429235],
[116.5017866531282, 39.80973585630804],
[116.50177726229172, 39.80974762218483],
[116.50176603303983, 39.809761691428776],
[116.5017559315272, 39.80977310463863],
[116.50174606013915, 39.80978461575066],
[116.501745399369, 39.80979802876061],
[116.50176111803627, 39.80981199004545],
[116.5017794095362, 39.80982207596424],
[116.50179458916823, 39.8098294587058],
[116.50180976712517, 39.8098368434775],
[116.50182494052174, 39.80984423377744],
[116.50183986641409, 39.80985190936817],
[116.50186093375147, 39.80986323461995],
[116.50187602871003, 39.80987071910237],
[116.50189112366859, 39.80987820358399],
[116.50190621862716, 39.80988568806478],
[116.50192135787326, 39.80989311925764],
[116.50193654901727, 39.80990048800575],
[116.5019517411002, 39.80990785560883],
[116.5019669480251, 39.80991520512269],
[116.5019889433169, 39.80992583545604],
[116.50200411254258, 39.80993323079723],
[116.50201928176824, 39.80994062613762],
[116.5020344549998, 39.80994801662329],
[116.50204936866068, 39.809955271625505]
]
}
# 处理新的数据并添加航向角
processed_data = process_gps_data_with_headings(new_original_data)
# 将结果保存为JSON格式
json_output = json.dumps(processed_data, indent=2, ensure_ascii=False)
print("处理完成!以下是包含航向角的JSON数据:")
print(json_output)
# 如果需要保存到文件
with open('gps_data_with_headings.json', 'w', encoding='utf-8') as f:
f.write(json_output)
print("\n数据已保存到 gps_data_with_headings.json 文件中")
\ No newline at end of file
This diff is collapsed.
......@@ -179,9 +179,9 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() {
//开启感知物websocket
getTarget()
//开启车辆位姿
// getCarVehicle()
//连接自己的服务车辆位姿
getSelfCar()
getCarVehicle()
//连接自己的服务websocket车辆位姿
// getSelfCar()
}
/**连接自己的车辆位姿服务**/
......@@ -335,10 +335,6 @@ class MainActivity : BaseActivity<ActivityMainBinding, MyBaseViewModel>() {
}
}
}
//召车的时候临时开一下
/* mainVm.targetPre.observe(this) {
showPre(it)
}*/
}
/**更新车辆位置*/
......
......@@ -244,22 +244,22 @@ class MainVm @Inject constructor(
* 联网车辆位姿数据
*/
fun subVehicle(): StateFlow<CarVehicle> {
if (isMock) {
// mockVM.subVehicle(carVehicle)
viewModelScope.launch {
delay(20000)
//模拟泊车
mockVM.onVehicleMockPark(carVehicle, v2xStartBean)
delay(3000)
//模拟叫车
mockVM.onVehicleMockCall(carVehicle, targetPre, v2xStartBean)
}
} else {
var url = "${MyContants.HOST}/api/avpweb/hmi/monitor/v1/monitorDrivenStatus"
carCb.url = url
var body = RequestBodyUtil.toRequestBody(mapOf("id" to MyContants.VEHICLEID))
avpDataRepo.getCarPose(url, body, carCb)
}
// if (isMock) {
//// mockVM.subVehicle(carVehicle)
// viewModelScope.launch {
// delay(20000)
// //模拟泊车
// mockVM.onVehicleMockPark(carVehicle, v2xStartBean)
// delay(3000)
// //模拟叫车
// mockVM.onVehicleMockCall(carVehicle, targetPre, v2xStartBean)
// }
// } else {
var url = "${MyContants.HOST}/api/avpweb/hmi/monitor/v1/monitorDrivenStatus"
carCb.url = url
var body = RequestBodyUtil.toRequestBody(mapOf("id" to MyContants.VEHICLEID))
avpDataRepo.getCarPose(url, body, carCb)
// }
return carVehicle
}
......
......@@ -154,16 +154,16 @@ class MockVM @Inject constructor(
//变速
CarPanelBean.instance.speed.set(random.nextInt(10..15))
//一边移动一把你计算航向角
if (index > 0 && index < mRoutes.rs.count()) {
/* if (index > 0 && index < mRoutes.rs.count()) {
var p1 = mRoutes.rs.get(index - 1)
var pc = mRoutes.rs.get(index)
head = MyMapUtils.calculateBearing(
LatLng(p1[1], p1[0]),
LatLng(pc[1], pc[0])
)
}
}*/
cCar = CarVehicle().apply {
this.vehiclePos = listOf(it[0], it[1], head)
this.vehiclePos = listOf(it[0], it[1], it[2])
}
oldHead = head
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment