Diff of /trunk/src/map-tool.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 58 by harbaum, Mon Aug 17 10:51:56 2009 UTC revision 61 by harbaum, Tue Aug 18 14:32:45 2009 UTC
# Line 18  Line 18 
18   */   */
19    
20  #include "gpxview.h"  #include "gpxview.h"
21    #include "converter.h"
22  #include <math.h>    // for isnan  #include <math.h>    // for isnan
23    
24  #ifdef ENABLE_OSM_GPS_MAP  #ifdef ENABLE_OSM_GPS_MAP
# Line 27  Line 28 
28  #define MAP_SOURCE  OSM_GPS_MAP_SOURCE_OPENSTREETMAP  #define MAP_SOURCE  OSM_GPS_MAP_SOURCE_OPENSTREETMAP
29  #define GPS_DEFAULT_ZOOM 13  #define GPS_DEFAULT_ZOOM 13
30    
 /* equatorial radius in meters */  
 #define EQ_RADIUS     (6378137.0)  
   
 #define RAD2DEG(a)  (((a)*180.0)/M_PI)  
 #define DEG2RAD(a)  (((a)*M_PI)/180.0)  
   
31  #define PROXY_KEY  "/system/http_proxy/"  #define PROXY_KEY  "/system/http_proxy/"
32    
33  static const char *get_proxy_uri(appdata_t *appdata) {  static const char *get_proxy_uri(appdata_t *appdata) {
# Line 83  static void map_zoom(map_context_t *cont Line 78  static void map_zoom(map_context_t *cont
78    gtk_widget_set_sensitive(context->zoomout,    gtk_widget_set_sensitive(context->zoomout,
79             zoom > osm_gps_map_source_get_min_zoom(MAP_SOURCE));             zoom > osm_gps_map_source_get_min_zoom(MAP_SOURCE));
80    
   /* hmm ... this doesn't really work */  
   osm_gps_map_osd_speed(map, zoom);  
   
81    /* save new zoom */    /* save new zoom */
82    context->appdata->map.zoom = zoom;    context->appdata->map.zoom = zoom;
83  }  }
# Line 251  static cache_t *map_closest(map_context_ Line 243  static cache_t *map_closest(map_context_
243  /* translate between osm-gps-map positions and gpxview ones */  /* translate between osm-gps-map positions and gpxview ones */
244  pos_t coord2pos(coord_t coo) {  pos_t coord2pos(coord_t coo) {
245    pos_t pos;    pos_t pos;
246    pos.lat = RAD2DEG(coo.rlat);    pos.lat = rad2deg(coo.rlat);
247    pos.lon = RAD2DEG(coo.rlon);    pos.lon = rad2deg(coo.rlon);
248    return pos;    return pos;
249  }  }
250    
# Line 301  cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf Line 293  cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf
293    
294    // now draw this onto the original context    // now draw this onto the original context
295    cairo_set_source_surface(cr, image_surface, x, y);    cairo_set_source_surface(cr, image_surface, x, y);
296    
297    cairo_paint(cr);    cairo_paint(cr);
298  }  }
299    
300    #define LINE_SKIP  7
301    
302  static void  static void
303  balloon_draw_cb(cairo_t *cr, OsmGpsMapRect_t *rect, gpointer data) {  balloon_draw_cb(cairo_t *cr, OsmGpsMapRect_t *rect, gpointer data) {
304    cache_t *cache = (cache_t*)data;    cache_t *cache = (cache_t*)data;
# Line 329  balloon_draw_cb(cairo_t *cr, OsmGpsMapRe Line 324  balloon_draw_cb(cairo_t *cr, OsmGpsMapRe
324    /* ... and right of it the waypoint id */    /* ... and right of it the waypoint id */
325    cairo_text_extents_t extents;    cairo_text_extents_t extents;
326    
327    cairo_select_font_face (cr, "Sans",    if(cache->id) {
328                            CAIRO_FONT_SLANT_NORMAL,      cairo_select_font_face (cr, "Sans",
329                            CAIRO_FONT_WEIGHT_BOLD);                              CAIRO_FONT_SLANT_NORMAL,
330                                CAIRO_FONT_WEIGHT_BOLD);
331    
332    cairo_set_font_size (cr, 20.0);      cairo_set_font_size (cr, 20.0);
333    cairo_text_extents (cr, cache->id, &extents);      cairo_text_extents (cr, cache->id, &extents);
334    
335    /* draw right of icon vertically centered */      /* display id right of icon vertically centered */
336    x += gdk_pixbuf_get_width(icon) + 5;      x += gdk_pixbuf_get_width(icon) + 5;
337    y += (gdk_pixbuf_get_height(icon) + extents.height)/2;      y += (gdk_pixbuf_get_height(icon) + extents.height)/2;
338        cairo_move_to (cr, x, y);
339    cairo_move_to (cr, x,y);      cairo_set_source_rgba (cr, 0, 0, 0, 1);
340    printf("trying to draw %s\n", cache->id);      cairo_show_text (cr, cache->id);
341    cairo_set_source_rgba (cr, 0, 0, 0, 1);      cairo_stroke (cr);
342    cairo_show_text (cr, cache->id);  
343    cairo_stroke (cr);      y += (gdk_pixbuf_get_height(icon) - extents.height)/2 + LINE_SKIP;
344      } else
345        y += gdk_pixbuf_get_height(icon);
346    
347      /* return to the left border and below icon/text */
348      x = rect->x;
349    
350      /* everything from here uses the same font */
351      cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
352                              CAIRO_FONT_WEIGHT_NORMAL);
353      cairo_set_font_size (cr, 14.0);
354    
355      if(cache->name) {
356        /* draw cache name */
357        cairo_text_extents (cr, cache->name, &extents);
358        y += extents.height;
359        cairo_move_to (cr, x, y);
360        cairo_set_source_rgba (cr, 0, 0, 0, 1);
361        cairo_show_text (cr, cache->name);
362        cairo_stroke (cr);
363    
364        /* return to the left border and below text */
365        y += LINE_SKIP;
366        x = rect->x;
367      }
368    
369      if(cache->terrain) {
370        /* draw cache rating */
371        const char *terrain = "Terrain:";
372        icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2));
373        cairo_text_extents (cr, _(terrain), &extents);
374        y += (gdk_pixbuf_get_height(icon) + extents.height)/2;
375    
376        /* draw "Terrain:" string */
377        cairo_move_to (cr, x, y);
378        cairo_set_source_rgba (cr, 0, 0, 0, 1);
379        cairo_show_text (cr, _(terrain));
380        cairo_stroke (cr);
381        x += extents.width + 2;
382    
383        /* draw terrain stars */
384        cairo_draw_pixbuf(cr, icon, x, y -
385                          (gdk_pixbuf_get_height(icon) + extents.height)/2);
386    
387        x += gdk_pixbuf_get_width(icon) + LINE_SKIP;
388        y -= (gdk_pixbuf_get_height(icon) + extents.height)/2;
389      }
390    
391      if(cache->difficulty) {
392        const char *difficulty = "Difficulty:";
393        cairo_text_extents (cr, _(difficulty), &extents);
394        y += (gdk_pixbuf_get_height(icon) + extents.height)/2;
395    
396        /* draw "Difficulty:" string */
397        cairo_move_to (cr, x, y);
398        cairo_set_source_rgba (cr, 0, 0, 0, 1);
399        cairo_show_text (cr, _(difficulty));
400        cairo_stroke (cr);
401        x += extents.width + 2;
402    
403        icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2));
404        cairo_draw_pixbuf(cr, icon, x, y -
405                          (gdk_pixbuf_get_height(icon) + extents.height)/2);
406      }
407  }  }
408    
409  static gboolean  static gboolean

Legend:
Removed from v.58  
changed lines
  Added in v.61