(*Výpočet délky a azimutu stěny na základě GIS podkladů z Prahy*)

dataphsPraha=Import["phs2.xlsx"];
vyskaphsPraha=Import["protihluk.xlsx"];

zemsirka=Table[dataphsPraha[[1]][[i]][[2]],{i,2,Length[dataphsPraha[[1]]]}];
zemdelka=Table[dataphsPraha[[1]][[i]][[3]],{i,2,Length[dataphsPraha[[1]]]}];
poradiphs=Table[dataphsPraha[[1]][[i]][[4]],{i,2,Length[dataphsPraha[[1]]]}];
vyskaimport=Table[vyskaphsPraha[[1]][[i]][[3]],{i,2,Length[vyskaphsPraha[[1]]]}];
datamodel=Table[{zemsirka[[i]],zemdelka[[i]],poradiphs[[i]]},{i,1,Length[zemdelka]}];

delkaphs=Table[If[datamodel[[i,3]]==datamodel[[i+1,3]],6371000*2*ArcTan[√1-(((Sin[((datamodel[[i+1]][[1]]Degree-datamodel[[i]][[1]]Degree)/2)])^2)+Cos[datamodel[[i]][[1]]Degree]*Cos[datamodel[[i+1]][[1]]Degree]*((Sin[((datamodel[[i+1]][[2]]Degree-datamodel[[i]][[2]]Degree)/2)])^2)),√(((Sin[((datamodel[[i+1]][[1]]Degree-datamodel[[i]][[1]]Degree)/2)])^2)+Cos[datamodel[[i]][[1]]Degree]*Cos[datamodel[[i+1]][[1]]Degree]*((Sin[((datamodel[[i+1]][[2]]Degree-datamodel[[i]][[2]]Degree)/2)])^2))],0],{i,1,Length[datamodel]-1}];

ID=Table[If[delkaphs[[i]]>0,datamodel[[i,3]],Nothing],{i,1,Length[delkaphs]}];
Export["IDpraha.xlsx",ID]

azimutphs=Table[If[datamodel[[i,3]]==datamodel[[i+1,3]],Mod[ArcTan[(Cos[datamodel[[i]][[1]]Degree]*Sin[datamodel[[i+1]][[1]]Degree]-Sin[datamodel[[i]][[1]]Degree]*Cos[datamodel[[i+1]][[1]]Degree]*Cos[datamodel[[i+1]][[2]]Degree-datamodel[[i]][[2]]Degree]),(Sin[datamodel[[i+1]][[2]]Degree-datamodel[[i]][[2]]Degree]*Cos[datamodel[[i+1]][[1]]Degree])]*(180/Pi)+360,360],0],{i,1,Length[datamodel]-1}];

Table[If[datamodel[[i,3]]==datamodel[[i+1,3]],ArcTan[(Cos[datamodel[[i]][[1]]Degree]*Sin[datamodel[[i+1]][[1]]Degree]-Sin[datamodel[[i]][[1]]Degree]*Cos[datamodel[[i+1]][[1]]Degree]*Cos[datamodel[[i+1]][[2]]Degree-datamodel[[i]][[2]]Degree]),(Sin[datamodel[[i+1]][[2]]Degree-datamodel[[i]][[2]]Degree]*Cos[datamodel[[i+1]][[1]]Degree])]+180Degree,0],{i,1,10}]

delkamodel=Table[If[delkaphs[[i]]>0,delkaphs[[i]],Nothing],{i,1,Length[datamodel]-1}];

azimutmodel=Table[If[azimutphs[[i]]>0,azimutphs[[i]],Nothing],{i,1,Length[datamodel]-1}];
vyskadleporadi=Table[If[vyskaimport[[i]]>0,vyskaimport[[i]],Nothing],{i,1,Length[vyskaimport]-1}];
vysledekvyska=Table[If[poradiphs[[i]]==poradiphs[[i+1]],vyskadleporadi[[poradiphs[[i]]]],0],{i,1,Length[vyskaimport]-1}];
vyskaexcel=Table[If[vysledekvyska[[i]]>0,vysledekvyska[[i]],Nothing],{i,1,Length[vysledekvyska]}];

modelexcel=Table[{delkamodel[[i]],azimutmodel[[i]],vyskaexcel[[i]]},{i,1,Length[delkamodel]}];

Export["model1.xlsx",modelexcel]

(*Výpočet délky a azimutu stěny na základě GIS podkladů od Ředitelství silnic a dálnic*)

dataRSD=Import["dataRSD.xlsx"][[1]];

delkaphsRSD=Table[If[dataRSD[[i,3]]==dataRSD[[i+1,3]],6371000*2*ArcTan[√(1-(((Sin[((dataRSD[[i+1]][[1]]Degree-dataRSD[[i]][[1]]Degree)/2)])^2)+Cos[dataRSD[[i]][[1]]Degree]*Cos[dataRSD[[i+1]][[1]]Degree]*((Sin[((dataRSD[[i+1]][[2]]Degree-dataRSD[[i]][[2]]Degree)/2)])^2))),√(((Sin[((dataRSD[[i+1]][[1]]Degree-dataRSD[[i]][[1]]Degree)/2)])^2)+Cos[dataRSD[[i]][[1]]Degree]*Cos[dataRSD[[i+1]][[1]]Degree]*((Sin[((dataRSD[[i+1]][[2]]Degree-dataRSD[[i]][[2]]Degree)/2)])^2))],0],{i,1,Length[dataRSD]-1}];

ID2=Table[If[delkaphsRSD[[i]]>0,dataRSD[[i,3]],Nothing],{i,1,Length[delkaphsRSD]}];
Export["IDrsd.xlsx",ID2]

azimutphsRSD=Table[If[dataRSD[[i,3]]==dataRSD[[i+1,3]],Mod[ArcTan[(Cos[dataRSD[[i]][[1]]Degree]*Sin[dataRSD[[i+1]][[1]]Degree]-Sin[dataRSD[[i]][[1]]Degree]*Cos[dataRSD[[i+1]][[1]]Degree]*Cos[dataRSD[[i+1]][[2]]Degree-dataRSD[[i]][[2]]Degree]),(Sin[dataRSD[[i+1]][[2]]Degree-dataRSD[[i]][[2]]Degree]*Cos[dataRSD[[i+1]][[1]]Degree])]*(180/Pi)+360,360],0],{i,1,Length[dataRSD]-1}]//Quiet;

delkamodelRSD=Table[If[delkaphsRSD[[i]]>0,delkaphsRSD[[i]],Nothing],{i,1,Length[dataRSD]-1}];
azimutmodelRSD=Table[If[azimutphsRSD[[i]]>0,azimutphsRSD[[i]],Nothing],{i,1,Length[dataRSD]-1}];

modelexcelRSD=Table[{delkamodelRSD[[i]],azimutmodelRSD[[i]]},{i,1,Length[delkamodelRSD]}];

Export["modelRSD.xlsx",modelexcelRSD]

(*Projekt FVPHS na úseku dálnice D35*)

data=Import["D35.json","Data"][[2,2]];
data1=data[[1,2,2]];
data2=data[[2,2,2]];
data3=data[[3,2,2]];
data4=data[[4,2,2]];
datad35=Import["D35.xlsx"][[1]];

d35=Import["PHSD35.xlsx"][[1]];

delkaphsD35=Table[If[d35[[i,3]]==d35[[i+1,3]],6371000*2*ArcTan[√(1-(((Sin[((d35[[i+1]][[1]]Degree-d35[[i]][[1]]Degree)/2)])^2)+Cos[d35[[i]][[1]]Degree]*Cos[d35[[i+1]][[1]]Degree]*((Sin[((d35[[i+1]][[2]]Degree-d35[[i]][[2]]Degree)/2)])^2))),√(((Sin[((d35[[i+1]][[1]]Degree-d35[[i]][[1]]Degree)/2)])^2)+Cos[d35[[i]][[1]]Degree]*Cos[d35[[i+1]][[1]]Degree]*((Sin[((d35[[i+1]][[2]]Degree-d35[[i]][[2]]Degree)/2)])^2))],0],{i,1,Length[d35]-1}];

azimutphsD35=Table[If[d35[[i,3]]==d35[[i+1,3]],Mod[ArcTan[(Cos[d35[[i]][[1]]Degree]*Sin[d35[[i+1]][[1]]Degree]-Sin[d35[[i]][[1]]Degree]*Cos[d35[[i+1]][[1]]Degree]*Cos[d35[[i+1]][[2]]Degree-d35[[i]][[2]]Degree]),(Sin[d35[[i+1]][[2]]Degree-d35[[i]][[2]]Degree]*Cos[d35[[i+1]][[1]]Degree])]*(180/Pi)+360,360],0],{i,1,Length[d35]-1}];

delkamodelD35=Table[If[delkaphsD35[[i]]>0,delkaphsD35[[i]],Nothing],{i,1,Length[d35]-1}];
azimutmodelD35=Table[If[azimutphsD35[[i]]>0,azimutphsD35[[i]],Nothing],{i,1,Length[d35]-1}];
ID=Table[If[delkaphsD35[[i]]>0,d35[[i,3]],Nothing],{i,1,Length[delkaphsD35]}];

modelD35=Table[{ID[[i]],delkamodelD35[[i]],azimutmodelD35[[i]]},{i,1,Length[delkamodelD35]}];