GPS4Palm

Source Code Documentation


Clip.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002  *
00003  * $RCSfile: Clip_8c-source.html,v $
00004  *
00005  * GPS4Palm Clipboard Functions
00006  *
00007  * This program is Copyright (C) 07/2003 Matthias Prinke
00008  * <matthias.prinke@surfeu.de> and covered by GNU's GPL.
00009  * In particular, this program is free software and comes WITHOUT
00010  * ANY WARRANTY.
00011  *
00012  * $Author: mp $
00013  *
00014  * $Date: 2007-10-08 20:40:32 $
00015  *
00016  * $Revision: 1.1.2.1 $
00017  *
00018  * $Log: Clip_8c-source.html,v $
00018  * Revision 1.1.2.1  2007-10-08 20:40:32  mp
00018  * updated for gps4palm V0.9.5 beta
00018  *
00019  * Revision 1.4  2005-04-02 17:29:25  mp
00020  * moved Position2Geodb() to Data.c/Data.h
00021  *
00022  * Revision 1.3  2005/04/02 10:10:08  mp
00023  * modified Position2Clipboard() and Position2Geodb() to return 'handled'
00024  *
00025  * Revision 1.2  2005/04/02 07:24:44  mp
00026  * added Position2Geodb()
00027  *
00028  * Revision 1.1  2005/03/25 13:40:48  mp
00029  * initial version
00030  *
00031  *
00032  *
00033  ****************************************************************************/
00034 #include <PalmOS.h>
00035 #include <PalmCompatibility.h>
00036 #include "common.h"
00037 #include "Clip.h"
00038 #include "Data.h"
00039 #include "geo.h"        /* deg_to_str() */
00040 
00041 
00042 /****************************************************************************/
00043 /**
00044  * \brief       Add Time/Date and Position (in user selected unit)
00045  *              to Clipboard
00046  *
00047  * \param       gps_data        GPS Data (Time of Fix, Position, ...)
00048  * \param       units           User selected units
00049  *
00050  * \return      True if GPS data is valid.
00051  ****************************************************************************/
00052 Boolean Position2Clipboard(GPSType gps_data, UnitsType units)
00053 {
00054   DateTimeType  dt;                     /* date/time structure */
00055   Char          lat_str[20];            /* latitude/easting */
00056   Char          lon_str[20];            /* longitude/northing */
00057   Char          field_str[5];           /* UTM zone and field */
00058   Char          clp_str[61];            /* time&date: 16 lat&lon: 45 */
00059     
00060   if (!gps_data.valid)
00061     return false;
00062 
00063   /* get time and date (output format: yy-mm-dd hh:mm) */
00064   TimSecondsToDateTime(gps_data.time, &dt);
00065   
00066   /* write date to string */
00067   DateToAscii(dt.month, dt.day, dt.year,
00068     dfYMDWithDashes,
00069     clp_str);
00070 
00071   /* append space */
00072   StrCat(clp_str, " ");
00073   
00074   /* write time to string */
00075   TimeToAscii(dt.hour, dt.minute,
00076     tfColon24h,
00077     &clp_str[StrLen(clp_str)]);
00078   
00079   /* append space */
00080   StrCat(clp_str, " ");
00081   
00082   /* convert position to string */
00083   deg_to_str(gps_data.lat, gps_data.lon, units.pos_unit,
00084              lat_str, lon_str, field_str, NULL, NULL);
00085   
00086   /* append UTM zone and field (or empty string) */
00087   StrCat(clp_str, field_str);
00088   
00089   if (StrLen(field_str) == 0)
00090     /* append space */
00091     StrCat(clp_str, " ");
00092 
00093   if (units.pos_unit == POS_UTM)
00094     StrCat(clp_str, "E");
00095   
00096   /* append Latitude or Easting */
00097   StrCat(clp_str, lat_str);
00098   
00099   /* append space */
00100   StrCat(clp_str, " ");
00101 
00102   if (units.pos_unit == POS_UTM)
00103     StrCat(clp_str, "N");
00104 
00105   /* append Longitude or Northing */
00106   StrCat(clp_str, lon_str);
00107 
00108   ClipboardAddItem(clipboardText, clp_str, StrLen(clp_str));
00109   
00110   return true;
00111 }

Created: Mon, 08 Oct 2007 22:33:16 +0200
Copyright ©2004 M. Prinke