]> git.street.me.uk Git - andy/viking.git/blobdiff - src/degrees_converters.c
Ensure highlight for a single track or waypoint is always shown on top.
[andy/viking.git] / src / degrees_converters.c
index c3350aa5f1412be2e2b2406562b78ac937d3b95b..0b29eb076b0a171dbf9eeadab22f47aff1dbf13c 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
+#ifdef HAVE_MATH_H
 #include <math.h>
-#include <glib.h>
+#endif
 #include <string.h>
+#include "degrees_converters.h"
+
+#define DEGREE_SYMBOL "\302\260"
 
 /**
  * @param pos_c char for positive value
@@ -44,8 +51,7 @@ static gchar *convert_dec_to_ddd(gdouble dec, gchar pos_c, gchar neg_c)
   val_d = fabs(dec);
 
   /* Format */
-  /* TODO : replace "°" as UTF-8 */
-  result = g_strdup_printf ( "%c%f°", sign_c, val_d );
+  result = g_strdup_printf ( "%c%f" DEGREE_SYMBOL, sign_c, val_d );
   return result;
 }
 
@@ -86,8 +92,7 @@ static gchar *convert_dec_to_dmm(gdouble dec, gchar pos_c, gchar neg_c)
   val_m = (tmp - val_d) * 60;
 
   /* Format */
-  /* TODO : replace "°" as UTF-8 */
-  result = g_strdup_printf ( "%c%d°%f'",
+  result = g_strdup_printf ( "%c%d" DEGREE_SYMBOL "%f'",
                              sign_c, val_d, val_m );
   return result;
 }
@@ -133,8 +138,7 @@ static gchar *convert_dec_to_dms(gdouble dec, gchar pos_c, gchar neg_c)
   val_s = (tmp - val_m) * 60;
 
   /* Format */
-  /* TODO : replace "°" as UTF-8 */
-  result = g_strdup_printf ( "%c%d°%d'%f\"",
+  result = g_strdup_printf ( "%c%d" DEGREE_SYMBOL "%d'%.4f\"",
                              sign_c, val_d, val_m, val_s );
   return result;
 }
@@ -174,7 +178,7 @@ gdouble convert_dms_to_dec(const gchar *dms)
                        gdouble value;
                        ptr = strpbrk (endptr, "0123456789,.");
                        if (ptr != NULL) {
-                               value = g_strtod(ptr, &endptr);
+                         value = g_strtod((const gchar *)ptr, (gchar **)&endptr);
                        nbFloat++;
                switch(nbFloat) {
                        case 1: