473,473 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help to CC++ a Visual Basic 6.0

2 New Member
Hello to all, I have a problem that I cannot solve, I have a file in C++ and like not like translating it to visual BASIC, I write to them to be able to receive aid and that somebody helps me to translate it to Visual BASIC 6,0, the code is the following one

#ifndef _INC_C_DEM
#define _INC_C_DEM

************************************************** ***************************************
#include <afx.h>
#include <math.h>

************************************************** ***************************************
class C_DEM
{
public:
C_DEM();
~C_DEM() {};

DWORD Init( const char *Filename );
short GetElevM( float &Lat, float &Lon );
float GetElevF( float &Lat, float &Lon );

private:
FILE *m_fpIn;

float m_LatConv;
float m_LonConv;
float m_DenConv;

long m_Line;
long m_Elem;
long m_Offset;

short m_Elev;
};

#endif // _INC_C_DEM

///////////////////////////////////////////////////////////////////////////////
//
// C_DEM.cpp
//
// This class is used to access a digital elevation map (DEM) in order to
// get the elevation at a specified latitude and longitude
//
// Notes:
// Returned elevation of 9999 indicates an error
// Returned elevation of -9999 indicates water

#include "C_DEM.h"

///////////////////////////////////////////////////////////////////////////////

C_DEM::C_DEM()
{
m_LatConv = (float) (89.0 + (239.0 / 240.0));
m_LonConv = (float) -(179.0 + (239.0 / 240.0));
m_DenConv = (float) (1.0 / 120.0);
}

///////////////////////////////////////////////////////////////////////////////

DWORD C_DEM::Init( const char *Filename )
{
m_fpIn = fopen( Filename, "rb" );
if( m_fpIn == NULL )
{
return( GetLastError() );
}

return( ERROR_SUCCESS );
}

///////////////////////////////////////////////////////////////////////////////

short C_DEM::GetElevM( float &Lat, float &Lon )
{
if( m_fpIn == NULL )
{
return( 9999 );
}

m_Line = (long) ((m_LatConv - Lat) / m_DenConv);
m_Elem = (long) fabs((double)((m_LonConv - Lon) / m_DenConv));

m_Offset = (m_Line * 86400) + (m_Elem * 2);
if( fseek( m_fpIn, m_Offset, SEEK_SET ) != 0 )
{
return( 9999 );
}
else
{
if( fread( &m_Elev, 2, 1, m_fpIn ) != 1 )
{
return( 9999 );
}
else
{
return( m_Elev );
}
}
}

///////////////////////////////////////////////////////////////////////////////

float C_DEM::GetElevF( float &Lat, float &Lon )
{
m_Elev = GetElevM( Lat, Lon );
if( (m_Elev == 9999) || (m_Elev == -9999) )
{
return( (float) m_Elev );
}
else
{
return( (float) m_Elev / (float) 0.3048 );
}
}
Nov 13 '06 #1
0 1029

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help...
2
by: quinto1000 | last post by:
Hello to all, I have a problem that I cannot solve, I have a file in C++ and like not like translating it to visual BASIC, I write to them to be able to receive aid and that somebody helps me to...
4
by: Brad Isaacs | last post by:
I am using ASP.NET 2.0 codebehind Visual Basic, Visual Studio 2005 Working with DataSet creating a Data Access Layer via VS 2005. My error is when the code that is prewritten by VS 2005 Casts...
0
by: Peterwkc | last post by:
Hello everybody, i a C/C++ programmer but i have a visual basic question becasue my computer is being attacked by someone else. I don't know what is the function of the code. Could oyu please...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.