]> err.no Git - mapper/commitdiff
Misc
authorKaj-Michael Lang <milang@tal.org>
Tue, 5 Aug 2008 14:59:39 +0000 (17:59 +0300)
committerKaj-Michael Lang <milang@tal.org>
Tue, 5 Aug 2008 14:59:39 +0000 (17:59 +0300)
libs/libgtkmap/gtkmap.c
libs/libgtkmap/path.c
libs/libgtkmap/path.h

index e0190b3a7a2d3690c434b5a614147abc009a907f..1fa1e7a1b987fa09fbc1fc9f45a970ef9461b2f0 100644 (file)
@@ -1108,6 +1108,7 @@ if (path->head==path->tail)
 
 map=GTK_MAP(widget);
 priv=GTK_MAP_GET_PRIVATE(map);
+
 prev=path->head;
 x1=unit2x(path->head->unitx);
 y1=unit2y(path->head->unity);
@@ -1126,18 +1127,21 @@ switch (path->type) {
        break;
 }
 cairo_set_line_width(priv->ct, priv->draw_width);
-#if 0
 cairo_rectangle(priv->ct, event->area.x, event->area.y, event->area.width, event->area.height);
 cairo_clip(priv->ct);
-#endif
-cairo_move_to(priv->ct, x1, y1);
+#if 0
 if (priv->rotate_view) {
-       gtk_map_update_rotation_matrix(priv,unit2x(priv->center.unitx),unit2y(priv->center.unity) );
+       gtk_map_update_rotation_matrix(priv, unit2x(priv->center.unitx), unit2y(priv->center.unity));
        cairo_set_matrix(priv->ct, &priv->matrix_rotate);
 }
 #endif
+cairo_move_to(priv->ct, x1, y1);
+#endif
 
 for (curr=path->head, wcurr=path->whead; curr++!=path->tail;) {
+       if (!curr->unitx)
+               continue;
+
        x2=unit2x(curr->unitx);
        y2=unit2y(curr->unity);
 
@@ -1151,8 +1155,6 @@ for (curr=path->head, wcurr=path->whead; curr++!=path->tail;) {
                        cairo_line_to(priv->ct, x2, y2);
 #else
                        gdk_draw_line(widget->window, priv->gc_track, x1, y1, x2, y2);
-                       x1=x2;
-                       y1=y2;
 #endif
                }
        }
@@ -1169,6 +1171,8 @@ for (curr=path->head, wcurr=path->whead; curr++!=path->tail;) {
                wcurr++;
        }
        prev=curr;
+       x1=x2;
+       y1=y2;
 }
 #if 0
 if (path->type==PATH_TYPE_ROUTE)
index ad96d8274fa63c18ed438a6ef99af9f5188e7cae..ef89c078fc285202e22713a844f860d2adb96477 100644 (file)
@@ -53,6 +53,9 @@ struct sql_select_stmt {
 };
 static struct sql_select_stmt sql;
 
+/* Null point */
+Point point_null;
+
 #define PATH_TABLE_PATHS "create table IF NOT EXISTS paths ( \
        nid             int primary key, \
        name    text not null, \
@@ -81,7 +84,7 @@ static struct sql_select_stmt sql;
 
 #define MACRO_PATH_INIT(path) { \
        (path).head = (path).tail = g_new0(Point, ARRAY_CHUNK_SIZE); \
-       *((path).tail) = _point_null; \
+       *((path).tail) = point_null; \
        (path).cap = (path).head + ARRAY_CHUNK_SIZE; \
        (path).whead = g_new0(WayPoint, ARRAY_CHUNK_SIZE); \
        (path).wtail = (path).whead; \
@@ -201,6 +204,8 @@ object_class->dispose=path_dispose;
 object_class->finalize=path_finalize;
 /* g_type_class_add_private (klass, sizeof(PathPrivate)); */
 
+memset(&point_null, 0, sizeof(point_null));
+
 signals[NEW_POINT]=g_signal_new("new-point", G_OBJECT_CLASS_TYPE(object_class),
        G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(PathClass, new_point),
        NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
@@ -361,6 +366,18 @@ guint unitx, unity;
 
 latlon2unit(lat, lon, &unitx, &unity);
 
+/* Initial point */
+if (path->head==path->tail) {
+       MACRO_PATH_INCREMENT_TAIL(*path);
+       path->tail->unitx=unitx;
+       path->tail->unity=unity;
+       path->tail->time=ptime;
+       path->tail->altitude=altitude;
+       path->speed=speed;
+       path->points=1;
+       return TRUE;
+}
+
 if (abs((gint)unitx-path->tail->unitx) > path->sensitivity || abs((gint)unity-path->tail->unity) > path->sensitivity) {
        if (path->tail->unity && path->tail->unitx) {
                gdouble plat, plon;
@@ -403,12 +420,15 @@ path_add_break(Path *path)
 g_return_val_if_fail(path, FALSE);
 g_return_val_if_fail(path->tail, FALSE);
 
+if (path->head==path->tail)
+       return FALSE;
+
 if (path->tail->unity && path->tail->unitx) {
        /* To mark a "break" in a track, we'll add a (0, 0) point and then 
           another instance of the most recent track point. */
 
        MACRO_PATH_INCREMENT_TAIL(*path);
-       *path->tail=_point_null;
+       *path->tail=point_null;
        MACRO_PATH_INCREMENT_TAIL(*path);
        *path->tail=path->tail[-2];
 
index b37ce24aa486062da0efc5b405874f98cea3a454..348b0ed262deeb70394dc0ac8cdf82c148b2e253 100644 (file)
@@ -170,9 +170,6 @@ struct _PathClass {
        void (*reached_waypoint) (Path *path);
 };
 
-/* Null point */
-Point _point_null;
-
 Path *path_new(PathType type, guint id);
 void path_free(Path *p);
 void path_clear(Path *p);