#include "utils.h"
#include "poi.h"
#include "path.h"
-#include "route.h"
-#include "track.h"
#include "settings.h"
#include "gps.h"
#include "mapper-types.h"
menu_cb_goto_destination(GtkAction *action)
{
if (gtk_map_goto_position(_dest)==FALSE) {
- MACRO_BANNER_SHOW_INFO(_window, _("Destination not set."));
+ MACRO_BANNER_SHOW_INFO(_window, _("Destination has not been set."));
} else {
- gtk_map_set_zoom(_map, 3);
- MACRO_BANNER_SHOW_INFO(_window, _("At destination"));
+ if (gtk_map_get_zoom(_map)>3)
+ gtk_map_set_zoom(_map, 3);
+ MACRO_BANNER_SHOW_INFO(_window, _("At destination point"));
}
return TRUE;
}
gboolean
menu_cb_goto_gps(GtkAction *action)
{
-gtk_map_set_center_mode(_map, CENTER_LATLON);
-MACRO_BANNER_SHOW_INFO(_window, _("At GPS coordinates."));
-map_update_location_from_center();
+if (gtk_map_set_center_mode(_map, CENTER_LATLON)) {
+ MACRO_BANNER_SHOW_INFO(_window, _("At GPS track coordinates."));
+ map_update_location_from_center();
+} else {
+ MACRO_BANNER_SHOW_INFO(_window, _("No active GPS track."));
+}
return TRUE;
}
gboolean
menu_cb_goto_nextway(GtkAction *action)
{
+GtkMapCenterMode *cm;
+
g_return_val_if_fail(_route, TRUE);
if (_route->next_way && _route->next_way->point->unity) {
- if (gtk_map_get_center_mode(_map) > 0)
+ g_object_get(_map, "center-mode", &cm);
+ if (cm>0)
set_action_activate("autocenter_none", TRUE);
- gtk_map_set_center_unit(_route->next_way->point->unitx, _route->next_way->point->unity);
+ gtk_map_set_center_unit(_map, _route->next_way->point->unitx, _route->next_way->point->unity);
+ if (gtk_map_get_zoom(_map)>3)
+ gtk_map_set_zoom(_map, 3);
} else {
MACRO_BANNER_SHOW_INFO(_window, _("There is no next waypoint."));
}
gboolean
menu_cb_goto_nearpoi(GtkAction *action)
{
+GtkMapCenterMode *cm;
gdouble lat, lon;
poi_info *p;
-if (gtk_map_get_center_mode(_map)!=CENTER_MANUAL) {
- /* Auto-Center is enabled - use the GPS position. */
- lat=_gps->data.lat;
- lon=_gps->data.lon;
-} else {
- gtk_map_get_center_latlon(_map, &lat, &lon);
-}
+gtk_map_get_center_latlon(_map, &lat, &lon);
p=poi_find_nearest(lat, lon);
-
if (p) {
gchar *banner;
cmenu_cb_way_distance_to(GtkAction *action)
{
WayPoint *way;
+gdouble lat, lon;
-if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+gtk_map_get_menu_latlon(_map, &lat, &lon);
+
+if ((way = route_find_nearest_waypoint(_route, lat, lon)))
route_show_distance_to(_route, way->point);
return TRUE;
cmenu_cb_way_delete(GtkAction *action)
{
WayPoint *way;
+gdouble lat, lon;
+
+gtk_map_get_menu_latlon(_map, &lat, &lon);
-if ((way = route_find_nearest_waypoint(_route, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+if ((way = route_find_nearest_waypoint(_route, lat, lon))) {
gchar buffer[BUFFER_SIZE];
GtkWidget *confirm;
w="UI";
break;
case MAPPER_INIT_GOTO:
- if (map_goto_position(&_home)==FALSE)
+ if (gtk_map_goto_position(_map, &_home)==FALSE)
g_printerr("Home is not set.\n");
else
- gtk_map_center_latlon(64.25, 22.00); /* XXX */
+ gtk_map_center_latlon(_map, 60.45, 22.25);
mis=MAPPER_INIT_DONE;
p=1.0;
w="Done";
/* First, set near_dist_squared with the new distance from
* near_point. */
near = route->near_point;
- near_dist_squared = DISTANCE_SQUARED(point, *near);
+ near_dist_squared = DISTANCE_SQUARED(*point, *near);
/* Now, search route for a closer point. If quick is TRUE, then we'll
* only search forward, only as long as we keep finding closer points.
*/
for (curr = route->near_point; curr++ != route->tail;) {
if (curr->unity) {
- guint dist_squared = DISTANCE_SQUARED(point, *curr);
+ guint dist_squared = DISTANCE_SQUARED(*point, *curr);
if (dist_squared <= near_dist_squared) {
near = curr;
near_dist_squared = dist_squared;
for (wnext = wcurr = route->next_way; wcurr != route->wtail; wcurr++) {
if (wcurr->point < near || (wcurr->point == near && quick
- && (route->next_wpt && (DISTANCE_SQUARED(point, *near) > route->next_way_dist_squared
- && DISTANCE_SQUARED(point, *route->next_wpt) < route->next_wpt_dist_squared))))
+ && (route->next_wpt && (DISTANCE_SQUARED(*point, *near) > route->next_way_dist_squared
+ && DISTANCE_SQUARED(*point, *route->next_wpt) < route->next_wpt_dist_squared))))
/* Okay, this else if expression warrants explanation. If the
* nearest track point happens to be a waypoint, then we want to
* check if we have "passed" that waypoint. To check this, we
}
if (wnext == route->wtail && (wnext->point < near || (wnext->point == near && quick
- && (route->next_wpt && (DISTANCE_SQUARED (_gps->data, *near) > route->next_way_dist_squared
- && DISTANCE_SQUARED(point, *route->next_wpt) < route->next_wpt_dist_squared)))))
+ && (route->next_wpt && (DISTANCE_SQUARED (*point, *near) > route->next_way_dist_squared
+ && DISTANCE_SQUARED(*point, *route->next_wpt) < route->next_wpt_dist_squared)))))
{
route->next_way = NULL;
route->next_wpt = NULL;
}
ret = TRUE;
}
- route->next_way_dist_squared = DISTANCE_SQUARED(_gps->data, *wnext->point);
+ route->next_way_dist_squared = DISTANCE_SQUARED(*point, *wnext->point);
if (route->next_wpt)
- route->next_wpt_dist_squared = DISTANCE_SQUARED(_gps->data, *route->next_wpt);
+ route->next_wpt_dist_squared = DISTANCE_SQUARED(*point, *route->next_wpt);
}
}
return ret;
gfloat altitude;
};
+#define DISTANCE_SQUARED(a, b) \
+ ((guint64)((((gint64)(b).unitx)-(a).unitx)*(((gint64)(b).unitx)-(a).unitx)) \
+ + (guint64)((((gint64)(b).unity)-(a).unity)*(((gint64)(b).unity)-(a).unity)))
+
/**
* A latitude/longitue pair
*/
gdouble path_get_distance_to(Path *path, Point *point, gdouble lat, gdouble lon);
+gboolean path_update_nears(Path *route, Point *point, gboolean quick);
+
gboolean path_insert_break(Path *path);
void path_insert_mark_text(Path *path, gchar *text);
void path_insert_mark_autonumber(Path *path);
guint i;
gchar *buffer;
-buffer = g_strdup_printf("%s\n\t%s\n%s", _("Delete category?"),
- dpoi->txt_label, _("WARNING: All POIs in that category will also be deleted!"));
+buffer = g_strdup_printf("%s\n\t%s\n%s", _("Delete category?"), dpoi->txt_label, _("WARNING: All POIs in that category will also be deleted!"));
dialog = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
g_free(buffer);
i = gtk_dialog_run(GTK_DIALOG(dialog));
if (poi_category_delete(dpoi->id)==FALSE)
popup_error(_window, _("Problem deleting category or POI"));
gtk_widget_hide_all(dpoi->dialog);
- map_poi_cache_clear();
- map_force_redraw();
+ gtk_map_refresh(_map);
}
return TRUE;
gtk_tree_model_get(model, &iter, ITEM_LAT, &lat, -1);
gtk_tree_model_get(model, &iter, ITEM_LON, &lon, -1);
-map_center_latlon(lat, lon);
+gtk_map_center_latlon(_map, lat, lon);
g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_update_location_from_center, NULL, NULL);
#if 0
gtk_widget_destroy(s->dialog);
#include "utils.h"
#include "poi.h"
#include "path.h"
-#include "route.h"
-#include "track.h"
#include "settings.h"
#include "gps.h"
#include "gtkmap.h"
ui_notebook.map=gtk_notebook_append_page(notebook, mapvbox, label);
/* Map widget */
-_map=gtkmap_new();
+_map=gtk_map_new();
gtk_paned_add2(GTK_PANED(hbox), _map);
#ifndef WITH_DEVICE_770
#include "mapper-types.h"
#include "ui-maemo.h"
#include "hildon-wrappers.h"
+#include "path.h"
#define SCALE_WIDTH (200)
GtkWidget *route_tree_view;
GtkWidget *track_tree_view;
-/** Context menu click location on map */
-guint _cmenu_position_x;
-guint _cmenu_position_y;
+Path *_route;
+Path *_track;
+
+AutoRouteDownloadData _autoroute_data;
void mapper_ui_init(void);
gboolean window_present();