[cairo-commit] roadster/src Makefile.am, 1.4, 1.5 databasewindow.c, 1.3, 1.4 databasewindow.h, 1.1, 1.2 db.c, 1.6, 1.7 db.h, 1.1, 1.2 geometryset.c, 1.5, 1.6 geometryset.h, 1.1, 1.2 gpsclient.c, 1.3, 1.4 gpsclient.h, 1.1, 1.2 gui.c, 1.2, 1.3 import.c, 1.6, 1.7 import_tiger.c, 1.8, 1.9 layers.c, 1.5, 1.6 layers.h, 1.1, 1.2 main.c, 1.4, 1.5 mainwindow.c, 1.5, 1.6 map.c, 1.9, 1.10 point.c, NONE, 1.1 point.h, NONE, 1.1 pointstring.c, NONE, 1.1 pointstring.h, NONE, 1.1 search_road.c, 1.6, 1.7

Ian McIntosh commit at pdx.freedesktop.org
Fri Feb 25 20:41:42 PST 2005


Committed by: ian

Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv1886/src

Modified Files:
	Makefile.am databasewindow.c databasewindow.h db.c db.h 
	geometryset.c geometryset.h gpsclient.c gpsclient.h gui.c 
	import.c import_tiger.c layers.c layers.h main.c mainwindow.c 
	map.c search_road.c 
Added Files:
	point.c point.h pointstring.c pointstring.h 
Log Message:
        * track.c:
        * track.h:
        * point.c:
        * point.h:
        * pointstring.c:
        * pointstring.h: Added.
        * configure.ac: Updated for embedded mysql.
        * src/Makefile.am: Added new files.
        * databasewindow.c: Made all dead code.  (No need for database window with embedded mysql)
        * db.c: Assume string format from embedded DB is reasonable in db_parse_point() and db_parse_pointstring().
        * geometryset.c: Move point and pointstring code into separate files.
        * gpsclient.c: Misc cleanup.
        * gui.c: Remove databasewindow from startup code path.
        * import.c: Remove GnomeVFS init.
        * main.c: Add GnomeVFS init.  Create ~/.roadster if missing.
        * layers.c: Style tweaks.
        * mainwindow.c: Add quasi-hack to record/draw GPS tracks.
        * map.c: Layer "halo" setting is now a stroke width number, not a boolean. Don't call cairo_set_dash for solid lines.  New track drawing.
        * search_road.c: Use renamed pointstring functions.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/roadster/src/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.am	23 Feb 2005 17:22:07 -0000	1.4
+++ Makefile.am	26 Feb 2005 04:41:40 -0000	1.5
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-NULL = 
+NULL =
 
 INCLUDES= \
 	-DDATADIR=\"$(pkgdatadir)\" \
@@ -38,7 +38,10 @@
 	search_location.c\
 	search.c\
 	scenemanager.c\
-	databasewindow.c
+	databasewindow.c\
+	point.c\
+	pointstring.c\
+	track.c
 
 roadster_LDADD = \
 	$(GNOME_LIBS) \

Index: databasewindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/databasewindow.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- databasewindow.c	23 Feb 2005 17:22:07 -0000	1.3
+++ databasewindow.c	26 Feb 2005 04:41:40 -0000	1.4
@@ -20,7 +20,11 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
+
+#ifdef ROADSTER_DEAD_CODE
+
+
+
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 
@@ -82,3 +86,5 @@
 void databasewindow_on_connectbutton_clicked(void)
 {
 }
+
+#endif

Index: databasewindow.h
===================================================================
RCS file: /cvs/cairo/roadster/src/databasewindow.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- databasewindow.h	23 Feb 2005 17:43:50 -0000	1.1
+++ databasewindow.h	26 Feb 2005 04:41:40 -0000	1.2
@@ -20,7 +20,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
+
 #ifndef _DATABASEWINDOW_H
 #define _DATABASEWINDOW_H
 
@@ -29,6 +29,8 @@
 {
 #endif
 
+#ifdef ROADSTER_DEAD_CODE
+
 void databasewindow_init(GladeXML* pGladeXML);
 gboolean databasewindow_connect(void);
 
@@ -39,6 +41,10 @@
 */
 void databasewindow_on_connectbutton_clicked(void);
 
+#endif
+
+
+
 #ifdef __cplusplus
 }
 #endif

Index: db.c
===================================================================
RCS file: /cvs/cairo/roadster/src/db.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- db.c	23 Feb 2005 17:22:07 -0000	1.6
+++ db.c	26 Feb 2005 04:41:40 -0000	1.7
@@ -23,7 +23,7 @@
 
 #include <mysql.h>
 
-#if HAVE_MYSQL_EMBED
+#ifdef HAVE_MYSQL_EMBED
 # include <mysql_embed.h>
 #endif
 
@@ -31,6 +31,7 @@
 #include <gtk/gtk.h>
 #include <stdio.h>
 #include <string.h>
+#include <gnome-vfs-2.0/libgnomevfs/gnome-vfs.h>
 
 #include "db.h"
 #include "mainwindow.h"
@@ -65,7 +66,7 @@
 //						better for embedded or local servers
 // mysql_store_result - more client memory, gets all results right away and frees up server
 //						better for remote servers
-#define MYSQL_GET_RESULT(x)		mysql_use_result((x))
+#define MYSQL_GET_RESULT(x)		mysql_store_result((x))
 
 db_connection_t* g_pDB = NULL;
 
@@ -202,20 +203,43 @@
 // call once on program start-up
 void db_init()
 {
-#if HAVE_MYSQL_EMBED
+#ifdef HAVE_MYSQL_EMBED
+	g_print("Initializing embedded MySQL server: ");
+
+	gchar* pszDataDir = g_strdup_printf("%s/.roadster/data", g_get_home_dir());
+	gchar* pszSetDataDirCommand = g_strdup_printf("--datadir=%s", pszDataDir);
+
+	// Create directory if it doesn't exist
+	g_print("creating directory: %s\n", pszDataDir);
+	if(GNOME_VFS_OK != gnome_vfs_make_directory(pszDataDir, 0700)) {
+		g_print("failed to create directory: %s\n", pszDataDir);
+	}
+
+	gchar* apszServerOptions[] = {
+		"",	// program name -- unused
+		"--skip-innodb",	// don't bother with table types we don't use
+		"--skip-bdb",		//
+//		"--flush",			// seems like a good idea since users can quickly kill the app/daemon
+		pszSetDataDirCommand
+	};
+
 	// Initialize the embedded server
 	// NOTE: if not linked with libmysqld, this call will do nothing (but will succeed)
- 	if(mysql_server_init(0, NULL, NULL) != 0) {
-		g_print("mysql_server_init failed\n");
+ 	if(mysql_server_init(NUM_ELEMS(apszServerOptions), apszServerOptions, NULL) != 0) {
+		g_print("failed\n");
 		return;
 	}
+	g_free(pszDataDir);
+	g_free(pszSetDataDirCommand);
+
+	g_print("success\n");
 #endif
 }
 
 // call once on program shut-down
 void db_deinit()
 {
-#if HAVE_MYSQL_EMBED
+#ifdef HAVE_MYSQL_EMBED
 	// Close embedded server if present
 	mysql_server_end();
 #endif
@@ -237,6 +261,7 @@
 		g_warning("mysql_real_connect failed: %s\n", mysql_error(pMySQLConnection));
 		return FALSE;
 	}
+//	db_enable_keys(); // just in case
 
 	// on success, alloc our connection struct and fill it
 	db_connection_t* pNewConnection = g_new0(db_connection_t, 1);
@@ -478,7 +503,7 @@
 
 	p = pszText;
 
-	if(g_str_has_prefix(p, "POINT")) {
+	if(p[0] == 'P') { //g_str_has_prefix(p, "POINT")) {
 		// format is "POINT(1.2345 -5.4321)"
 
 		p += (6); 	// move past "POINT("
@@ -501,7 +526,7 @@
 {
 	// parse string and add points to the string
 	const gchar* p = pszText;
-	if(g_str_has_prefix(p, "LINESTRING")) {
+	if(p[0] == 'L') { //g_str_has_prefix(p, "LINESTRING")) {
 		// format is "LINESTRING(1.2345 5.4321, 10 10, 20 20)"
 		mappoint_t* pPoint;
 
@@ -664,8 +689,10 @@
 		" AddressRightStart INT2 UNSIGNED NOT NULL,"
 		" AddressRightEnd INT2 UNSIGNED NOT NULL,"
 		" Coordinates point NOT NULL,"
+		
+	    // lots of indexes:
 		" PRIMARY KEY (ID),"
-" INDEX(TypeID),"
+	    " INDEX(TypeID),"
 		" INDEX(AddressLeftStart, AddressLeftEnd),"
 		" INDEX(AddressRightStart, AddressRightEnd),"
 		" SPATIAL KEY (Coordinates));", NULL);
@@ -682,8 +709,9 @@
 	db_query("CREATE TABLE IF NOT EXISTS Road_RoadName("
 		" RoadID INT4 UNSIGNED NOT NULL,"
 		" RoadNameID INT4 UNSIGNED NOT NULL,"
-		" PRIMARY KEY (RoadID, RoadNameID),"
-		" INDEX(RoadNameID));", NULL);
+		
+	    " PRIMARY KEY (RoadID, RoadNameID),"	// allows search on (RoadID,RoadName) and just (RoadID)
+		" INDEX(RoadNameID));", NULL);			// allows search the other way, going from a Name to a RoadID
 
 	// Location
 	db_query("CREATE TABLE IF NOT EXISTS Location("
@@ -724,16 +752,20 @@
 
 void db_enable_keys(void)
 {
-	db_query("ALTER TABLE Road ENABLE KEYS", NULL);
-	db_query("ALTER TABLE RoadName ENABLE KEYS", NULL);
-	db_query("ALTER TABLE Road_RoadName ENABLE KEYS", NULL);
+//	g_print("Enabling keys\n");
+
+//	db_query("ALTER TABLE Road ENABLE KEYS", NULL);
+//	db_query("ALTER TABLE RoadName ENABLE KEYS", NULL);
+//	db_query("ALTER TABLE Road_RoadName ENABLE KEYS", NULL);
 }
 
 void db_disable_keys(void)
 {
-	db_query("ALTER TABLE Road DISABLE KEYS", NULL);
-	db_query("ALTER TABLE RoadName DISABLE KEYS", NULL);
-	db_query("ALTER TABLE Road_RoadName DISABLE KEYS", NULL);
+//	g_print("Disabling keys\n");
+	
+//	db_query("ALTER TABLE Road DISABLE KEYS", NULL);
+//	db_query("ALTER TABLE RoadName DISABLE KEYS", NULL);
+//	db_query("ALTER TABLE Road_RoadName DISABLE KEYS", NULL);
 }
 
 /*

Index: db.h
===================================================================
RCS file: /cvs/cairo/roadster/src/db.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- db.h	23 Feb 2005 17:43:50 -0000	1.1
+++ db.h	26 Feb 2005 04:41:40 -0000	1.2
@@ -42,6 +42,7 @@
 
 #include "map.h"
 #include "layers.h"
+#include "pointstring.h"
 
 void db_create_tables(void);
 

Index: geometryset.c
===================================================================
RCS file: /cvs/cairo/roadster/src/geometryset.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- geometryset.c	23 Feb 2005 17:22:07 -0000	1.5
+++ geometryset.c	26 Feb 2005 04:41:40 -0000	1.6
@@ -31,80 +31,9 @@
 #include "geometryset.h"
 #include "map.h"
 #include "util.h"
+#include "point.h"
+#include "pointstring.h"
 
-GMemChunk* g_pPointChunkAllocator;		// chunk allocators to be shared by all geometrysets
-GMemChunk* g_pPointStringChunkAllocator;
-
-void geometryset_init()
-{
-	// create memory allocators
-	g_pPointChunkAllocator = g_mem_chunk_new("point chunk allocator",
-			sizeof(mappoint_t), 1000, G_ALLOC_AND_FREE);
-	g_return_if_fail(g_pPointChunkAllocator != NULL);
-	
-	g_pPointStringChunkAllocator = g_mem_chunk_new("pointstring chunk allocator",
-			sizeof(pointstring_t), 1000, G_ALLOC_AND_FREE);
-	g_return_if_fail(g_pPointStringChunkAllocator != NULL);
-}
-
-/*******************************************************
-** point alloc/free
-*******************************************************/
-gboolean geometryset_util_new_point(mappoint_t** ppPoint)
-{
-	g_return_val_if_fail(ppPoint != NULL, FALSE);
-	g_return_val_if_fail(*ppPoint == NULL, FALSE);	// must be a pointer to a NULL pointer
-
-	// get a new point struct from the allocator
-	mappoint_t* pNew = g_mem_chunk_alloc0(g_pPointChunkAllocator);
-	if(pNew) {
-		*ppPoint = pNew;
-		return TRUE;
-	}
-	return FALSE;
-}
-
-static void geometryset_util_free_point(mappoint_t* pPoint)
-{
-	g_return_if_fail(pPoint != NULL);
-
-	// give back to allocator
-	g_mem_chunk_free(g_pPointChunkAllocator, pPoint);
-}
-
-/*******************************************************
-** pointstring alloc/free
-*******************************************************/
-
-// create a new pointstring (polygon and road)
-gboolean geometryset_util_new_pointstring(pointstring_t** ppPointString)
-{
-	g_return_val_if_fail(ppPointString != NULL, FALSE);
-	g_return_val_if_fail(*ppPointString == NULL, FALSE);	// must be a pointer to a NULL pointer
-
-	// allocate it
-	pointstring_t* pNew = g_mem_chunk_alloc0(g_pPointStringChunkAllocator);
-	if(pNew) {
-		// configure it
-		pNew->m_pPointsArray = g_ptr_array_sized_new(2);
-		*ppPointString = pNew;
-		return TRUE;
-	}
-	return FALSE;
-}
-
-// return a pointstring struct to the allocator
-void geometryset_util_free_pointstring(pointstring_t* pPointString)
-{
-	g_return_if_fail(pPointString != NULL);
-
-	int i;
-	for(i = (pPointString->m_pPointsArray->len - 1) ; i>=0 ; i--) {
-		mappoint_t* pPoint = g_ptr_array_remove_index_fast(pPointString->m_pPointsArray, i);
-		geometryset_util_free_point(pPoint);
-	}
-	g_mem_chunk_free(g_pPointStringChunkAllocator, pPointString);
-}
 
 /*******************************************************
 ** construction / destruction
@@ -133,7 +62,7 @@
 	// Free each pointstring
 	for(i = (pGeometrySet->m_pPointStringsArray->len - 1) ; i>=0 ; i--) {
 		pointstring_t* pPointString = g_ptr_array_remove_index_fast(pGeometrySet->m_pPointStringsArray, i);
-		geometryset_util_free_pointstring(pPointString);
+		pointstring_free(pPointString);
 	}
 }
 
@@ -154,7 +83,6 @@
 	pGeometrySet->m_pPointStringsArray = NULL;
 }
 
-
 gboolean geometryset_load_geometry(maprect_t* pRect)
 {
 	g_return_val_if_fail(pRect != NULL, FALSE);
@@ -175,8 +103,10 @@
 		   g_aLayers[i].m_Style.m_aSubLayers[1].m_afLineWidths[nZoomLevel-1] != 0.0)
 		{
 			gchar azLayerNumber[10];
+
 			if(nActiveLayerCount > 0) g_snprintf(azLayerNumber, 10, ",%d", i);
 			else g_snprintf(azLayerNumber, 10, "%d", i);
+
 			g_strlcat(azLayerNumberList, azLayerNumber, 200);
 			nActiveLayerCount++;
 		}
@@ -234,11 +164,11 @@
 
 			// Extract points
 			pointstring_t* pNewPointString = NULL;
-			if(!geometryset_util_new_pointstring(&pNewPointString)) {
+			if(!pointstring_alloc(&pNewPointString)) {
 				g_warning("out of memory loading pointstrings\n");
 				continue;
 			}
-			db_parse_pointstring(aRow[2], pNewPointString, geometryset_util_new_point);
+			db_parse_pointstring(aRow[2], pNewPointString, point_alloc);
 
 			// Build name by adding suffix, if one is present
 			gchar azFullName[100] = "";
@@ -277,24 +207,24 @@
 /*******************************************************
 ** Debug functions
 *******************************************************/
-void geometryset_debug_print(geometryset_t* pGeometrySet)
-{
-	if(pGeometrySet->m_pPointStringsArray == NULL) {
-		g_print("m_pPointStringsArray is NULL\n");
-	}
-	else {
-		g_print("pointstring list (%d items):\n", pGeometrySet->m_pPointStringsArray->len);
-		int i;
-		for(i=0 ; i<pGeometrySet->m_pPointStringsArray->len ; i++) {
-			pointstring_t* pPointString = g_ptr_array_index(pGeometrySet->m_pPointStringsArray, i);
-			
-			g_print("- string (%d items): ", pPointString->m_pPointsArray->len);
-			int j;
-			for(j=0 ; j<pPointString->m_pPointsArray->len ; j++) {
-				mappoint_t* pPoint = g_ptr_array_index(pPointString->m_pPointsArray, j);
-				g_print("(%.5f,%.5f), ", pPoint->m_fLatitude, pPoint->m_fLongitude);
-			}
-			g_print("\n");
-		}
-	}
-}
+// void geometryset_debug_print(geometryset_t* pGeometrySet)
+// {
+//     if(pGeometrySet->m_pPointStringsArray == NULL) {
+//         g_print("m_pPointStringsArray is NULL\n");
+//     }
+//     else {
+//         g_print("pointstring list (%d items):\n", pGeometrySet->m_pPointStringsArray->len);
+//         int i;
+//         for(i=0 ; i<pGeometrySet->m_pPointStringsArray->len ; i++) {
+//             pointstring_t* pPointString = g_ptr_array_index(pGeometrySet->m_pPointStringsArray, i);
+//
+//             g_print("- string (%d items): ", pPointString->m_pPointsArray->len);
+//             int j;
+//             for(j=0 ; j<pPointString->m_pPointsArray->len ; j++) {
+//                 mappoint_t* pPoint = g_ptr_array_index(pPointString->m_pPointsArray, j);
+//                 g_print("(%.5f,%.5f), ", pPoint->m_fLatitude, pPoint->m_fLongitude);
+//             }
+//             g_print("\n");
+//         }
+//     }
+// }

Index: geometryset.h
===================================================================
RCS file: /cvs/cairo/roadster/src/geometryset.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- geometryset.h	23 Feb 2005 17:43:50 -0000	1.1
+++ geometryset.h	26 Feb 2005 04:41:40 -0000	1.2
@@ -29,12 +29,6 @@
 	GPtrArray* m_pPointStringsArray;
 } geometryset_t;
 
-// holds points that form a road or polygon (park, etc.)
-typedef struct {
-	gchar* m_pszName;
-	GPtrArray* m_pPointsArray;
-} pointstring_t;
-
 #include "map.h"
 
 void geometryset_init(void);
@@ -43,12 +37,12 @@
 
 gboolean geometryset_new(geometryset_t** ppGeometrySet);
 
-gboolean geometryset_util_new_point(mappoint_t** ppPoint);
-gboolean geometryset_util_new_pointstring(pointstring_t** ppPointString);
-void geometryset_util_free_pointstring(pointstring_t* pPointString);
+//gboolean geometryset_util_new_point(mappoint_t** ppPoint);
+//gboolean geometryset_util_new_pointstring(pointstring_t** ppPointString);
+//void geometryset_util_free_pointstring(pointstring_t* pPointString);
 
 gboolean geometryset_load_geometry(maprect_t* pRect);
 
-void geometryset_debug_print(geometryset_t* pGeometrySet);
+//void geometryset_debug_print(geometryset_t* pGeometrySet);
 
 #endif

Index: gpsclient.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gpsclient.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gpsclient.c	23 Feb 2005 17:22:07 -0000	1.3
+++ gpsclient.c	26 Feb 2005 04:41:40 -0000	1.4
@@ -20,7 +20,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
+
 #include <gtk/gtk.h>
 #include <gps.h>	// gpslib
 #include "gpsclient.h"
@@ -31,12 +31,12 @@
 } g_GPSClient = {0};
 
 gboolean gpsclient_callback_data_waiting(GIOChannel *source, GIOCondition condition, gpointer data);
-//~ static void update_display(char *buf);
 
-static void gpsclient_callback_update(char* p)
+static void gpsclient_callback_raw_data(char* p)
 {
-//	g_print("gpsclient_callback_update(%s)\n", p);
+	// g_print("raw: %s\n", p);
 }
+
 void gpsclient_debug_print(void);
 
 static void gpsclient_connect(void)
@@ -51,40 +51,30 @@
 
 	// connect
  	g_GPSClient.m_pGPSConnection = gps_open("localhost", DEFAULT_GPSD_PORT);
-	g_GPSClient.m_pPublicGPSData->m_eStatus = GPS_STATUS_NO_GPSD;
 
 	if(g_GPSClient.m_pGPSConnection) {
-//		g_print("Connected to GPSD\n");
-		
-		// 
-		gps_set_raw_hook(g_GPSClient.m_pGPSConnection, gpsclient_callback_update);
-		
 		// turn on streaming of GPS data
 		gps_query(g_GPSClient.m_pGPSConnection, "w+x\n");
-//		g_print("gps_query = %d\n", b);
 
-//		g_print("g_GPSClient.m_pGPSConnection->gps_fd = %d\n", g_GPSClient.m_pGPSConnection->gps_fd);
-		g_io_add_watch(g_io_channel_unix_new(g_GPSClient.m_pGPSConnection->gps_fd), 
+		g_io_add_watch(g_io_channel_unix_new(g_GPSClient.m_pGPSConnection->gps_fd),
 			G_IO_IN, gpsclient_callback_data_waiting, NULL);
 
-//		g_print("g_io_add_watch = %d\n", x);
-	
-		// assume no device
+		// assume no GPS device is present
 		g_GPSClient.m_pPublicGPSData->m_eStatus = GPS_STATUS_NO_DEVICE;
 	}
 	else {
-//		g_print("FAILED to connect to GPSD\n");
-	}	
+		g_GPSClient.m_pPublicGPSData->m_eStatus = GPS_STATUS_NO_GPSD;
+	}
 }
+
 void gpsclient_init()
 {
 	g_GPSClient.m_pPublicGPSData = g_new0(gpsdata_t, 1);
-	
+
 	gpsclient_connect();
 }
 
-// fill structure with data
-gpsdata_t* gpsclient_getdata()
+const gpsdata_t* gpsclient_getdata()
 {
 	gpsclient_connect();	// connect if necessary
 	
@@ -94,8 +84,7 @@
 // callback for g_io_add_watch on the GPSD file descriptor
 gboolean gpsclient_callback_data_waiting(GIOChannel *source, GIOCondition condition, gpointer data)
 {
-//	g_print("gpsclient_callback_data_waiting\n");
-	gpsdata_t* l = g_GPSClient.m_pPublicGPSData;	// our public data struct
+	gpsdata_t* l = g_GPSClient.m_pPublicGPSData;	// our public data struct, for easy access
 
 	// is there data waiting on the socket?
 	if(condition == G_IO_IN) {
@@ -133,17 +122,14 @@
 					l->m_fSignalQuality = GPS_SIGNALQUALITY_1_TERRIBLE;
 				}
 
-				//
 				// Set speed
-				//
 				l->m_fSpeedInKilometersPerHour = (d->speed * KNOTS_TO_KPH);
 				l->m_fSpeedInMilesPerHour = (d->speed * KNOTS_TO_MPH);
 
-				// dampen noise
+				// Dampen Noise when not moving fast enough for trustworthy data
 				if(l->m_fSignalQuality <= GPS_SIGNALQUALITY_2_POOR &&
 					l->m_fSpeedInMilesPerHour <= 2.0)
 				{
-					g_print("low quality signal, setting speed to 0\n");
 					l->m_fSpeedInMilesPerHour = 0.0;
 					l->m_fSpeedInKilometersPerHour = 0.0;
 				}
@@ -157,18 +143,13 @@
 		else {
 			l->m_eStatus = GPS_STATUS_NO_DEVICE;
 		}
-	//	gpsclient_debug_print();
-	//	g_print("GPS Status: %d\n", l->m_eStatus);
 	}
-	return TRUE; // keep socket notification coming
+	return TRUE; // TRUE = keep socket notification coming
 }
 
-//~ static void update_display(char *buf)
-//~ {
-	//~ g_print("********************* what the hell does this do?\n");	
-//~ }
+#ifdef ROADSTER_DEAD_CODE
 
-void gpsclient_debug_print(void)
+static void gpsclient_debug_print(void)
 {
 	struct gps_data_t* d = g_GPSClient.m_pGPSConnection;	// gpsd data
 
@@ -189,3 +170,5 @@
 
 	g_print("gps_fd = %d\n\n", d->gps_fd);
 }
+
+#endif

Index: gpsclient.h
===================================================================
RCS file: /cvs/cairo/roadster/src/gpsclient.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gpsclient.h	23 Feb 2005 17:43:50 -0000	1.1
+++ gpsclient.h	26 Feb 2005 04:41:40 -0000	1.2
@@ -20,7 +20,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
- 
+
 #ifndef _GPSCLIENT_H
 #define _GPSCLIENT_H
 
@@ -64,7 +64,7 @@
 } gpsdata_t;
 
 void gpsclient_init(void);
-gpsdata_t* gpsclient_getdata(void);
+const gpsdata_t* gpsclient_getdata(void);
 
 #ifdef __cplusplus
 }

Index: gui.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gui.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- gui.c	23 Feb 2005 17:22:07 -0000	1.2
+++ gui.c	26 Feb 2005 04:41:40 -0000	1.3
@@ -66,25 +66,18 @@
 	importwindow_init(pGladeXML);
 	datasetwindow_init(pGladeXML);
 	welcomewindow_init(pGladeXML);
-	databasewindow_init(pGladeXML);
+//	databasewindow_init(pGladeXML);
 }
 
 void gui_run()
 {
-	if(databasewindow_connect()) {
-		db_create_tables();
-
-		if(db_is_empty()) {
-			welcomewindow_show();
-		}
-		else {
-			mainwindow_show();
-		}
-		gtk_main();
+	if(db_is_empty()) {
+		welcomewindow_show();
 	}
 	else {
-		return;
+		mainwindow_show();
 	}
+	gtk_main();
 }
 
 void gui_exit()

Index: import.c
===================================================================
RCS file: /cvs/cairo/roadster/src/import.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- import.c	23 Feb 2005 17:22:07 -0000	1.6
+++ import.c	26 Feb 2005 04:41:40 -0000	1.7
@@ -42,10 +42,6 @@
 
 gboolean import_from_uri(const gchar* pszURI)
 {
-	if(!gnome_vfs_init()) {	
-		g_warning("gnome_vfs_init failed\n");
-		return FALSE;
-	}
 	gboolean bResult = FALSE;
 
 	GnomeVFSFileInfo info;
@@ -55,7 +51,9 @@
 	}
 
 //	func_progress_callback(0.0, pCallbackData);
+
 	gchar* pszFileBaseName = info.name;
+
 	g_return_val_if_fail(pszFileBaseName != NULL, FALSE);
 	// does it look like a tgr file name (tgr00000.zip) ?
 	if(strlen(pszFileBaseName) == 12 && g_str_has_prefix(pszFileBaseName, "tgr") && g_str_has_suffix(pszFileBaseName, ".zip")) {
@@ -66,10 +64,10 @@
 
 		gint nTigerSetNumber = atoi(buf);
 		// just assume it's a TIGER file for now since it's all we support
-		
-//		db_disable_keys();
+
+		//	db_disable_keys();
 		bResult = import_tiger_from_uri(pszURI, nTigerSetNumber);
-//		db_enable_keys();
+		//	db_enable_keys();
 
 		if(bResult) {
 			importwindow_log_append("success.\n\n");
@@ -78,7 +76,7 @@
 			importwindow_log_append("\n** Failed.\n\n");
 		}
 	}
-	g_free(pszFileBaseName);
+//	g_free(pszFileBaseName);
 
 	// free file info
 	gnome_vfs_file_info_unref(&info);

Index: import_tiger.c
===================================================================
RCS file: /cvs/cairo/roadster/src/import_tiger.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- import_tiger.c	23 Feb 2005 17:22:07 -0000	1.8
+++ import_tiger.c	26 Feb 2005 04:41:40 -0000	1.9
@@ -391,20 +391,6 @@
 	return FALSE;
 }
 
-#if 0
-static void debug_print_string(char* str, gint len)
-{
-	char* p = str;
-	while(len > 0) {
-		g_print("(%c %02d)", *p, *p);
-		p++;
-		len--;
-		if(*p == '\0') break;
-	}
-	g_print("\n");
-}
-#endif
-
 static gchar* import_tiger_copy_line(const gchar* pszString)
 {
 	char azBuffer[LINE_LENGTH_MAX];
@@ -1108,3 +1094,18 @@
 
 	return TRUE;
 }
+
+#ifdef ROADSTER_DEAD_CODE
+static void debug_print_string(char* str, gint len)
+{
+	char* p = str;
+	while(len > 0) {
+		g_print("(%c %02d)", *p, *p);
+		p++;
+		len--;
+		if(*p == '\0') break;
+	}
+	g_print("\n");
+}
+#endif
+

Index: layers.c
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- layers.c	23 Feb 2005 17:22:07 -0000	1.5
+++ layers.c	26 Feb 2005 04:41:40 -0000	1.6
@@ -49,11 +49,11 @@
 /* 1 */	{LAYER_MINORSTREET, "Minor Roads",
 			{{
 			/* line widths @ zooms	  	  						 color 									  dash, join, cap	*/
-			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 6.0, 12.0, 18.0,36.0}, {159/255.0, 149/255.0, 127/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 4.5, 10.5, 16.5,34.5}, {255/255.0, 251/255.0, 255/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
+			{{0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 5.0, 12.0, 18.0,36.0}, {169/255.0, 159/255.0, 157/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
+			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.5, 10.0, 16.0,32.0}, {255/255.0, 251/255.0, 255/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
 			}},
 
-			{{0,0,0,0,0,0,0,8,14,25}, /* font size */
+			{{0,0,0,0,0,0,0,10,18,32}, /* font size */
 	 		 {0,0,0,0,0,0,0,0,0,0}, /* bold */
 			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
 			 {0,0,0,0}},
@@ -61,24 +61,24 @@
 
 /* 2 */	{LAYER_MAJORSTREET, "Major Roads",
 			{{
-			{{0.0, 0.0, 2.0, 3.0, 5.0, 10.0, 14.0, 17.0, 24.0,32.0}, {173/255.0, 162/255.0, 140/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 1.8, 2.5, 4.3, 9.0,  13.0, 15.5, 22.0,30.0}, {255/255.0, 251/255.0, 115/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
+			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 12.0, 17.0, 24.0, 36.0}, {173/255.0, 162/255.0, 140/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
+			{{0.0, 0.0, 1.8, 2.5, 3.3, 6.0, 10.0, 14.5, 22.0, 32.5}, {255/255.0, 251/255.0, 115/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
 			}},
 
-			{{0,0,0,0,0,6,8,10,16,26}, /* font size */
-			 {0,0,0,0,0,1,1,1,1,1}, /* bold */
+			{{0,0,0,0,0,8,10,12,20,34}, /* font size */
+			 {0,0,0,0,0,0,0,0,1,1}, /* bold */
 			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
 			 {0,0,0,0}},
 			NULL},
 
 /* 3 */	{LAYER_MINORHIGHWAY, "Minor Highways",
 			{{
-			{{0.0, 0.0, 4.0, 5.0, 8.0, 9.0, 17.0,22.0,28.0,36.0}, {173/255.0, 162/255.0, 140/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
-			{{0.0, 0.0, 3.5, 4.1, 6.8, 7.5, 15.0,20.0,26.0,34.0}, {255/255.0, 202/255.0, 58/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
-			}},
+			{{0.0, 0.0, 4.0, 5.0, 8.0, 9.0, 17.0,22.0,28.0,36.0}, {173/255.0, 142/255.0, 33/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND},
+			{{0.0, 0.0, 2.5, 3.1, 6.5, 7.0, 15.0,19.5,25.0,33.0}, {247/255.0, 223/255.0, 74/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
+			}},													// 255/255.0, 202/255.0, 58/255.0
 			
-			{{0,0,0,0,0,0,8,8,10,18}, /* font size */
-			 {0,0,0,0,0,0,0,0,0,0}, /* bold */
+			{{0,0,0,0,0,6,12,16,18,26}, /* font size */
+			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
 			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
 			 {0,0,0,0}},
 			NULL},
@@ -89,7 +89,7 @@
 			{{0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.5, 3.5,6.0,8.0}, {247/255.0, 223/255.0, 74/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_ROUND}
 			}},
 			
-			{{0,0,0,0,0,0,8,8,10,18}, /* font size */
+			{{0,0,0,0,0,0,0,0,0,0}, /* font size */
 			 {0,0,0,0,0,0,0,0,0,0}, /* bold */
 			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
 			 {0,0,0,0}},
@@ -101,8 +101,8 @@
 			{{0.0, 0.0, 2.0, 8.5,  10.0, 14.0, 20.0,26.0,32.0,36.0}, {239/255.0, 190/255.0, 33/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
 			}},
 			
-			{{0,0,0,0,0,0,8,8,10,18}, /* font size */
-			 {0,0,0,0,0,0,0,0,0,0}, /* bold */
+			{{0,0,0,0,0,6,8,10,16,26}, /* font size */
+			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
 			 {0,0,0,0,0,0,0,0,0,0}, /* halo */
 			 {0,0,0,0}},
 			NULL},
@@ -125,9 +125,9 @@
 			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.0, 3.0, 4.0, 7.0}, {80/255.0, 80/255.0, 110/255.0, 1.00}, 1, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
 			}},
 			
-			{{0,0,0,0,0,0,8,10,12,12}, /* font size */
+			{{0,0,0,0,0,0,10,10,10,10}, /* font size */
 			 {0,0,0,0,0,0,0,0,0,0}, /* bold */
-			 {0,0,0,0,0,0,1,1,1,1}, /* halo */
+			 {0,0,0,0,0,0,4,4,4,4}, /* halo */
 			 {0,0,0,0}},
 			NULL},
 
@@ -137,10 +137,10 @@
 			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {135/255.0, 172/255.0, 126/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
 			}},
 			
-			{{0,0,0,0,0,0,12,14,14,16}, /* font size */
+			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
 			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,1,1,1,1}, /* halo */
-			 {0.25,0.5,0.25, 1.0}},
+			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
+			 {0.1,0.1,0.1, 1.0}},
 			NULL},
 
 /* 9 */{LAYER_RIVER, "Rivers",
@@ -149,9 +149,9 @@
 			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_ROUND, CAIRO_LINE_CAP_ROUND}
 			}},
 			
-			{{0,0,0,0,0,0,12,14,14,16}, /* font size */
+			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
 			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,1,1,1,1}, /* halo */
+			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
 			 {128/255.0, 158/255.0, 180/255.0, 1.0}},
 			NULL},
 
@@ -161,10 +161,10 @@
 			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
 			}},
 			
-			{{0,0,0,0,0,0,12,14,14,16}, /* font size */
+			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
 			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,1,1,1,1}, /* halo */
-			 {128/255.0, 158/255.0, 180/255.0, 1.0}},
+			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
+			 {0.1,0.1,0.1, 1.0}},
 			NULL},
 
 /* 11 */{LAYER_MISC_AREA, "Misc Areas",
@@ -173,9 +173,9 @@
 			{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, {0/255.0, 0/255.0, 0/255.0, 1.00}, 0, CAIRO_LINE_JOIN_MITER, CAIRO_LINE_CAP_BUTT}
 			}},
 			
-			{{0,0,0,0,0,0,12,16,16,18}, /* font size */
+			{{0,0,0,0,0,0,10,12,12,14}, /* font size */
 			 {0,0,0,0,0,0,1,1,1,1}, /* bold */
-			 {0,0,0,0,0,0,1,1,1,1}, /* halo */
+			 {0,0,0,0,0,0,3,3,3,3}, /* halo */
 			 {0.25,0.25,0.25,1.0}},
 			NULL},
 };

Index: layers.h
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- layers.h	23 Feb 2005 17:43:50 -0000	1.1
+++ layers.h	26 Feb 2005 04:41:40 -0000	1.2
@@ -85,7 +85,7 @@
 typedef struct textlabelstyle {
 	gdouble m_afFontSizeAtZoomLevel[MAX_ZOOM_LEVEL];
 	gint m_abBoldAtZoomLevel[MAX_ZOOM_LEVEL];	// 0s or 1s
-	gint m_abHaloAtZoomLevel[MAX_ZOOM_LEVEL];	// 0s or 1s
+	gint m_afHaloAtZoomLevel[MAX_ZOOM_LEVEL];	// stroke width
 	color_t m_clrColor;
 	// font family...
 	// font style...

Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- main.c	23 Feb 2005 17:22:07 -0000	1.4
+++ main.c	26 Feb 2005 04:41:40 -0000	1.5
@@ -35,6 +35,9 @@
 #include "gpsclient.h"
 #include "locationset.h"
 #include "scenemanager.h"
+#include "point.h"
+#include "pointstring.h"
+#include "track.h"
 
 int main (int argc, char *argv[])
 {
@@ -45,17 +48,33 @@
 
 	gnome_init(PACKAGE, VERSION, argc, argv);
 
+	if(!gnome_vfs_init()) {	
+		g_warning("gnome_vfs_init failed\n");
+		return 1;
+	}
+	gchar* pszApplicationDir = g_strdup_printf("%s/.roadster", g_get_home_dir());
+	if(GNOME_VFS_OK != gnome_vfs_make_directory(pszApplicationDir, 0700)) {
+		g_print("failed to create directory: %s\n", pszApplicationDir);
+	}
+
 	/*
 	** init our modules
 	*/
+	point_init();
+	pointstring_init();
+	track_init();
+
 	scenemanager_init();
-	geometryset_init();
+	//geometryset_init();
 	locationset_init();
 	gpsclient_init();
 	gui_init();
 	layers_init();
 	db_init();
 
+	gboolean bConnected = db_connect(NULL, NULL, NULL, "");
+	db_create_tables();
+
 	map_set_zoomlevel(7);
 	mainwindow_statusbar_update_zoomscale();
 

Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mainwindow.c	23 Feb 2005 17:22:07 -0000	1.5
+++ mainwindow.c	26 Feb 2005 04:41:40 -0000	1.6
@@ -48,9 +48,9 @@
 #  include <cairo-xlib.h>
 #endif
 
-#define PROGRAM_NAME		"Roadster"
-#define PROGRAM_COPYRIGHT	"Copyright (c) 2005 Ian McIntosh"
-#define PROGRAM_DESCRIPTION	"Mapping for everyone!"
+#define PROGRAM_NAME			"Roadster"
+#define PROGRAM_COPYRIGHT		"Copyright (c) 2005 Ian McIntosh"
+#define PROGRAM_DESCRIPTION		"Mapping for everyone!"
 
 // Layerlist columns
 #define LAYERLIST_COLUMN_ENABLED	(0)
@@ -61,17 +61,8 @@
 
 #define SPEED_LABEL_FORMAT			("<span font_desc='32'>%.0f</span>")
 
-// Prototypes
-gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event);
-gboolean mainwindow_on_expose_event(GtkWidget *pDrawingArea, GdkEventExpose *event, gpointer data);
-gint mainwindow_on_configure_event(GtkWidget *pDrawingArea, GdkEventConfigure *event);
-void mainwindow_draw_map(void);
-
-void mainwindow_statusbar_update_zoomscale(void);
-void mainwindow_statusbar_update_position(void);
-void mainwindow_setup_selected_tool(void);
-
-gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer pData);
+// Settings
+#define TIMER_GPS_REDRAW_INTERVAL_MS	(2500)		// lower this (to 1?) when it's faster to redraw track
 
 // Types
 typedef struct {
@@ -89,6 +80,19 @@
 	kToolZoom = 1,
 } EToolType;
 
+
+// Prototypes
+gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event);
+gboolean mainwindow_on_expose_event(GtkWidget *pDrawingArea, GdkEventExpose *event, gpointer data);
+gint mainwindow_on_configure_event(GtkWidget *pDrawingArea, GdkEventConfigure *event);
+void mainwindow_draw_map(void);
+
+void mainwindow_statusbar_update_zoomscale(void);
+void mainwindow_statusbar_update_position(void);
+void mainwindow_setup_selected_tool(void);
+
+gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer pData);
+
 struct {
 	GtkWindow* m_pWindow;
 	GtkTooltips* m_pTooltips;
@@ -131,6 +135,8 @@
 	GdkPixmap* m_pOffscreenPixmap;
 	
 	EToolType m_eSelectedTool;
+
+	gint m_nCurrentGPSPath;
 } g_MainWindow = {0};
 
 // Data
@@ -299,7 +305,6 @@
 			-1);
 	}
 
-#define TIMER_GPS_REDRAW_INTERVAL_MS	(5000)
 	g_timeout_add(TIMER_GPS_REDRAW_INTERVAL_MS,
 			  (GSourceFunc)mainwindow_callback_on_gps_redraw_timeout,
 			  (gpointer)NULL);
@@ -736,6 +741,12 @@
 		
 		cairo_set_target_drawable(pCairoInstance, dpy, drawable);
 		map_draw(pCairoInstance);
+	
+		pointstring_t* pTrackPointString = track_get_pointstring(g_MainWindow.m_nCurrentGPSPath);
+		if(pTrackPointString) {
+			map_draw_gps_trail(pCairoInstance, pTrackPointString);
+		}
+
 	cairo_destroy(pCairoInstance);
 
 	gtk_widget_queue_draw(GTK_WIDGET(g_MainWindow.m_pDrawingArea));
@@ -812,12 +823,22 @@
 
 	gpsdata_t* pData = gpsclient_getdata();
 	if(pData->m_eStatus == GPS_STATUS_LIVE) {
+
+		if(g_MainWindow.m_nCurrentGPSPath == 0) {
+			// create a new track for GPS trail
+			g_MainWindow.m_nCurrentGPSPath = track_new();
+		}
+
+		track_add_point(g_MainWindow.m_nCurrentGPSPath, &pData->m_ptPosition);
+
 		// if(keep position centered) {
-		map_center_on_worldpoint(pData->m_ptPosition.m_fLatitude, pData->m_ptPosition.m_fLongitude);
-		mainwindow_statusbar_update_position();
-		mainwindow_draw_map();
+//         map_center_on_worldpoint(pData->m_ptPosition.m_fLatitude, pData->m_ptPosition.m_fLongitude);
+//         mainwindow_statusbar_update_position();
 		// }
 
+		// redraw because GPS icon/trail may be different
+		mainwindow_draw_map();
+
 		// update image and tooltip for GPS icon
 		util_set_image_to_stock(g_MainWindow.m_pStatusbarGPSIcon, GTK_STOCK_OK, GTK_ICON_SIZE_MENU);
 		gtk_tooltips_set_tip(GTK_TOOLTIPS(g_MainWindow.m_pTooltips), pWidget,

Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- map.c	23 Feb 2005 17:43:50 -0000	1.9
+++ map.c	26 Feb 2005 04:41:40 -0000	1.10
@@ -26,7 +26,11 @@
 #include <gnome.h>
 #include <math.h>
 
-#define HACK_AROUND_CAIRO_LINE_CAP_BUG
+#define HACK_AROUND_CAIRO_LINE_CAP_BUG	// enable to ensure roads have rounded caps if the style dictates
+
+#define ROAD_FONT	"Bitstream Vera Sans"
+#define AREA_FONT	"Bitstream Vera Sans" // "Bitstream Charter"
+
 
 #include "gui.h"
 #include "map.h"
@@ -54,6 +58,10 @@
 	TRUE
 };
 
+// ADD:
+// 'Mal' - ?
+// 'Trce - Trace
+
 struct {
 	gchar* m_pszLong;
 	gchar* m_pszShort;
@@ -523,7 +531,7 @@
 static void map_draw_background(cairo_t *pCairo)
 {
 	cairo_save(pCairo);
-		cairo_set_rgb_color(pCairo, 239/255.0, 231/255.0, 230/255.0);
+		cairo_set_rgb_color(pCairo, 247/255.0, 235/255.0, 230/255.0);
 		cairo_rectangle(pCairo, 0, 0, g_Map.m_WindowDimensions.m_uWidth, g_Map.m_WindowDimensions.m_uHeight);
 		cairo_fill(pCairo);
 	cairo_restore(pCairo);
@@ -592,7 +600,7 @@
 		fTotalLineLength += fLineLength;
 	}
 
-	gchar* pszFontFamily = "Bitstream Vera Sans";
+	gchar* pszFontFamily = ROAD_FONT;
 
 	cairo_save(pCairo);
 	cairo_select_font(pCairo, pszFontFamily,
@@ -760,10 +768,10 @@
 			cairo_rotate(pCairo, fAngleInRadians);
 			cairo_text_path(pCairo, azLabelSegment);
 
-			gboolean bDrawHalo = pLabelStyle->m_abHaloAtZoomLevel[pRenderMetrics->m_nZoomLevel-1];
-			if(bDrawHalo) {
+			gdouble fHaloSize = pLabelStyle->m_afHaloAtZoomLevel[pRenderMetrics->m_nZoomLevel-1];
+			if(fHaloSize >= 0) {
 				cairo_save(pCairo);
-					cairo_set_line_width(pCairo, 4);
+					cairo_set_line_width(pCairo, fHaloSize);
 					cairo_set_rgb_color(pCairo, 1.0,1.0,1.0);
 					cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_BEVEL);
 					//cairo_set_miter_limit(pCairo, 0.1);
@@ -830,7 +838,7 @@
 	gdouble fDrawX = fTotalX / pPointString->m_pPointsArray->len;
 	gdouble fDrawY = fTotalY / pPointString->m_pPointsArray->len;
 
-	gchar* pszFontFamily = "Bitstream Vera Sans";
+	gchar* pszFontFamily = AREA_FONT;
 
 	cairo_save(pCairo);
 
@@ -859,10 +867,10 @@
 		cairo_set_alpha(pCairo, fAlpha);
 		cairo_text_path(pCairo, pszLabel);
 
-		gboolean bDrawHalo = pLabelStyle->m_abHaloAtZoomLevel[pRenderMetrics->m_nZoomLevel-1];
-		if(bDrawHalo) {
+		gdouble fHaloSize = pLabelStyle->m_afHaloAtZoomLevel[pRenderMetrics->m_nZoomLevel-1];
+		if(fHaloSize >= 0) {
 			cairo_save(pCairo);
-				cairo_set_line_width(pCairo, 3);
+				cairo_set_line_width(pCairo, fHaloSize);
 				cairo_set_rgb_color(pCairo, 1.0,1.0,1.0);
 				cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_BEVEL);
 //				cairo_set_miter_limit(pCairo, 0.1);
@@ -1212,40 +1220,43 @@
 	gint iPoint;
 
 	gdouble fLineWidth = pSubLayerStyle->m_afLineWidths[pRenderMetrics->m_nZoomLevel-1];
-	if(fLineWidth == 0.0) return;	// Don't bother drawing with line width 0
+	if(fLineWidth <= 0.0) return;	// Don't draw invisible lines
 	if(pSubLayerStyle->m_clrColor.m_fAlpha == 0.0) return;	// invisible?
 
 	cairo_save(pCairo);
 
+	// Raise the tolerance way up for thin lines
+	gint nCapStyle = pSubLayerStyle->m_nCapStyle;
+
 	gdouble fTolerance;
-	if(fLineWidth <= 2.0) {
-		fTolerance = 5;
-	}
-	else if(fLineWidth <= 5.0) {
-		fTolerance = 1;
-	}
-	else { 	// anything bigger...
+	if(fLineWidth >= 6.0) {
 		fTolerance = 0.5;
 	}
+	else {
+		if(nCapStyle == CAIRO_LINE_CAP_ROUND) {
+			//g_print("forcing round->square cap style\n");
+			nCapStyle = CAIRO_LINE_CAP_SQUARE;
+		}
 
-	//g_print("setting tolerance %f\n", fTolerance);
+//         if(fLineWidth >= 3.0) {
+//             fTolerance = 1.2;
+//         }
+//         else {  // smaller...
+//             fTolerance = 10;
+//         }
+	}
 	cairo_set_tolerance(pCairo, fTolerance);
-
-	gint nCapStyle = pSubLayerStyle->m_nCapStyle;
-	if(nCapStyle == CAIRO_LINE_CAP_ROUND && fLineWidth <= 4.0) {
-		g_print("forcing square cap style\n");
-		nCapStyle = CAIRO_LINE_CAP_SQUARE;
+	cairo_set_line_join(pCairo, pSubLayerStyle->m_nJoinStyle);
+	cairo_set_line_cap(pCairo, nCapStyle);	/* CAIRO_LINE_CAP_BUTT, CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_CAP */
+	if(g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount > 1) {
+		cairo_set_dash(pCairo, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_pfList, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount, 0.0);
 	}
-	
+
 	// Set layer attributes	
 	cairo_set_rgb_color(pCairo, pSubLayerStyle->m_clrColor.m_fRed, pSubLayerStyle->m_clrColor.m_fGreen, pSubLayerStyle->m_clrColor.m_fBlue);
 	cairo_set_alpha(pCairo, pSubLayerStyle->m_clrColor.m_fAlpha);
 	cairo_set_line_width(pCairo, fLineWidth);
 
-	cairo_set_line_join(pCairo, pSubLayerStyle->m_nJoinStyle);
-	cairo_set_line_cap(pCairo, nCapStyle);	/* CAIRO_LINE_CAP_BUTT, CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_CAP */
-	cairo_set_dash(pCairo, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_pfList, g_aDashStyles[pSubLayerStyle->m_nDashStyle].m_nCount, 0.0);
-
 	for(iString=0 ; iString<pGeometry->m_pPointStringsArray->len ; iString++) {
 		pPointString = g_ptr_array_index(pGeometry->m_pPointStringsArray, iString);
 
@@ -1266,10 +1277,11 @@
 				cairo_line_to(pCairo, SCALE_X(pRenderMetrics, pPoint->m_fLongitude), SCALE_Y(pRenderMetrics, pPoint->m_fLatitude));
 			}
 #ifdef HACK_AROUND_CAIRO_LINE_CAP_BUG
-			cairo_stroke(pCairo);	// this is wrong place of it (see below)
+			cairo_stroke(pCairo);	// this is wrong place for it (see below)
 #endif
    		}
 	}
+
 #ifndef HACK_AROUND_CAIRO_LINE_CAP_BUG
 	// this is correct place to stroke, but we can't do this until Cairo fixes this bug:
 	// http://cairographics.org/samples/xxx_multi_segment_caps.html
@@ -1330,3 +1342,29 @@
 	}
 	return FALSE;
 }
+
+void map_draw_gps_trail(cairo_t* pCairo, pointstring_t* pPointString)
+{
+	rendermetrics_t renderMetrics = {0};
+	map_get_render_metrics(&renderMetrics);
+	rendermetrics_t* pRenderMetrics = &renderMetrics;
+
+	if(pPointString->m_pPointsArray->len > 2) {
+		mappoint_t* pPoint = g_ptr_array_index(pPointString->m_pPointsArray, 0);
+		
+		// move to index 0
+		cairo_move_to(pCairo, SCALE_X(pRenderMetrics, pPoint->m_fLongitude), SCALE_Y(pRenderMetrics, pPoint->m_fLatitude));
+
+		gint i;
+		for(i=1 ; i<pPointString->m_pPointsArray->len ; i++) {
+			pPoint = g_ptr_array_index(pPointString->m_pPointsArray, i);
+
+			cairo_line_to(pCairo, SCALE_X(pRenderMetrics, pPoint->m_fLongitude), SCALE_Y(pRenderMetrics, pPoint->m_fLatitude));
+		}
+
+		cairo_set_rgb_color(pCairo, 0.0, 0.0, 0.7);
+		cairo_set_alpha(pCairo, 0.6);
+		cairo_set_line_width(pCairo, 10);
+		cairo_stroke(pCairo);
+	}
+}

--- NEW FILE: point.c ---
/***************************************************************************
 *            point.c
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <gtk/gtk.h>
#include "map.h"
#include "point.h"

GMemChunk* g_pPointChunkAllocator;		// chunk allocators to be shared by all geometrysets

void point_init(void)
{
	// create memory allocators
	g_pPointChunkAllocator = g_mem_chunk_new("point chunk allocator",
			sizeof(mappoint_t), 1000, G_ALLOC_AND_FREE);
	g_return_if_fail(g_pPointChunkAllocator != NULL);
}

/*******************************************************
** point alloc/free
*******************************************************/
gboolean point_alloc(mappoint_t** ppPoint)
{
	g_return_val_if_fail(ppPoint != NULL, FALSE);
	g_return_val_if_fail(*ppPoint == NULL, FALSE);	// must be a pointer to a NULL pointer

	// get a new point struct from the allocator
	mappoint_t* pNew = g_mem_chunk_alloc0(g_pPointChunkAllocator);
	if(pNew) {
		*ppPoint = pNew;
		return TRUE;
	}
	return FALSE;
}

void point_free(mappoint_t* pPoint)
{
	g_return_if_fail(pPoint != NULL);

	// give back to allocator
	g_mem_chunk_free(g_pPointChunkAllocator, pPoint);
}


--- NEW FILE: point.h ---
/***************************************************************************
 *            point.h
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

void point_init(void);
gboolean point_alloc(mappoint_t** ppPoint);
void point_free(mappoint_t* pPoint);


--- NEW FILE: pointstring.c ---
/***************************************************************************
 *            pointstring.c
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <gtk/gtk.h>
#include "map.h"
#include "point.h"
#include "pointstring.h"

GMemChunk* g_pPointStringChunkAllocator;

void pointstring_init(void)
{
	g_pPointStringChunkAllocator = g_mem_chunk_new("pointstring chunk allocator",
			sizeof(pointstring_t), 1000, G_ALLOC_AND_FREE);
	g_return_if_fail(g_pPointStringChunkAllocator != NULL);
}

/*******************************************************
** pointstring alloc/free
*******************************************************/

// create a new pointstring
gboolean pointstring_alloc(pointstring_t** ppPointString)
{
	g_return_val_if_fail(ppPointString != NULL, FALSE);
	g_return_val_if_fail(*ppPointString == NULL, FALSE);	// must be a pointer to a NULL pointer

	// allocate it
	pointstring_t* pNew = g_mem_chunk_alloc0(g_pPointStringChunkAllocator);
	if(pNew) {
		// configure it
		pNew->m_pPointsArray = g_ptr_array_sized_new(2);
		*ppPointString = pNew;
		return TRUE;
	}
	return FALSE;
}

// return a pointstring struct to the allocator
void pointstring_free(pointstring_t* pPointString)
{
	g_return_if_fail(pPointString != NULL);

	int i;
	for(i = (pPointString->m_pPointsArray->len - 1) ; i>=0 ; i--) {
		mappoint_t* pPoint = g_ptr_array_remove_index_fast(pPointString->m_pPointsArray, i);
		point_free(pPoint);
	}
	g_mem_chunk_free(g_pPointStringChunkAllocator, pPointString);
}

// copies pPoint and adds it
void pointstring_append_point(pointstring_t* pPointString, mappoint_t* pPoint)
{
	mappoint_t* pNewPoint = NULL;
	point_alloc(&pNewPoint);

	memcpy(pNewPoint, pPoint, sizeof(mappoint_t));

	g_ptr_array_add(pPointString->m_pPointsArray, pNewPoint);
}


--- NEW FILE: pointstring.h ---
/***************************************************************************
 *            pointstring.h
 *
 *  Copyright  2005  Ian McIntosh
 *  ian_mcintosh at linuxadvocate.org
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _POINTSTRING_H_
#define _POINTSTRING_H_

// holds points that form a road or polygon (park, etc.)
typedef struct {
	gchar* m_pszName;
	GPtrArray* m_pPointsArray;
} pointstring_t;

void pointstring_init(void);
gboolean pointstring_alloc(pointstring_t** ppPointString);
void pointstring_free(pointstring_t* pPointString);
void pointstring_append_point(pointstring_t* pPointString, mappoint_t* pPoint);

#endif

Index: search_road.c
===================================================================
RCS file: /cvs/cairo/roadster/src/search_road.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- search_road.c	23 Feb 2005 17:22:07 -0000	1.6
+++ search_road.c	26 Feb 2005 04:41:40 -0000	1.7
@@ -27,7 +27,9 @@
 
 #include "db.h"
 #include "util.h"
-#include "geometryset.h"
+//#include "geometryset.h"
+#include "pointstring.h"
+#include "point.h"
 #include "searchwindow.h"
 #include "search.h"
 #include "search_road.h"
@@ -220,13 +222,13 @@
 			nCount++;
 			if(nCount <= SEARCH_RESULT_COUNT_LIMIT) {
 				pointstring_t* pPointString = NULL;
-				geometryset_util_new_pointstring(&pPointString);
-				db_parse_pointstring(aRow[3], pPointString, geometryset_util_new_point);
+				pointstring_alloc(&pPointString);
+				db_parse_pointstring(aRow[3], pPointString, point_alloc);
 
 //	g_print("raw: %s\n", aRow[3]);
 				search_road_filter_result(aRow[1], pRoadSearch->m_nNumber, atoi(aRow[2]), atoi(aRow[4]), atoi(aRow[5]), atoi(aRow[6]), atoi(aRow[7]), pPointString);
 //	g_print("%03d: Road.ID='%s' RoadName.Name='%s', Suffix=%s, L:%s-%s, R:%s-%s\n", nCount, aRow[0], aRow[1], aRow[3], aRow[4], aRow[5], aRow[6], aRow[7]);
-				geometryset_util_free_pointstring(pPointString);
+				pointstring_free(pPointString);
 			}
 		}
 		db_free_result(pResultSet);




More information about the cairo-commit mailing list