cbgpx.h File Reference

Set of functions for creating GPX files. More...

#include "cbthr.h"
#include <stdio.h>
#include <wchar.h>

Go to the source code of this file.

Data Structures

struct  t_cbgpx

Functions

short cbgpx_isvalid (const t_cbgpx *aHandle)
 Checks, if the given handle of the GPX file is valied.
short cbgpx_opena (t_cbgpx *theHandle, const char *aFileName)
 Opens the given file as a GPX file, ANSI file name.
short cbgpx_openw (t_cbgpx *theHandle, const wchar_t *aFileName)
 Opens the given file as a GPX file, wide char file name.
void cbgpx_close (t_cbgpx *aHandle)
 Closes the GPX file.
short cbgpx_write (t_cbgpx *aHandle, double aLat, double aLon, double anAlt)
 Writes the given coordinates into the GPX file.


Detailed Description

Set of functions for creating GPX files.

See also GPX: The GPS exchange format , http://www.topografix.com/gpx.asp.

Example: the following code:

 #include "cbgpx.h"

 int main() {
   t_cbgpx  hgpx;

   if (cbgpx_opena(&hgpx, "test.gpx") != 0) {
     cbgpx_write(&hgpx, 49.2, 11.7, 403.6);
     ...
     cbgpx_write(&hgpx, 49.5, 12.2, 398.3);
     cbgpx_close(&hgpx);
   }
 }
produces the following GPX file in "test.gpx":
 <?xml version="1.0"?>
 <gpx xmlns="http://www.topografix.com/GPX/1/0">
   <time>2008-11-23T16:40:07Z</time>
   <wpt lat="49.2" lon="11.7">
     <ele>403.6</ele>
     <time>2008-11-23T16:46:09Z</time>
     <name>0</name>
     <desc>0</desc>
     <sym>Dot</sym>
     <type>Dot</type>
   </wpt>
   <!-- ... -->
   <wpt lat="49.5" lon="12.2">
     <ele>398.3</ele>
     <time>2008-11-23T17:05:51Z</time>
     <name>275</name>
     <desc>275</desc>
     <sym>Dot</sym>
     <type>Dot</type>
   </wpt>
   <bounds minlat="49.2" minlon="11.7" maxlat="49.5" maxlon="12.2" />
 </gpx>

Function Documentation

void cbgpx_close ( t_cbgpx aHandle  ) 

Closes the GPX file.

The function writes the following closing information into the GPX file

and closes the file handle. Afterwards it resets the handle of the GPX file.
Parameters:
aHandle the handle of the GPX file to close.

short cbgpx_isvalid ( const t_cbgpx aHandle  ) 

Checks, if the given handle of the GPX file is valied.

Parameters:
aHandle pointer to the handle to check
Returns:
!= 0 if the handle is valid, 0 else.

short cbgpx_opena ( t_cbgpx theHandle,
const char *  aFileName 
)

Opens the given file as a GPX file, ANSI file name.

The function opens the given file and writes the following initial information into it:

 <?xml version="1.0"?>
 <gpx xmlns="http://www.topografix.com/GPX/1/0">
   <time>[current time]</time>
where [current time] is the current system time in format yyyy-MM-ddTHH:mm:ssZ
Parameters:
theHandle the resulting handle of the GPX file.
aFileName the name of the file to open.
Returns:
!= 0 if everything went OK, 0 on error.

short cbgpx_openw ( t_cbgpx theHandle,
const wchar_t *  aFileName 
)

Opens the given file as a GPX file, wide char file name.

Converts the given file name into multibyte and uses cbgpx_opena() in order to open the GPX file.

Parameters:
theHandle the resulting handle of the GPX file.
aFileName the name of the file to open.
Returns:
!= 0 if everything went OK, 0 on error.

short cbgpx_write ( t_cbgpx aHandle,
double  aLat,
double  aLon,
double  anAlt 
)

Writes the given coordinates into the GPX file.

The function writes the following information into the GPX file:

   <wpt lat="[latitude]" lon="[longitude]">
     <ele>[altitude]</ele>
     <time>[current time]</time>
     <name>0</name>
     <desc>0</desc>
     <sym>Dot</sym>
     <type>Dot</type>
   </wpt>
where:
  1. [latitude] is the given latitude aLat with a dot as decimal point
  2. [longitude] is the given longitude aLon with a dot as decimal point
  3. [altitude] is the given altitude anAlt with a dot as decimal point
  4. long is the given latitude with dot as the decimal point separator
  5. [current time] is the current system time in format yyyy-MM-ddTHH:mm:ssZ

Parameters:
aHandle the GPX file handle.
aLat the latitude, positive for North, negative for South, decimal degrees.
aLon the longitude, positive for East, negative for West, decimal degrees.
anAlt the altitude in meters.
Returns:
!= 0 if everything went OK, 0 on error.


Generated on Thu Feb 12 11:09:26 2009 for cb by  doxygen 1.4.7