155 |
return; |
return; |
156 |
} |
} |
157 |
|
|
158 |
pos_float_t center_lat = (context->max.lat + context->min.lat)/2; |
/* check if the position is invalid */ |
159 |
pos_float_t center_lon = (context->max.lon + context->min.lon)/2; |
if(isnan(context->min.lat) || isnan(context->min.lon) || |
160 |
|
isnan(context->min.lat) || isnan(context->min.lon)) { |
161 |
/* we know the widgets pixel size, we know the required real size, */ |
|
162 |
/* we want the zoom! */ |
/* no coordinates given: display the entire world */ |
163 |
double vzoom = LOG2((45.0 * context->map.widget->allocation.height)/ |
osm_gps_map_set_mapcenter(OSM_GPS_MAP(context->map.widget), |
164 |
((context->max.lat - context->min.lat)*32.0)); |
0.0, 0.0, 1); |
165 |
|
|
166 |
double hzoom = LOG2((45.0 * context->map.widget->allocation.width)/ |
osm_gps_map_clear_tracks(OSM_GPS_MAP(context->map.widget)); |
167 |
((context->max.lon - context->min.lon)*32.0)); |
} else { |
168 |
|
|
169 |
osm_gps_map_set_center(OSM_GPS_MAP(context->map.widget), |
pos_float_t center_lat = (context->max.lat + context->min.lat)/2; |
170 |
center_lat, center_lon); |
pos_float_t center_lon = (context->max.lon + context->min.lon)/2; |
171 |
|
|
172 |
/* use smallest zoom, so everything fits on screen */ |
/* we know the widgets pixel size, we know the required real size, */ |
173 |
osm_gps_map_set_zoom(OSM_GPS_MAP(context->map.widget), |
/* we want the zoom! */ |
174 |
(vzoom < hzoom)?vzoom:hzoom); |
double vzoom = LOG2((45.0 * context->map.widget->allocation.height)/ |
175 |
|
((context->max.lat - context->min.lat)*32.0)); |
176 |
/* ---------- draw border (as a gps track) -------------- */ |
|
177 |
osm_gps_map_clear_tracks(OSM_GPS_MAP(context->map.widget)); |
double hzoom = LOG2((45.0 * context->map.widget->allocation.width)/ |
178 |
|
((context->max.lon - context->min.lon)*32.0)); |
179 |
GSList *box = pos_append(NULL, context->min.lat, context->min.lon); |
|
180 |
box = pos_append(box, context->max.lat, context->min.lon); |
osm_gps_map_set_center(OSM_GPS_MAP(context->map.widget), |
181 |
box = pos_append(box, context->max.lat, context->max.lon); |
center_lat, center_lon); |
182 |
box = pos_append(box, context->min.lat, context->max.lon); |
|
183 |
box = pos_append(box, context->min.lat, context->min.lon); |
/* use smallest zoom, so everything fits on screen */ |
184 |
|
osm_gps_map_set_zoom(OSM_GPS_MAP(context->map.widget), |
185 |
osm_gps_map_add_track(OSM_GPS_MAP(context->map.widget), box); |
(vzoom < hzoom)?vzoom:hzoom); |
186 |
|
|
187 |
|
/* ---------- draw border (as a gps track) -------------- */ |
188 |
|
osm_gps_map_clear_tracks(OSM_GPS_MAP(context->map.widget)); |
189 |
|
|
190 |
|
GSList *box = pos_append(NULL, context->min.lat, context->min.lon); |
191 |
|
box = pos_append(box, context->max.lat, context->min.lon); |
192 |
|
box = pos_append(box, context->max.lat, context->max.lon); |
193 |
|
box = pos_append(box, context->min.lat, context->max.lon); |
194 |
|
box = pos_append(box, context->min.lat, context->min.lon); |
195 |
|
|
196 |
|
osm_gps_map_add_track(OSM_GPS_MAP(context->map.widget), box); |
197 |
|
} |
198 |
|
|
199 |
context->map.needs_redraw = FALSE; |
context->map.needs_redraw = FALSE; |
200 |
} |
} |
201 |
|
|