--- trunk/src/osm-gps-map.c 2009/08/24 09:23:36 74 +++ trunk/src/osm-gps-map.c 2009/09/01 11:16:30 89 @@ -49,6 +49,25 @@ #define EXTRA_BORDER (TILESIZE / 2) +#define OSM_GPS_MAP_SCROLL_STEP 10 + +/* any defined key enables key support */ +#if (defined(OSM_GPS_MAP_KEY_FULLSCREEN) || \ + defined(OSM_GPS_MAP_KEY_ZOOMIN) || \ + defined(OSM_GPS_MAP_KEY_ZOOMOUT) || \ + defined(OSM_GPS_MAP_KEY_UP) || \ + defined(OSM_GPS_MAP_KEY_DOWN) || \ + defined(OSM_GPS_MAP_KEY_LEFT) || \ + defined(OSM_GPS_MAP_KEY_RIGHT)) +#define OSM_GPS_MAP_KEYS +#endif + +#ifdef OSM_GPS_MAP_KEYS +#include +#endif + +#define USER_AGENT "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11" + struct _OsmGpsMapPrivate { GHashTable *tile_queue; @@ -78,8 +97,8 @@ char *proxy_uri; //where downloaded tiles are cached + char *tile_dir; char *cache_dir; - gboolean cache_dir_is_full_path; //contains flags indicating the various special characters //the uri string contains, that will be replaced when calculating @@ -112,6 +131,13 @@ #ifdef ENABLE_OSD //the osd controls (if present) osm_gps_map_osd_t *osd; +#ifdef OSD_DOUBLE_BUFFER + GdkPixmap *dbuf_pixmap; +#endif +#endif + +#ifdef OSM_GPS_MAP_KEY_FULLSCREEN + gboolean fullscreen; #endif //additional images or tracks added to the map @@ -165,7 +191,6 @@ PROP_REPO_URI, PROP_PROXY_URI, PROP_TILE_CACHE_DIR, - PROP_TILE_CACHE_DIR_IS_FULL_PATH, PROP_ZOOM, PROP_MAX_ZOOM, PROP_MIN_ZOOM, @@ -326,6 +351,8 @@ inspect_map_uri(OsmGpsMap *map) { OsmGpsMapPrivate *priv = map->priv; + priv->uri_format = 0; + priv->the_google = FALSE; if (g_strrstr(priv->repo_uri, URI_MARKER_X)) priv->uri_format |= URI_HAS_X; @@ -1072,6 +1099,11 @@ } } +#ifdef LIBSOUP22 + soup_message_headers_append(msg->request_headers, + "User-Agent", USER_AGENT); +#endif + g_hash_table_insert (priv->tile_queue, dl->uri, msg); soup_session_queue_message (priv->soup_session, msg, osm_gps_map_tile_download_complete, dl); } else { @@ -1424,6 +1456,12 @@ priv->idle_map_redraw = 0; + /* don't redraw the entire map while the OSD is doing */ + /* some animation or the like. This is to keep the animation */ + /* fluid */ + if (priv->osd->busy(priv->osd)) + return FALSE; + /* the motion_notify handler uses priv->pixmap to redraw the area; if we * change it while we are dragging, we will end up showing it in the wrong * place. This could be fixed by carefully recompute the coordinates, but @@ -1451,11 +1489,6 @@ osm_gps_map_draw_balloon_int(map); #endif -#ifdef ENABLE_OSD - if(priv->osd) - priv->osd->draw(priv->osd, EXTRA_BORDER, EXTRA_BORDER); -#endif - //osm_gps_map_osd_speed(map, 1.5); osm_gps_map_purge_cache(map); gtk_widget_queue_draw (GTK_WIDGET (map)); @@ -1472,6 +1505,86 @@ priv->idle_map_redraw = g_idle_add ((GSourceFunc)osm_gps_map_map_redraw, map); } +#ifdef OSM_GPS_MAP_KEYS +static gboolean +on_window_key_press(GtkWidget *widget, + GdkEventKey *event, OsmGpsMapPrivate *priv) { + gboolean handled = FALSE; + int step = GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; + + // the map handles some keys on its own ... + switch(event->keyval) { +#ifdef OSM_GPS_MAP_KEY_FULLSCREEN + case OSM_GPS_MAP_KEY_FULLSCREEN: { + GtkWidget *toplevel = gtk_widget_get_toplevel(GTK_WIDGET(widget)); + if(!priv->fullscreen) + gtk_window_fullscreen(GTK_WINDOW(toplevel)); + else + gtk_window_unfullscreen(GTK_WINDOW(toplevel)); + + priv->fullscreen = !priv->fullscreen; + handled = TRUE; + } break; +#endif + +#ifdef OSM_GPS_MAP_KEY_ZOOMIN + case OSM_GPS_MAP_KEY_ZOOMIN: + osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom+1); + handled = TRUE; + break; +#endif + +#ifdef OSM_GPS_MAP_KEY_ZOOMOUT + case OSM_GPS_MAP_KEY_ZOOMOUT: + osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom-1); + handled = TRUE; + break; +#endif + +#ifdef OSM_GPS_MAP_KEY_UP + case OSM_GPS_MAP_KEY_UP: + priv->map_y -= step; + priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); + handled = TRUE; + break; +#endif + +#ifdef OSM_GPS_MAP_KEY_DOWN + case OSM_GPS_MAP_KEY_DOWN: + priv->map_y += step; + priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); + handled = TRUE; + break; +#endif + +#ifdef OSM_GPS_MAP_KEY_LEFT + case OSM_GPS_MAP_KEY_LEFT: + priv->map_x -= step; + priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); + handled = TRUE; + break; +#endif + +#ifdef OSM_GPS_MAP_KEY_RIGHT + case OSM_GPS_MAP_KEY_RIGHT: + priv->map_x += step; + priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); + handled = TRUE; + break; +#endif + + default: + break; + } + + return handled; +} +#endif + static void osm_gps_map_init (OsmGpsMap *object) { @@ -1496,6 +1609,10 @@ priv->osd = NULL; #endif +#ifdef OSM_GPS_MAP_BUTTON_FULLSCREEN + priv->fullscreen = FALSE; +#endif + priv->tracks = NULL; priv->images = NULL; @@ -1512,12 +1629,12 @@ #ifndef LIBSOUP22 //Change naumber of concurrent connections option? - priv->soup_session = soup_session_async_new_with_options( - SOUP_SESSION_USER_AGENT, - "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11", - NULL); + priv->soup_session = + soup_session_async_new_with_options(SOUP_SESSION_USER_AGENT, + USER_AGENT, NULL); #else - /* libsoup-2.2 seems not to be able to set the user agent */ + /* libsoup-2.2 has no special way to set the user agent, so we */ + /* set it seperately as an extra header field for each reuest */ priv->soup_session = soup_session_async_new(); #endif @@ -1540,23 +1657,12 @@ GTK_WIDGET_SET_FLAGS (object, GTK_CAN_FOCUS); g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MASK, my_log_handler, NULL); -} -#ifndef G_CHECKSUM_MD5 -/* simple hash algorithm hack if md5 is not present */ -static char *simple_hash(char *str) { - union { - char str[4]; - gulong val; - } hash = { .val = 0x55555555 }; - - while(*str) { - hash.str[(int)str & 3] ^= *str; - str++; - } - return g_strdup_printf("%08lX", hash.val); -} +#ifdef OSM_GPS_MAP_KEYS + g_signal_connect(G_OBJECT(object), "key_press_event", + G_CALLBACK(on_window_key_press), priv); #endif +} static GObject * osm_gps_map_constructor (GType gtype, guint n_properties, GObjectConstructParam *properties) @@ -1595,25 +1701,13 @@ } } - if (!priv->cache_dir_is_full_path) { -#ifdef G_CHECKSUM_MD5 - char *md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5, priv->repo_uri, -1); -#else - char *md5 = simple_hash(priv->repo_uri); -#endif - - if (priv->cache_dir) { - char *old = priv->cache_dir; - //the new cachedir is the given cache dir + the md5 of the repo_uri - priv->cache_dir = g_strdup_printf("%s%c%s", old, G_DIR_SEPARATOR, md5); - g_debug("Adjusting cache dir %s -> %s", old, priv->cache_dir); - g_free(old); - } else { - //the new cachedir is the current dir + the md5 of the repo_uri - priv->cache_dir = g_strdup(md5); - } + const char *fname = osm_gps_map_source_get_friendly_name(priv->map_source); + if(!fname) fname = "_unknown_"; - g_free(md5); + if (priv->tile_dir) { + //the new cachedir is the given cache dir + the friendly name of the repo_uri + priv->cache_dir = g_strdup_printf("%s%c%s", priv->tile_dir, G_DIR_SEPARATOR, fname); + g_debug("Adjusting cache dir %s -> %s", priv->tile_dir, priv->cache_dir); } inspect_map_uri(map); @@ -1662,6 +1756,11 @@ #ifdef ENABLE_OSD if(priv->osd) priv->osd->free(priv->osd); + +#ifdef OSD_DOUBLE_BUFFER + if(priv->dbuf_pixmap) + g_object_unref (priv->dbuf_pixmap); +#endif #endif G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object); @@ -1673,7 +1772,12 @@ OsmGpsMap *map = OSM_GPS_MAP(object); OsmGpsMapPrivate *priv = map->priv; - g_free(priv->cache_dir); + if(priv->tile_dir) + g_free(priv->tile_dir); + + if(priv->cache_dir) + g_free(priv->cache_dir); + g_free(priv->repo_uri); g_free(priv->image_format); @@ -1730,10 +1834,7 @@ break; case PROP_TILE_CACHE_DIR: if ( g_value_get_string(value) ) - priv->cache_dir = g_value_dup_string (value); - break; - case PROP_TILE_CACHE_DIR_IS_FULL_PATH: - priv->cache_dir_is_full_path = g_value_get_boolean (value); + priv->tile_dir = g_value_dup_string (value); break; case PROP_ZOOM: priv->map_zoom = g_value_get_int (value); @@ -1761,9 +1862,53 @@ case PROP_GPS_POINT_R2: priv->ui_gps_point_outer_radius = g_value_get_int (value); break; - case PROP_MAP_SOURCE: + case PROP_MAP_SOURCE: { + gint old = priv->map_source; priv->map_source = g_value_get_int (value); - break; + if(old >= OSM_GPS_MAP_SOURCE_NULL && + priv->map_source != old && + priv->map_source >= OSM_GPS_MAP_SOURCE_NULL && + priv->map_source <= OSM_GPS_MAP_SOURCE_LAST) { + + /* we now have to switch the entire map */ + + /* flush the ram cache */ + g_hash_table_remove_all(priv->tile_cache); + + //check if the source given is valid + const char *uri = osm_gps_map_source_get_repo_uri(priv->map_source); + if (uri) { + g_debug("Setting map source from ID"); + g_free(priv->repo_uri); + + priv->repo_uri = g_strdup(uri); + priv->image_format = g_strdup( + osm_gps_map_source_get_image_format(priv->map_source)); + priv->max_zoom = osm_gps_map_source_get_max_zoom(priv->map_source); + priv->min_zoom = osm_gps_map_source_get_min_zoom(priv->map_source); + } + + /* create a new disk cache path */ + const char *fname = osm_gps_map_source_get_friendly_name(priv->map_source); + if(!fname) fname = "_unknown_"; + + if (priv->tile_dir) { + //the new cachedir is the given cache dir + the friendly name of the repo_uri + priv->cache_dir = + g_strdup_printf("%s%c%s", priv->tile_dir, G_DIR_SEPARATOR, fname); + g_debug("Adjusting cache dir %s -> %s", priv->tile_dir, priv->cache_dir); + } + + /* adjust zoom if necessary */ + if(priv->map_zoom > priv->max_zoom) + osm_gps_map_set_zoom(map, priv->max_zoom); + + if(priv->map_zoom < priv->min_zoom) + osm_gps_map_set_zoom(map, priv->min_zoom); + + inspect_map_uri(map); + + } } break; case PROP_IMAGE_FORMAT: priv->image_format = g_value_dup_string (value); break; @@ -1804,9 +1949,6 @@ case PROP_TILE_CACHE_DIR: g_value_set_string(value, priv->cache_dir); break; - case PROP_TILE_CACHE_DIR_IS_FULL_PATH: - g_value_set_boolean(value, priv->cache_dir_is_full_path); - break; case PROP_ZOOM: g_value_set_int(value, priv->map_zoom); break; @@ -1891,34 +2033,37 @@ #endif #ifdef ENABLE_OSD - #define SCROLL_STEP 10 - /* pressed inside OSD control? */ if(priv->osd) { - osd_button_t but = priv->osd->check(event->x, event->y); + osd_button_t but = priv->osd->check(priv->osd, event->x, event->y); if(but != OSD_NONE) { + int step = GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; priv->drag_counter = -1; switch(but) { case OSD_UP: - priv->map_y -= GTK_WIDGET(widget)->allocation.height/SCROLL_STEP; + priv->map_y -= step; priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); break; case OSD_DOWN: - priv->map_y += GTK_WIDGET(widget)->allocation.height/SCROLL_STEP; + priv->map_y += step; priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); break; case OSD_LEFT: - priv->map_x -= GTK_WIDGET(widget)->allocation.width/SCROLL_STEP; + priv->map_x -= step; priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); break; case OSD_RIGHT: - priv->map_x += GTK_WIDGET(widget)->allocation.width/SCROLL_STEP; + priv->map_x += step; priv->center_coord_set = FALSE; + osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); break; case OSD_IN: @@ -1936,8 +2081,6 @@ break; } - osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); - return FALSE; } } @@ -2023,11 +2166,11 @@ if (priv->drag_counter < 6) return FALSE; -#ifdef USE_MAEMO +#ifdef OSM_GPS_MAP_REFRESH /* reduce update frequency on maemo to keep screen update fluid */ static guint32 last_time = 0; - if(event->time - last_time < 100) return FALSE; + if(event->time - last_time < (1000/OSM_GPS_MAP_REFRESH)) return FALSE; last_time = event->time; #endif @@ -2039,18 +2182,6 @@ priv->drag_mouse_dx = x - priv->drag_start_mouse_x; priv->drag_mouse_dy = y - priv->drag_start_mouse_y; -#ifdef ENABLE_OSD - if(priv->osd) { - /* undo OSD */ - priv->osd->restore (priv->osd); - - /* draw new OSD */ - priv->osd->draw (priv->osd, - EXTRA_BORDER - priv->drag_mouse_dx, - EXTRA_BORDER - priv->drag_mouse_dy); - } -#endif - osm_gps_map_expose (widget, NULL); return FALSE; @@ -2066,18 +2197,27 @@ g_object_unref (priv->pixmap); priv->pixmap = gdk_pixmap_new ( - widget->window, - widget->allocation.width + EXTRA_BORDER * 2, - widget->allocation.height + EXTRA_BORDER * 2, - -1); + widget->window, + widget->allocation.width + EXTRA_BORDER * 2, + widget->allocation.height + EXTRA_BORDER * 2, + -1); #ifdef ENABLE_OSD + +#ifdef OSD_DOUBLE_BUFFER + if (priv->dbuf_pixmap) + g_object_unref (priv->dbuf_pixmap); + + priv->dbuf_pixmap = gdk_pixmap_new ( + widget->window, + widget->allocation.width, + widget->allocation.height, + -1); +#endif + /* the osd needs some references to map internal objects */ if(priv->osd) - { - priv->osd->pixmap = priv->pixmap; priv->osd->widget = widget; - } #endif /* and gc, used for clipping (I think......) */ @@ -2096,67 +2236,84 @@ { OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); - gdk_draw_drawable ( - widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - priv->pixmap, - 0,0, - priv->drag_mouse_dx - EXTRA_BORDER, - priv->drag_mouse_dy - EXTRA_BORDER, - -1,-1); - - //Paint white outside of the map if dragging. Its less - //ugly than painting the corrupted map - if(priv->drag_mouse_dx>EXTRA_BORDER) { - gdk_draw_rectangle ( - widget->window, - widget->style->white_gc, - TRUE, - 0, 0, - priv->drag_mouse_dx - EXTRA_BORDER, - widget->allocation.height); - } - else if (-priv->drag_mouse_dx > EXTRA_BORDER) - { - gdk_draw_rectangle ( - widget->window, - widget->style->white_gc, - TRUE, - priv->drag_mouse_dx + widget->allocation.width + EXTRA_BORDER, 0, - -priv->drag_mouse_dx - EXTRA_BORDER, - widget->allocation.height); - } - - if (priv->drag_mouse_dy>EXTRA_BORDER) { - gdk_draw_rectangle ( - widget->window, - widget->style->white_gc, - TRUE, - 0, 0, - widget->allocation.width, - priv->drag_mouse_dy - EXTRA_BORDER); - } - else if (-priv->drag_mouse_dy > EXTRA_BORDER) - { - gdk_draw_rectangle ( - widget->window, - widget->style->white_gc, - TRUE, - 0, priv->drag_mouse_dy + widget->allocation.height + EXTRA_BORDER, - widget->allocation.width, - -priv->drag_mouse_dy - EXTRA_BORDER); - } -#if 0 - if(!priv->dragging) - gdk_draw_drawable ( - widget->window, +#if defined(ENABLE_OSD) && defined(OSD_DOUBLE_BUFFER) + GdkDrawable *drawable = priv->dbuf_pixmap; +#else + GdkDrawable *drawable = widget->window; +#endif + + if (!priv->dragging && event) + { + gdk_draw_drawable (drawable, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + priv->pixmap, + event->area.x + EXTRA_BORDER, event->area.y + EXTRA_BORDER, + event->area.x, event->area.y, + event->area.width, event->area.height); + } + else + { + gdk_draw_drawable (drawable, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + priv->pixmap, + 0,0, + priv->drag_mouse_dx - EXTRA_BORDER, + priv->drag_mouse_dy - EXTRA_BORDER, + -1,-1); + + //Paint white outside of the map if dragging. Its less + //ugly than painting the corrupted map + if(priv->drag_mouse_dx>EXTRA_BORDER) { + gdk_draw_rectangle (drawable, + widget->style->white_gc, + TRUE, + 0, 0, + priv->drag_mouse_dx - EXTRA_BORDER, + widget->allocation.height); + } + else if (-priv->drag_mouse_dx > EXTRA_BORDER) + { + gdk_draw_rectangle (drawable, + widget->style->white_gc, + TRUE, + priv->drag_mouse_dx + widget->allocation.width + EXTRA_BORDER, 0, + -priv->drag_mouse_dx - EXTRA_BORDER, + widget->allocation.height); + } + + if (priv->drag_mouse_dy>EXTRA_BORDER) { + gdk_draw_rectangle (drawable, + widget->style->white_gc, + TRUE, + 0, 0, + widget->allocation.width, + priv->drag_mouse_dy - EXTRA_BORDER); + } + else if (-priv->drag_mouse_dy > EXTRA_BORDER) + { + gdk_draw_rectangle (drawable, + widget->style->white_gc, + TRUE, + 0, priv->drag_mouse_dy + widget->allocation.height + EXTRA_BORDER, + widget->allocation.width, + -priv->drag_mouse_dy - EXTRA_BORDER); + } + } + +#ifdef ENABLE_OSD + /* draw new OSD */ + if(priv->osd) + priv->osd->draw (priv->osd, drawable); + +#ifdef OSD_DOUBLE_BUFFER + gdk_draw_drawable (widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - priv->pixmap, - event->area.x + EXTRA_BORDER, - event->area.y + EXTRA_BORDER, - event->area.x, event->area.y, - event->area.width, event->area.height); + priv->dbuf_pixmap, + 0,0,0,0,-1,-1); +#endif + #endif + return FALSE; } @@ -2238,14 +2395,6 @@ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); g_object_class_install_property (object_class, - PROP_TILE_CACHE_DIR_IS_FULL_PATH, - g_param_spec_boolean ("tile-cache-is-full-path", - "tile cache is full path", - "if true, the path passed to tile-cache is interpreted as the full cache path", - FALSE, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_ZOOM, g_param_spec_int ("zoom", "zoom", @@ -2363,7 +2512,7 @@ -1, /* minimum property value */ G_MAXINT, /* maximum property value */ -1, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); + G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); g_object_class_install_property (object_class, PROP_IMAGE_FORMAT, @@ -2384,9 +2533,9 @@ case OSM_GPS_MAP_SOURCE_OPENSTREETMAP: return "OpenStreetMap"; case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: - return "OpenStreetMap Renderer"; - case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: - return "OpenAerialMap"; + return "OpenStreetMap Tiles@Home"; + case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: + return "OpenCycleMap"; case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: return "Maps-For-Free"; case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: @@ -2428,8 +2577,8 @@ return OSM_REPO_URI; case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: return "http://tah.openstreetmap.org/Tiles/tile/#Z/#X/#Y.png"; - case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: - return "http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/#Z/#X/#Y.jpg"; + case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: + return "http://c.andy.sandbox.cloudmade.com/tiles/cycle/#Z/#X/#Y.png"; case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: return "http://maps-for-free.com/layer/relief/z#Z/row#Y/#Z_#X-#Y.jpg"; case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: @@ -2467,9 +2616,11 @@ case OSM_GPS_MAP_SOURCE_NULL: case OSM_GPS_MAP_SOURCE_OPENSTREETMAP: case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: + case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: return "png"; - case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: + case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: + case OSM_GPS_MAP_SOURCE_GOOGLE_SATELLITE: case OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID: case OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET: case OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_SATELLITE: @@ -2477,8 +2628,6 @@ case OSM_GPS_MAP_SOURCE_YAHOO_STREET: case OSM_GPS_MAP_SOURCE_YAHOO_SATELLITE: case OSM_GPS_MAP_SOURCE_YAHOO_HYBRID: - case OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE: - case OSM_GPS_MAP_SOURCE_GOOGLE_SATELLITE: return "jpg"; default: return "bin"; @@ -2502,7 +2651,7 @@ case OSM_GPS_MAP_SOURCE_OPENSTREETMAP: return OSM_MAX_ZOOM; case OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER: - case OSM_GPS_MAP_SOURCE_OPENAERIALMAP: + case OSM_GPS_MAP_SOURCE_OPENCYCLEMAP: case OSM_GPS_MAP_SOURCE_GOOGLE_STREET: case OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID: case OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET: @@ -2736,67 +2885,6 @@ } void -osm_gps_map_osd_speed (OsmGpsMap *map, float speed) -{ - OsmGpsMapPrivate *priv; - - PangoContext *context = NULL; - PangoLayout *layout = NULL; - PangoFontDescription *desc = NULL; - - GdkColor color; - GdkGC *gc; - - gchar *buffer; - //static int x = 10, y = 10; - static int width = 0, height = 0; - - g_return_if_fail (OSM_IS_GPS_MAP (map)); - priv = map->priv; - - buffer = g_strdup_printf("%.0f", speed); - - /* pango initialisation */ - context = gtk_widget_get_pango_context (GTK_WIDGET(map)); - layout = pango_layout_new (context); - desc = pango_font_description_new(); - - pango_font_description_set_size (desc, 40 * PANGO_SCALE); - pango_layout_set_font_description (layout, desc); - pango_layout_set_text (layout, buffer, strlen(buffer)); - - gc = gdk_gc_new (GTK_WIDGET(map)->window); - - color.red = (0 > 50) ? 0xffff : 0; - color.green = 0; - color.blue = 0; - - gdk_gc_set_rgb_fg_color (gc, &color); - - /* faster / less flicker alternative:*/ - gdk_draw_drawable ( - GTK_WIDGET(map)->window, - GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(map)], - priv->pixmap, - 0,0, - 0,0, - width+10,width+10); - - gdk_draw_layout(GTK_WIDGET(map)->window, - gc, - 0, 0, - layout); - - /* set width and height */ - pango_layout_get_pixel_size(layout, &width, &height); - - g_free(buffer); - pango_font_description_free (desc); - g_object_unref (layout); - g_object_unref (gc); -} - -void osm_gps_map_draw_gps (OsmGpsMap *map, float latitude, float longitude, float heading) { int pixel_x, pixel_y; @@ -2990,4 +3078,9 @@ priv->osd = osd; } +void +osm_gps_map_repaint (OsmGpsMap *map) { + osm_gps_map_expose (GTK_WIDGET(map), NULL); +} + #endif