91 |
return(strcasecmp(name, _(str)) == 0); |
return(strcasecmp(name, _(str)) == 0); |
92 |
} |
} |
93 |
|
|
94 |
|
static char *warn_text(context_t *context) { |
95 |
|
/* compute area size */ |
96 |
|
pos_float_t center_lat = (context->max.lat + context->min.lat)/2; |
97 |
|
double vscale = DEG2RAD(POS_EQ_RADIUS / 1000.0); |
98 |
|
double hscale = DEG2RAD(cos(DEG2RAD(center_lat)) * POS_EQ_RADIUS / 1000.0); |
99 |
|
|
100 |
|
double area = vscale * (context->max.lat - context->min.lat) * |
101 |
|
hscale * (context->max.lon - context->min.lon); |
102 |
|
|
103 |
|
return g_strdup_printf( |
104 |
|
_("The currently selected area is %.02f km² (%.02f mi²) in size. " |
105 |
|
"This is more than the recommended %.02f km² (%.02f mi²).\n\n" |
106 |
|
"Continuing may result in a big or failing download and low " |
107 |
|
"mapping performance in a densly mapped area (e.g. cities)!"), |
108 |
|
area, area/(KMPMIL*KMPMIL), |
109 |
|
WARN_OVER, WARN_OVER/(KMPMIL*KMPMIL) |
110 |
|
); |
111 |
|
} |
112 |
|
|
113 |
static void on_area_warning_clicked(GtkButton *button, gpointer data) { |
static void on_area_warning_clicked(GtkButton *button, gpointer data) { |
114 |
context_t *context = (context_t*)data; |
context_t *context = (context_t*)data; |
115 |
|
|
116 |
/* compute area size */ |
char *wtext = warn_text(context); |
117 |
|
warningf(context->dialog, wtext); |
118 |
|
g_free(wtext); |
119 |
|
} |
120 |
|
|
121 |
|
static gboolean area_warning(context_t *context) { |
122 |
|
gboolean ret = TRUE; |
123 |
|
|
124 |
|
/* check if area size exceeds recommended values */ |
125 |
pos_float_t center_lat = (context->max.lat + context->min.lat)/2; |
pos_float_t center_lat = (context->max.lat + context->min.lat)/2; |
126 |
double vscale = DEG2RAD(POS_EQ_RADIUS / 1000.0); |
double vscale = DEG2RAD(POS_EQ_RADIUS / 1000.0); |
127 |
double hscale = DEG2RAD(cos(DEG2RAD(center_lat)) * POS_EQ_RADIUS / 1000.0); |
double hscale = DEG2RAD(cos(DEG2RAD(center_lat)) * POS_EQ_RADIUS / 1000.0); |
129 |
double area = vscale * (context->max.lat - context->min.lat) * |
double area = vscale * (context->max.lat - context->min.lat) * |
130 |
hscale * (context->max.lon - context->min.lon); |
hscale * (context->max.lon - context->min.lon); |
131 |
|
|
132 |
warningf(context->dialog, |
if(area > WARN_OVER) { |
133 |
_("The currently selected area is %.02f km² (%.02f mi²) in size. " |
char *wtext = warn_text(context); |
|
"This is more than the recommended %.02f km² (%.02f mi²).\n\n" |
|
|
"Continuing may result in a big download and low mapping performance " |
|
|
"in a densly mapped area (e.g. cities)!"), |
|
|
area, area/(KMPMIL*KMPMIL), |
|
|
WARN_OVER, WARN_OVER/(KMPMIL*KMPMIL) |
|
|
); |
|
134 |
|
|
135 |
|
ret = yes_no_f(context->dialog, context->area->appdata, |
136 |
|
MISC_AGAIN_ID_AREA_TOO_BIG, MISC_AGAIN_FLAG_DONT_SAVE_NO, |
137 |
|
_("Area size warning!"), |
138 |
|
_("%s Do you really want to continue?"), wtext); |
139 |
|
|
140 |
|
g_free(wtext); |
141 |
|
} |
142 |
|
|
143 |
|
return ret; |
144 |
} |
} |
145 |
|
|
146 |
static void area_main_update(context_t *context) { |
static void area_main_update(context_t *context) { |
589 |
|
|
590 |
gboolean area_edit(area_edit_t *area) { |
gboolean area_edit(area_edit_t *area) { |
591 |
GtkWidget *vbox; |
GtkWidget *vbox; |
|
gboolean ok = FALSE; |
|
592 |
|
|
593 |
context_t context; |
context_t context; |
594 |
memset(&context, 0, sizeof(context_t)); |
memset(&context, 0, sizeof(context_t)); |
837 |
|
|
838 |
area_main_update(&context); |
area_main_update(&context); |
839 |
|
|
840 |
if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(context.dialog))) { |
gboolean leave = FALSE, ok = FALSE; |
841 |
|
do { |
842 |
|
if(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(context.dialog))) { |
843 |
|
if(area_warning(&context)) { |
844 |
|
leave = TRUE; |
845 |
|
ok = TRUE; |
846 |
|
} |
847 |
|
} else |
848 |
|
leave = TRUE; |
849 |
|
} while(!leave); |
850 |
|
|
851 |
|
if(ok) { |
852 |
/* copy modified values back to given storage */ |
/* copy modified values back to given storage */ |
853 |
area->min->lat = context.min.lat; |
area->min->lat = context.min.lat; |
854 |
area->min->lon = context.min.lon; |
area->min->lon = context.min.lon; |
855 |
area->max->lat = context.max.lat; |
area->max->lat = context.max.lat; |
856 |
area->max->lon = context.max.lon; |
area->max->lon = context.max.lon; |
|
ok = TRUE; |
|
857 |
} |
} |
858 |
|
|
859 |
#ifdef ENABLE_OSM_GPS_MAP |
#ifdef ENABLE_OSM_GPS_MAP |