13 #include <glib/gstdio.h>
16 #include <gdk/gdkkeysyms.h>
17 #include <libgnomevfs/gnome-vfs.h>
18 #include <curl/multi.h>
19 #include <gconf/gconf-client.h>
20 #include <libxml/parser.h>
24 #include "mapper-types.h"
27 void sound_noise(void)
30 hildon_play_system_sound("/usr/share/sounds/ui-information_note.wav");
36 void sound_speak(gchar * phrase)
38 #define _voice_synth_path "/usr/bin/flite"
42 /* We are the fork child. Synthesize the voice. */
45 printf("%s %s\n", _voice_synth_path, _last_spoken_phrase);
46 execl(_voice_synth_path, _voice_synth_path,
47 "-t", _last_spoken_phrase, (char *)NULL);
56 void latlon2unit(gfloat lat, gfloat lon, gint *unitx_, gint *unity_)
63 unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f;
64 tmp = sinf(lat * (PI / 180.f));
65 unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN)
66 * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP);
69 void unit2latlon(gint unitx, gint unity, gfloat *lat, gfloat *lon)
71 (lon) = ((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f;
72 (lat) = (360.f * (atanf(expf(((unity)
73 * (MERCATOR_SPAN / WORLD_SIZE_UNITS))
74 + MERCATOR_TOP)))) * (1.f / PI) - 90.f;
79 deg_format(DegFormat degformat, gfloat coor, gchar * scoor, gchar neg_char,
83 gfloat acoor = fabs(coor);
84 printf("%s()\n", __PRETTY_FUNCTION__);
88 sprintf(scoor, "%.5f°", coor);
91 sprintf(scoor, "%.5f° %c", acoor,
92 coor < 0.f ? neg_char : pos_char);
96 sprintf(scoor, "%d°%06.3f'",
97 (int)coor, (acoor - (int)acoor) * 60.0);
100 sprintf(scoor, "%d°%06.3f' %c",
101 (int)acoor, (acoor - (int)acoor) * 60.0,
102 coor < 0.f ? neg_char : pos_char);
106 min = (acoor - (int)acoor) * 60.0;
107 sprintf(scoor, "%d°%02d'%04.1f\"", (int)coor, (int)min,
108 ((min - (int)min) * 60.0));
110 case DD_MM_SSPS_NSEW:
111 min = (acoor - (int)acoor) * 60.0;
112 sprintf(scoor, "%d°%02d'%04.1f\" %c", (int)acoor, (int)min,
113 ((min - (int)min) * 60.0),
114 coor < 0.f ? neg_char : pos_char);
118 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
122 * Convert the float lat/lon/speed/heading data into integer units.
124 void integerize_data()
127 printf("%s()\n", __PRETTY_FUNCTION__);
129 latlon2unit(_gps.lat, _gps.lon, _pos.unitx, _pos.unity);
131 tmp = (_gps.heading * (1.f / 180.f)) * PI;
132 _vel_offsetx = (gint) (floorf(_gps.speed * sinf(tmp) + 0.5f));
133 _vel_offsety = -(gint) (floorf(_gps.speed * cosf(tmp) + 0.5f));
135 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
139 download_comparefunc(const ProgressUpdateInfo * a,
140 const ProgressUpdateInfo * b, gpointer user_data)
142 gint diff = (a->priority - b->priority);
145 diff = (a->tilex - b->tilex);
148 diff = (a->tiley - b->tiley);
151 diff = (a->zoom - b->zoom);
154 diff = (a->repo - b->repo);
157 /* Otherwise, deletes are "greatest" (least priority). */
159 return (b->retries ? -1 : 0);
160 else if (!b->retries)
161 return (a->retries ? 1 : 0);
162 /* Do updates after non-updates (because they'll both be done anyway). */
163 return (a->retries - b->retries);