Download source files - 10 Kb
, a freeware MFC class to support retrieval of recent Earthquake
information from the USGS (United States Geological Survey) via the finger protocol.
For detailed information about the Finger protocol, you should read RFC 1288. You can find
numerous Web Servers which carry these documents by going to
www.yahoo.com and look for RFC and 1288.
The sample app provided with the code implements a very simple console app which queries for
the Earthquake information and displays the results using simple printf calls.
V1.0 (18 October 1999)
- Simple and clean C++ interface.
- The interface provided is synchronous which provides an easier programming model
than using asynchronous sockets.
- The code does not rely on the MFC socket classes. These classes have a number of
shortcomings, one of which causes problems when they are used in NT services.
- The code can be used in a console application without any problems (Again this is
not the case for the MFC socket classes).
- A configurable timeout for the connection can be set through the main class method.
- The code internally makes use of another of the authors classes namely
Before you can compile CEQD, you will also need to download the
CFinger source and copy over the finger
cpp and h files into the directory where you have unzipped the CEQD code.
- To use the class in your code simply include eqd.cpp and finger.cpp in your
#include eqd.h in which ever of your modules needs to make calls
to the class.
- To see the class in action, have a look at the code in main in the module main.cpp.
- Your code will need to include MFC either statically or dynamically.
- You will need to have a functioning Winsock stack installed and correctly initialized prior
to calling the
GetQuakeData() method. Depending on your application, this will
involve calling either
AfxSocketInit() at startup
of your application.
- You will also need to have afxpriv.h and winsock.h or afxsock.h in your
precompiled header. The code will work just as well in a GUI or console app. The code should
also work in a multithreaded application, although it has not be explicitly tested in this
The API consists of the class
and the single public member function of
the class CEQD namely
- The Coordinated Universal Time of when the Earthquake took place.
- Geographic latitude of the Epicenter. North of the equator is positive, south of
the equator is negative.
- Geographic longitude of the Epicenter. East of the Greenwich prime meridian is positive,
west of the prime meridian is negative.
- The depth below sea level in Km of the epicenter.
- Enum of the type of magnitude as reported in m_Magnitude. This member is one of the
- Ml: The original Richter magnitude
- Lg: Local or regional magnitude
- Md: Duration wave
- Mb: Body wave
- Ms: Surface wave
- Mw: Moment wave
- The actual magnitude of the earthquake on the Richter Scale.
- Enum of quality of the location fix. This member is one of the following enums:
- A: Quake location is "Good"
- B: Quake location is "Fair"
- C: Quake location is "Poor"
- D: Quake Location is "Bad"
- U: Quake Location quality has not been determined
- This is a textual Description, Normally this will be the location of the quake.
CQuakeData class represents the data associated with a single earthquake as
- BOOL CEQD::GetQuakeData(CArray<CQuakeData, CQuakeData&>& data, DWORD dwTimeout = 500);
If the function succeeds, the return value is TRUE. If the function fails, the return value is
FALSE. To get extended error information, call
- data -- Upon successful return, this will contain an array of
instances which represent all the most recent earthquakes which have occurred.
- dwTimeout -- The timeout value to use in milliseconds for socket connections.
Call this member function to perform the actual retrieval of the quake data.
18 October 1999