]> err.no Git - mapper/blobdiff - src/route.c
Add header and cast properly.
[mapper] / src / route.c
index 32fafbbd60ee3419902d7e42eadeab95a7f52bd3..3144f60650eddf3a704738d10bfd6e6e75ed2d40 100644 (file)
@@ -72,8 +72,8 @@ confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Really clear the
 
 if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
        cancel_autoroute(FALSE);
-       MACRO_PATH_FREE(_route);
-       MACRO_PATH_INIT(_route);
+       route_deinit();
+       route_init();
        route_find_nearest_point();
        map_force_redraw();
 }
@@ -488,7 +488,7 @@ guint64 nearest_squared;
 Point pos = { unitx, unity, 0, NAN };
 
 wcurr = wnear = _route.whead;
-if (wcurr && wcurr != _route.wtail) {
+if (wcurr && wcurr->point && wcurr != _route.wtail) {
        nearest_squared = DISTANCE_SQUARED(pos, *(wcurr->point));
 
        while (wcurr++ != _route.wtail) {
@@ -500,13 +500,11 @@ if (wcurr && wcurr != _route.wtail) {
        }
 }
 
-if (wnear) {
+if (wnear && wnear->point) {
        /* Only use the waypoint if it is within a 6*_draw_width square drawn
         * around the position. This is consistent with select_poi(). */
-       if (abs(unitx - wnear->point->unitx) <
-           pixel2unit(3 * _draw_width)
-           && abs(unity - wnear->point->unity) <
-           pixel2unit(3 * _draw_width))
+       if (abs(unitx - wnear->point->unitx) < pixel2unit(3 * _draw_width) &&
+                       abs(unity - wnear->point->unity) < pixel2unit(3 * _draw_width))
                return wnear;
 }
 
@@ -735,50 +733,3 @@ if (_route.head != _route.tail) {
 
 /***/
 
-GtkListStore *
-route_generate_store(Path *route)
-{
-WayPoint *wcurr;
-GtkTreeIter iter;
-GtkListStore *store;
-gchar buffer1[80];
-gchar buffer2[32];
-gdouble lat1, lon1, lat2, lon2;
-gdouble sum=0.0;
-
-if (route->whead==route->wtail)
-       return NULL;
-
-wcurr=route->whead;
-
-if (!wcurr->point)
-       return NULL;
-
-unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat1, lon1);
-
-store = gtk_list_store_new(ROUTE_NUM_COLUMNS,G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
-while (wcurr!=route->wtail) {
-       if (!wcurr)
-               break;
-
-       unit2latlon(wcurr->point->unitx, wcurr->point->unity, lat2, lon2);
-       g_snprintf(buffer1, sizeof(buffer1), "%.05f,%.05f", lat2, lon2);
-       sum += calculate_distance(lat1, lon1, lat2, lon2);
-       g_snprintf(buffer2, sizeof(buffer2), "%.02f %s", sum * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
-
-       lat1=lat2;
-       lon1=lon2;
-
-       gtk_list_store_append(store, &iter);
-       gtk_list_store_set(store, &iter,
-        ROUTE_LATLON, buffer1,
-               ROUTE_DISTANCE, buffer2,
-               ROUTE_WAYPOINT, wcurr->desc,
-               -1);
-
-       wcurr++;
-}
-
-return store;
-}