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

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

revision 34 by harbaum, Wed Jul 29 19:24:15 2009 UTC revision 35 by harbaum, Thu Jul 30 08:29:52 2009 UTC
# Line 63  static const char *get_proxy_uri(appdata Line 63  static const char *get_proxy_uri(appdata
63    
64        g_free(host);        g_free(host);
65      }      }
66        return proxy_buffer;
67    }    }
68    
69    return proxy_buffer;    return NULL;
70  }  }
71    
72  static void map_zoom(map_context_t *context, int step) {  static void map_zoom(map_context_t *context, int step) {
# Line 91  cb_map_zoomout(GtkButton *button, map_co Line 92  cb_map_zoomout(GtkButton *button, map_co
92    return FALSE;    return FALSE;
93  }  }
94    
 #define DEG2RAD(a)  ((a) * M_PI / 180.0)  
   
95  static gboolean  static gboolean
96  cb_map_gps(GtkButton *button, map_context_t *context) {  cb_map_gps(GtkButton *button, map_context_t *context) {
97    pos_t *refpos = get_pos(context->appdata);    pos_t *refpos = get_pos(context->appdata);
98    if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {    if(refpos && !isnan(refpos->lat) && !isnan(refpos->lon)) {
99      printf("pos is %f %f\n", refpos->lat, refpos->lon);      osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
100                                  refpos->lat, refpos->lon, 14);
101      osm_gps_map_set_center(OSM_GPS_MAP(context->widget),    } else {
102             DEG2RAD(refpos->lat), DEG2RAD(refpos->lon));      /* no coordinates given: display the entire world */
103        osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->widget),
104                                  0.0, 0.0, 1);
105    }    }
106    
107    return FALSE;    return FALSE;
# Line 131  static gboolean map_gps_update(gpointer Line 132  static gboolean map_gps_update(gpointer
132    return TRUE;    return TRUE;
133  }  }
134    
135    static gboolean on_map_configure(GtkWidget *widget,
136                                     GdkEventConfigure *event,
137                                     map_context_t *context) {
138    
139      cb_map_gps(NULL, context);
140    
141      return FALSE;
142    }
143    
144  void map(appdata_t *appdata) {  void map(appdata_t *appdata) {
145    map_context_t context;    map_context_t context;
# Line 151  void map(appdata_t *appdata) { Line 160  void map(appdata_t *appdata) {
160    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);
161    
162    char *path = g_strdup_printf("%s/map/", appdata->image_path);    char *path = g_strdup_printf("%s/map/", appdata->image_path);
163      const char *proxy = get_proxy_uri(appdata);
164    
165    context.widget = g_object_new(OSM_TYPE_GPS_MAP,    context.widget = g_object_new(OSM_TYPE_GPS_MAP,
166                  "repo-uri", MAP_SOURCE_OPENSTREETMAP,                  "repo-uri", MAP_SOURCE_OPENSTREETMAP,
                 "proxy-uri", get_proxy_uri(appdata),  
167                  "tile-cache", path,                  "tile-cache", path,
168                    proxy?"proxy-uri":NULL, proxy,
169                   NULL);                   NULL);
170    
171    g_free(path);    g_free(path);
172    
173      g_signal_connect(G_OBJECT(context.widget), "configure-event",
174                       G_CALLBACK(on_map_configure), &context);
175  #if 0  #if 0
176    g_signal_connect(G_OBJECT(context.widget), "button-release-event",    g_signal_connect(G_OBJECT(context.widget), "button-release-event",
177                     G_CALLBACK(on_map_button_release_event), &context);                     G_CALLBACK(on_map_button_release_event), &context);
# Line 197  void map(appdata_t *appdata) { Line 209  void map(appdata_t *appdata) {
209    
210    gtk_dialog_run(GTK_DIALOG(dialog));    gtk_dialog_run(GTK_DIALOG(dialog));
211    
212      gtk_timeout_remove(context.handler_id);
213    
214    gtk_widget_destroy(dialog);    gtk_widget_destroy(dialog);
   
215  }  }

Legend:
Removed from v.34  
changed lines
  Added in v.35