Hi to all!

Please I need a help, I am a beginner in programming. I am trying to develop a software to transform heights in a file using Visual c++6.0. With the input file consisting of latitude, longitude and a geoid height , Hgeoid for every point . After transformation I want to get the same latitude and longitude together with a mean sea level height, Hmsl. I want that When I select and change the model in the combo box its value be used in the function Hgeoid_Hgeoid for computation of the output height value.

I do not know the problem I have in my code but when I run I am getting only the first column with correct result and strange numbers on the rest two columns. Please have a look at my code and help me! Thank you in advance for your time!

void CFileTransformationDlg::OnComp()
{
UpdateData (TRUE);

m_geoidmodeltype = m_Geoidmodeltyp_box.GetCurSel();

char Pointnumber [20];

CStdioFile input, output;

if (! (input.Open(m_strInputFile, CFile::modeRead)))
{
MessageBox ("Declare a valid InputFile name!",
"Achtung", MB_OK);
return;
}

if (! (output.Open(m_strOutputFile, CFile::modeCreate| CFile::modeWrite)))
{
MessageBox ("Declare a valid OutPutFile name!",
"Achtung", MB_OK);
return;
}

CString buffer;

while (input.ReadString(buffer))
{

sscanf (buffer,"%s%1f%lf%f",Pointnumber, &phi, &lambda, &Hgeoid);

Hgeoid_Hmsl( phi, lambda, Hgeoid, m_phi, m_lambda, m_Hmsl);

buffer.Format ("%10s%15.3f%15.3f%15.3f\n", Pointnumber, m_phi, m_lambda, m_Hmsl);

output.WriteString(buffer);
}

output.Close();
input.Close();

MessageBox ("The computation completed successfully!!",
"Alles o.k.", MB_OK);
}

void CFileTransformationDlg::OnchangeGeoidModeltyp()
{
switch (m_geoidmodeltype)
{
case 0://EGM96
{
m_XTranslation_U= -0.75451+0.00138;
m_YTranslation_V= -0.55520+0.00147;
m_ZTranslation_W= -0.068244+0.0013;
m_RotEx=-0.000028591+0.000000088;
m_RotEy=-0.000041862+0.000000101;
break;
}
case 1: //African Geoid, AGP2003
{
m_XTranslation_U=-0.040239+0.002715;
m_YTranslation_V= 0.12844+0.0019843;
m_ZTranslation_W=0.4084+0.0035588;
m_RotEx=-0.000032330+0.00000021657;
m_RotEy=0.0000075046+0.00000012609;
break;
}
}
}

void CFileTransformationDlg::Hgeoid_Hmsl(double phi, double lambda, double Hgeoid, double m_phi, double m_lambda, double m_Hmsl)
{
UpdateData (TRUE);

double N,p, q, r, s, t, a_e, b_e, e_sq, PIE, RHO;

m_Hgeoid=Hgeoid;

PIE = atan(1.0)*4.0;
RHO = 180.0 / PIE;

phi=m_phi;
lambda=m_lambda;

a_e = 6378137;
b_e = 6356752.3142;
e_sq =((a_e*a_e)-(b_e*b_e))/(a_e*a_e);

//Prime meridian length of arc N = a_e/(sqrt(1 - (e_sq*sin(phi)*sin(phi))));

N=a_e/(sqrt(1 - (e_sq*sin(phi/RHO)*sin(phi/RHO))));


// p= cos(lambda)*cos(phi);

p=cos(lambda/RHO)*cos(phi/RHO);

// q= cos(phi)*sin(lambda);

q=cos(phi/RHO)*sin(lambda/RHO);

// r=sin(phi);

r=sin(phi/RHO);


// s= e_sq*N*sin(phi) * cos(phi)*sin(lambda);

s=e_sq*N*sin(phi/RHO) * cos(phi/RHO)*sin(lambda/RHO);

// t=(-e_sq*N*sin(phi) * cos(phi)*cos(lambda));

t=(-e_sq*N*sin(phi/RHO) * cos(phi/RHO)*cos(lambda/RHO));

// Computing the correction between Hmsl and Hgeoid, dH

dH= (p*m_XTranslation_U)+(q*m_YTranslation_V)+ (r*m_ZTranslation_W)+(s*m_RotEx)+(t*m_RotEy);//For EGM96


//Computing MSL heights, Hmsl

Hmsl=dH + m_Hgeoid;

m_Hmsl =Hmsl;

UpdateData (FALSE);

}
[3995 byte] By [dorodeus] at [2007-11-20 1:36:07]
# 1 Re: Hi to all!
The code looks unreadable. Can you comment your code, and indent?

(Note: This section is only for C++/CLI and Managed C++. If you're using regular C++, post in the correct section. This is not the correct section for regular C++.)
Lee Cheon-Sin at 2007-11-9 12:07:26 >