]> err.no Git - mapper/blobdiff - src/path.h
Path: Add a function to add a raw point, more documentation
[mapper] / src / path.h
index 78cf2835cd83be1fa11d52b7cda5b90e19b2ceea..2f9ecd16d1b983c1c40ff4d073e577a9f57cfb72 100644 (file)
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
+#include "gpsdata.h"
+
+G_BEGIN_DECLS
+
+#define PATH_TYPE                              (path_get_type ())
+#define PATH(obj)                              (G_TYPE_CHECK_INSTANCE_CAST ((obj), PATH_TYPE, Path))
+#define PATH_CLASS(klass)              (G_TYPE_CHECK_CLASS_CAST ((klass), PATH_TYPE, PathClass))
+#define IS_PATH(obj)                   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PATH_TYPE))
+#define IS_PATH_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), PATH_TYPE))
+#define PATH_GET_CLASS(obj)            (G_TYPE_INSTANCE_GET_CLASS ((obj), PATH_TYPE, PathClass))
+
 typedef enum {
        PATH_TYPE_TRACK=0,
        PATH_TYPE_ROUTE,
        PATH_TYPE_FRIEND,
 } PathType;
 
+/* Path store items */
+typedef enum {
+    PATH_LATLON,
+    PATH_DISTANCE,
+    PATH_WAYPOINT,
+    PATH_LAT,
+    PATH_LON,
+    PATH_NUM_COLUMNS
+} PathStoreList;
+
+
 /* Fixed ID's */
 #define PATH_ID_MY_TRACK       (1)
 #define PATH_ID_MY_ROUTE       (2)
 
-/** A general definition of a point in the Mapper unit system. */
+/** 
+ * A general definition of a point in the Map unit system. 
+ */
 typedef struct _Point Point;
 struct _Point {
        guint unitx;
@@ -44,24 +68,48 @@ struct _Point {
        gfloat altitude;
 };
 
-/** A WayPoint, which is a Point with a description. */
+#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
+ */
+typedef struct _LatLon LatLon;
+struct _LatLon {
+       gdouble lat;
+       gdouble lon;
+};
+
+/** 
+ * A WayPoint, which is a Point with a description. 
+ */
 typedef struct _WayPoint WayPoint;
 struct _WayPoint {
        Point *point;
        gchar *desc;
 };
 
-/** A Path is a set of PathPoints and WayPoints. */
+/** 
+ * Path GObject
+ */
 typedef struct _Path Path;
 struct _Path {
+       GObject parent;
+
        PathType type;
        guint id;
+       gint sensitivity;
 
        /* Path points */
        Point *head;            /* points to first element in array; NULL if empty. */
        Point *tail;            /* points to last element in array. */
        Point *cap;                     /* points after last slot in array. */
 
+       /* Path bounding box */
+       LatLon min;
+       LatLon max;
+
        /* Path waypoints */
        WayPoint *whead;        /* points to first element in array; NULL if empty. */
        WayPoint *wtail;        /* points to last element in array. */
@@ -79,6 +127,10 @@ struct _Path {
        Point *next_wpt;
        guint64 next_wpt_dist_squared;
 
+       /* The waypoint we last announced */
+       WayPoint *announced_waypoint;
+       gint announce_notice_ratio;
+
        /* Path statistics */
        guint32 points;
        guint32 wpcnt;          /* Auto waypoint number counter */
@@ -97,10 +149,17 @@ struct _Path {
        time_t time;
 };
 
-/* Null point */
-Point _point_null;
+typedef struct _PathClass PathClass;
+struct _PathClass {
+       GObjectClass parent;
 
+       void (*new_point) (Path *path);
+       void (*new_break) (Path *path);
+       void (*new_waypoint) (Path *path);
+};
 
+/* Null point */
+Point _point_null;
 
 Path *path_new(PathType type, guint id);
 void path_free(Path *p);
@@ -113,11 +172,22 @@ gboolean path_wresize(Path *path, guint wsize);
 
 gdouble path_get_distance_to(Path *path, Point *point, gdouble lat, gdouble lon);
 
-gboolean path_insert_break(Path *path);
+void path_find_nearest_point(Path *path);
+gboolean path_update_nears(Path *route, Point *point, gboolean quick);
+
+gboolean path_add_latlon(Path *path, gdouble lat, gdouble lon, time_t ptime, gfloat speed, gfloat altitude);
+gboolean path_add_point(Path *path, GpsData *gps);
+
+gboolean path_has_points(Path *path);
+gboolean path_has_waypoints(Path *path);
+
+gboolean path_add_break(Path *path);
 void path_insert_mark_text(Path *path, gchar *text);
 void path_insert_mark_autonumber(Path *path);
 void path_insert_mark_audio(Path *path, gchar *audio);
 
+gboolean path_get_waypoint_latlon(WayPoint *way, gdouble *lat, gdouble *lon);
+
 GtkListStore *path_get_waypoints_store(Path *path);
 
 #define MACRO_PATH_INIT(path) { \
@@ -149,4 +219,6 @@ GtkListStore *path_get_waypoints_store(Path *path);
                path_wresize(&(route), (route).wcap - (route).whead + ARRAY_CHUNK_SIZE); \
 }
 
+G_END_DECLS
+
 #endif