[cairo-commit] roadster/src Makefile.am, 1.7, 1.8 db.c, 1.9,
1.10 db.h, 1.4, 1.5 geometryset.c, 1.7, NONE geometryset.h,
1.2, NONE glyph.c, 1.1, 1.2 gotowindow.c, 1.4,
1.5 import_tiger.c, 1.10, 1.11 layers.c, 1.6, 1.7 layers.h,
1.2, 1.3 main.c, 1.7, 1.8 mainwindow.c, 1.9, 1.10 mainwindow.h,
1.2, 1.3 map.c, 1.11, 1.12 map.h, 1.2, 1.3 road.c, NONE,
1.1 road.h, NONE, 1.1 scenemanager.c, 1.5, 1.6 scenemanager.h,
1.1, 1.2 search.c, 1.3, 1.4 search_location.c, 1.5,
1.6 search_road.c, 1.9, 1.10 searchwindow.c, 1.6, 1.7 util.h,
1.1, 1.2
Ian McIntosh
commit at pdx.freedesktop.org
Tue Mar 1 11:48:23 PST 2005
Committed by: ian
Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv13032/src
Modified Files:
Makefile.am db.c db.h glyph.c gotowindow.c import_tiger.c
layers.c layers.h main.c mainwindow.c mainwindow.h map.c map.h
scenemanager.c scenemanager.h search.c search_location.c
search_road.c searchwindow.c util.h
Added Files:
road.c road.h
Removed Files:
geometryset.c geometryset.h
Log Message:
* road.c:
* road.h: Added with code removed from map module.
* geometryset.c:
* geometryset.h: Removed.
* map.c: Moved static data to road.c. Removed global map object and moved to allocated map object (all map_* functions take a map pointer now). Trying to switch to threaded rendering (currently disabled).
* db.c: Added support for locking.
* mainwindow.c: Now owns an allocated map object. Switched from single-click to double-click to move around.
* gotowindow.c: Talk to mainwindow only, not map.
* layers.c: Don't store loaded map data in the layers settings structure. (Stored in map object now.)
* main.c: Changed main_init() to return boolean.
* scenemanager.c: Removed global data, switched to allocated (a scenemanager is owned by a map).
* search.c: Can now deal with search strings containing newlines and other whitespace junk.
* search_road.c: Perform exact-match for street names of 3 or fewer chars for speed and results quality.
Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/roadster/src/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.am 28 Feb 2005 06:31:04 -0000 1.7
+++ Makefile.am 1 Mar 2005 19:48:21 -0000 1.8
@@ -23,7 +23,6 @@
mainwindow.c\
gotowindow.c\
map.c\
- geometryset.c\
layers.c\
import.c\
import_tiger.c\
@@ -42,7 +41,8 @@
point.c\
pointstring.c\
track.c\
- glyph.c
+ glyph.c\
+ road.c
roadster_LDADD = \
$(GNOME_LIBS) \
Index: db.c
===================================================================
RCS file: /cvs/cairo/roadster/src/db.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- db.c 28 Feb 2005 03:25:23 -0000 1.9
+++ db.c 1 Mar 2005 19:48:21 -0000 1.10
@@ -37,7 +37,6 @@
#include "db.h"
#include "mainwindow.h"
-#include "geometryset.h"
#include "util.h"
#include "layers.h"
#include "locationset.h"
@@ -54,12 +53,23 @@
#define MYSQL_GET_RESULT(x) mysql_store_result((x))
db_connection_t* g_pDB = NULL;
+GMutex* g_pDBMutex = NULL;
+
+void db_lock(void)
+{
+ g_mutex_lock(g_pDBMutex);
+}
+
+void db_unlock(void)
+{
+ g_mutex_unlock(g_pDBMutex);
+}
gboolean db_query(const gchar* pszSQL, db_resultset_t** ppResultSet)
{
g_assert(pszSQL != NULL);
if(g_pDB == NULL) return FALSE;
-
+
if(mysql_query(g_pDB->m_pMySQLConnection, pszSQL) != MYSQL_RESULT_SUCCESS) {
g_warning("db_query: %s (SQL: %s)\n", mysql_error(g_pDB->m_pMySQLConnection), pszSQL);
return FALSE;
@@ -67,7 +77,7 @@
// get result?
if(ppResultSet != NULL) {
- *ppResultSet = (db_resultset_t*)MYSQL_GET_RESULT(g_pDB->m_pMySQLConnection);
+ *ppResultSet = (db_resultset_t*)MYSQL_GET_RESULT(g_pDB->m_pMySQLConnection);
}
return TRUE;
}
@@ -76,7 +86,7 @@
{
g_assert(pszSQL != NULL);
if(g_pDB == NULL) return FALSE;
-
+
if(mysql_query(g_pDB->m_pMySQLConnection, pszSQL) != MYSQL_RESULT_SUCCESS) {
g_warning("db_query: %s (SQL: %s)\n", mysql_error(g_pDB->m_pMySQLConnection), pszSQL);
return FALSE;
@@ -182,6 +192,8 @@
// call once on program start-up
void db_init()
{
+ g_pDBMutex = g_mutex_new();
+
#ifdef HAVE_MYSQL_EMBED
gchar* pszDataDir = g_strdup_printf("%s/.roadster/data", g_get_home_dir());
gchar* pszSetDataDirCommand = g_strdup_printf("--datadir=%s", pszDataDir);
@@ -572,7 +584,7 @@
" Name VARCHAR(30) NOT NULL,"
" SuffixID INT1 UNSIGNED NOT NULL,"
" PRIMARY KEY (ID),"
- " UNIQUE KEY (Name(30), SuffixID));", NULL);
+ " UNIQUE KEY (Name(15), SuffixID));", NULL);
// Road_RoadName
db_query("CREATE TABLE IF NOT EXISTS Road_RoadName("
Index: db.h
===================================================================
RCS file: /cvs/cairo/roadster/src/db.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- db.h 28 Feb 2005 03:25:23 -0000 1.4
+++ db.h 1 Mar 2005 19:48:21 -0000 1.5
@@ -93,4 +93,7 @@
gboolean db_city_get_id(const gchar* pszName, gint nStateID, gint* pnReturnID);
gboolean db_state_get_id(const gchar* pszName, gint* pnReturnID);
+void db_lock(void);
+void db_unlock(void);
+
#endif
--- geometryset.c DELETED ---
--- geometryset.h DELETED ---
Index: glyph.c
===================================================================
RCS file: /cvs/cairo/roadster/src/glyph.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- glyph.c 28 Feb 2005 03:34:04 -0000 1.1
+++ glyph.c 1 Mar 2005 19:48:21 -0000 1.2
@@ -42,7 +42,7 @@
void glyph_init(void)
{
g_Glyph.m_pGlyphArray = g_ptr_array_new();
- g_ptr_array_add(g_Glyph.m_pGlyphArray, NULL); // index 0 is taken!
+ g_ptr_array_add(g_Glyph.m_pGlyphArray, NULL); // index 0 is taken! (it's the "no glyph" value)
}
gint glyph_load(const gchar* pszPath)
@@ -85,17 +85,17 @@
void glyph_draw_centered(cairo_t* pCairo, gint nGlyphHandle, gdouble fX, gdouble fY)
{
+ if(nGlyphHandle == 0) return;
+
glyph_t* pGlyph = NULL;
if(!glyph_lookup(nGlyphHandle, &pGlyph)) {
- // use a default glyph?
- return;
+ g_assert_not_reached();
}
cairo_save(pCairo);
-// cairo_scale(pCairo, 2, 2);
- cairo_set_alpha(pCairo, 0.5);
- cairo_translate(pCairo, (fX - (pGlyph->m_nWidth/2)), (fY - (pGlyph->m_nHeight/2)));
- svg_cairo_render(pGlyph->m_pCairoSVG, pCairo);
+ cairo_set_alpha(pCairo, 0.5);
+ cairo_translate(pCairo, (fX - (pGlyph->m_nWidth/2)), (fY - (pGlyph->m_nHeight/2)));
+ svg_cairo_render(pGlyph->m_pCairoSVG, pCairo);
cairo_restore(pCairo);
}
Index: gotowindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gotowindow.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gotowindow.c 28 Feb 2005 03:25:23 -0000 1.4
+++ gotowindow.c 1 Mar 2005 19:48:21 -0000 1.5
@@ -153,7 +153,7 @@
// TODO: error checking for 0 (meaning either bad text "3a21" or "000" etc.
- map_set_centerpoint(&pt);
+ mainwindow_set_centerpoint(&pt);
mainwindow_draw_map();
mainwindow_statusbar_update_position();
return TRUE;
Index: import_tiger.c
===================================================================
RCS file: /cvs/cairo/roadster/src/import_tiger.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- import_tiger.c 26 Feb 2005 09:37:36 -0000 1.10
+++ import_tiger.c 1 Mar 2005 19:48:21 -0000 1.11
@@ -31,6 +31,7 @@
#include "util.h"
#include "import_tiger.h"
#include "importwindow.h"
+#include "road.h"
#define TIGER_RT1_LINE_LENGTH (230)
#define TIGER_RT2_LINE_LENGTH (210)
@@ -494,7 +495,7 @@
gchar achType[5];
import_tiger_read_string(&pLine[50-1], 4, &achType[0]);
// g_print("%30s is type %s\n", pRecord->m_achName, achType);
- map_road_suffix_atoi(achType, &pRecord->m_nRoadNameSuffixID);
+ road_suffix_atoi(achType, &pRecord->m_nRoadNameSuffixID);
if(achType[0] != '\0' && pRecord->m_nRoadNameSuffixID == ROAD_SUFFIX_NONE) {
g_print("type '%s' couldn't be looked up\n", achType);
Index: layers.c
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- layers.c 26 Feb 2005 04:41:40 -0000 1.6
+++ layers.c 1 Mar 2005 19:48:21 -0000 1.7
@@ -43,8 +43,8 @@
{{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}},
- NULL},
+ {0,0,0,0}}
+ },
/* 1 */ {LAYER_MINORSTREET, "Minor Roads",
{{
@@ -53,11 +53,11 @@
{{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,10,18,32}, /* font size */
+ {{0,0,0,0,0,0,0,10,14,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}},
- NULL},
+ {0,0,0,0}}
+ },
/* 2 */ {LAYER_MAJORSTREET, "Major Roads",
{{
@@ -68,8 +68,8 @@
{{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},
+ {0,0,0,0}}
+ },
/* 3 */ {LAYER_MINORHIGHWAY, "Minor Highways",
{{
@@ -80,8 +80,8 @@
{{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},
+ {0,0,0,0}}
+ },
/* 4 */ {LAYER_MINORHIGHWAY_RAMP, "Minor Highway Ramps",
{{
@@ -92,8 +92,8 @@
{{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}},
- NULL},
+ {0,0,0,0}}
+ },
/* 5 */ {LAYER_MAJORHIGHWAY, "Major Highways",
{{
@@ -104,8 +104,8 @@
{{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},
+ {0,0,0,0}}
+ },
/* 6 */ {LAYER_MAJORHIGHWAY_RAMP, "Major Highway Ramps",
{{
@@ -116,8 +116,8 @@
{{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}},
- NULL},
+ {0,0,0,0}}
+ },
/* 7 */ {LAYER_RAILROAD, "Railroads",
{{
@@ -128,8 +128,8 @@
{{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,4,4,4,4}, /* halo */
- {0,0,0,0}},
- NULL},
+ {0,0,0,0}}
+ },
/* 8 */ {LAYER_PARK, "Parks",
{{
@@ -140,8 +140,8 @@
{{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,3,3,3,3}, /* halo */
- {0.1,0.1,0.1, 1.0}},
- NULL},
+ {0.1,0.1,0.1, 1.0}}
+ },
/* 9 */{LAYER_RIVER, "Rivers",
{{
@@ -152,8 +152,8 @@
{{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,3,3,3,3}, /* halo */
- {128/255.0, 158/255.0, 180/255.0, 1.0}},
- NULL},
+ {128/255.0, 158/255.0, 180/255.0, 1.0}}
+ },
/* 10 */{LAYER_LAKE, "Lakes",
{{
@@ -164,8 +164,8 @@
{{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,3,3,3,3}, /* halo */
- {0.1,0.1,0.1, 1.0}},
- NULL},
+ {0.1,0.1,0.1, 1.0}}
+ },
/* 11 */{LAYER_MISC_AREA, "Misc Areas",
{{
@@ -176,22 +176,6 @@
{{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,3,3,3,3}, /* halo */
- {0.25,0.25,0.25,1.0}},
- NULL},
+ {0.25,0.25,0.25,1.0}}
+ },
};
-
-void layers_init()
-{
- gint i;
- for(i=LAYER_FIRST ; i<=LAYER_LAST ; i++) {
- geometryset_new(&(g_aLayers[i].m_pGeometrySet));
- }
-}
-
-void layers_clear()
-{
- gint i;
- for(i=LAYER_FIRST ; i<=LAYER_LAST ; i++) {
- geometryset_clear(g_aLayers[i].m_pGeometrySet);
- }
-}
Index: layers.h
===================================================================
RCS file: /cvs/cairo/roadster/src/layers.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- layers.h 26 Feb 2005 04:41:40 -0000 1.2
+++ layers.h 1 Mar 2005 19:48:21 -0000 1.3
@@ -21,11 +21,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef _LAYERS_H
-#define _LAYERS_H
+#ifndef _LAYERS_H_
+#define _LAYERS_H_
#include <gtk/gtk.h>
-#include "geometryset.h"
#ifdef __cplusplus
extern "C"
@@ -34,23 +33,25 @@
#define LAYER_NONE (0)
-#define LAYER_MINORSTREET (1)
-#define LAYER_MAJORSTREET (2)
-#define LAYER_MINORHIGHWAY (3)
-#define LAYER_MINORHIGHWAY_RAMP (4)
-#define LAYER_MAJORHIGHWAY (5) // used?
-#define LAYER_MAJORHIGHWAY_RAMP (6) // used?
-#define LAYER_RAILROAD (7)
+#define LAYER_MINORSTREET (1)
+#define LAYER_MAJORSTREET (2)
+#define LAYER_MINORHIGHWAY (3)
+#define LAYER_MINORHIGHWAY_RAMP (4)
+#define LAYER_MAJORHIGHWAY (5) // used?
+#define LAYER_MAJORHIGHWAY_RAMP (6) // used?
+#define LAYER_RAILROAD (7)
#define LAYER_PARK (8)
#define LAYER_RIVER (9)
#define LAYER_LAKE (10)
-#define LAYER_MISC_AREA (11)
+#define LAYER_MISC_AREA (11)
#define NUM_LAYERS (11)
-
+
#define LAYER_FIRST (1)
#define LAYER_LAST (11)
+#include "map.h"
+
typedef struct color {
gfloat m_fRed;
gfloat m_fGreen;
@@ -74,21 +75,12 @@
gint m_nCapStyle;
} sublayerstyle_t;
- //~ gint m_nMinZoomLevel;
- //~ gdouble m_fTopLineWidthPercent;
- //~ gdouble m_afLineWidths[10];
- //~ color_t m_clrLowDetail;
- //~ color_t m_clrFill;
- //~ color_t m_clrOutline;
- //~ gint m_nDashStyle; // index into dashes table
-
typedef struct textlabelstyle {
gdouble m_afFontSizeAtZoomLevel[MAX_ZOOM_LEVEL];
gint m_abBoldAtZoomLevel[MAX_ZOOM_LEVEL]; // 0s or 1s
gint m_afHaloAtZoomLevel[MAX_ZOOM_LEVEL]; // stroke width
color_t m_clrColor;
// font family...
- // font style...
} textlabelstyle_t;
// defines the look of a layer
@@ -100,17 +92,13 @@
gint nLayerIndex;
gchar* m_pszName;
layerstyle_t m_Style;
- textlabelstyle_t m_TextLabelStyle;
- geometryset_t* m_pGeometrySet;
+ textlabelstyle_t m_TextLabelStyle;
} layer_t;
extern layer_t g_aLayers[NUM_LAYERS+1];
-void layers_init(void);
-void layers_clear(void);
-
#ifdef __cplusplus
}
#endif
-#endif /* _LAYERS_H */
+#endif /* _LAYERS_H_ */
Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- main.c 28 Feb 2005 06:31:04 -0000 1.7
+++ main.c 1 Mar 2005 19:48:21 -0000 1.8
@@ -28,7 +28,6 @@
#include <gnome.h>
#include "gui.h"
#include "db.h"
-#include "geometryset.h"
#include "mainwindow.h"
#include "map.h"
#include "import.h"
@@ -39,7 +38,7 @@
#include "pointstring.h"
#include "track.h"
-static int main_init(void);
+static gboolean main_init(void);
static void main_deinit(void);
int main (int argc, char *argv[])
@@ -52,21 +51,23 @@
#endif
gnome_init(PACKAGE, VERSION, argc, argv);
- ret = main_init();
-
- if (ret)
- return ret;
+ if(!main_init()) {
+ return 1;
+ }
gui_run();
main_deinit(); // usually doesn't get here
return 0;
}
-int main_init(void)
+gboolean main_init(void)
{
+ // Initialize GLib thread system
+ // g_thread_init(NULL);
+
if(!gnome_vfs_init()) {
g_warning("gnome_vfs_init failed\n");
- return 1;
+ return FALSE;
}
gchar* pszApplicationDir = g_strdup_printf("%s/.roadster", g_get_home_dir());
if(GNOME_VFS_OK != gnome_vfs_make_directory(pszApplicationDir, 0700)) {
@@ -84,18 +85,19 @@
track_init();
g_print("initializing glyphs\n");
glyph_init();
+ g_print("initializing map\n");
+ map_init();
g_print("initializing scenemanager\n");
scenemanager_init();
//geometryset_init();
+
g_print("initializing locationsets\n");
locationset_init();
g_print("initializing gpsclient\n");
gpsclient_init();
g_print("initializing gui\n");
gui_init();
- g_print("initializing layers\n");
- layers_init();
g_print("initializing db\n");
db_init();
@@ -107,7 +109,7 @@
g_print("initialization complete\n");
- return 0;
+ return TRUE;
}
static void main_deinit(void)
Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mainwindow.c 28 Feb 2005 06:31:04 -0000 1.9
+++ mainwindow.c 1 Mar 2005 19:48:21 -0000 1.10
@@ -59,9 +59,8 @@
#define LAYERLIST_COLUMN_NAME (1)
// Limits
-#define MAX_SEARCH_TEXT_LENGTH (100)
-
-#define SPEED_LABEL_FORMAT ("<span font_desc='32'>%.0f</span>")
+#define MAX_SEARCH_TEXT_LENGTH (100)
+#define SPEED_LABEL_FORMAT ("<span font_desc='32'>%.0f</span>")
// Settings
#define TIMER_GPS_REDRAW_INTERVAL_MS (2500) // lower this (to 1?) when it's faster to redraw track
@@ -105,17 +104,16 @@
GtkImage* m_pStatusbarGPSIcon;
GtkWidget *m_pSidebox;
-
// Sidebar
-
+
// "Draw" Sidebar
GtkTreeView* m_pLayersListTreeView;
GtkTreeView* m_pLocationSetsTreeView;
-
+
// "GPS" sidebar
GtkLabel* m_pSpeedLabel;
GtkProgressBar* m_pGPSSignalStrengthProgressBar;
-
+
// Statusbar
GtkVBox* m_pStatusbar;
GtkLabel* m_pPositionLabel;
@@ -128,14 +126,16 @@
// Drawing area
// GtkWidget* m_pDrawWidget;
GtkDrawingArea* m_pDrawingArea;
- GdkPixmap* m_pOffscreenPixmap;
-
+
+ map_t* m_pMap;
+
EToolType m_eSelectedTool;
gint m_nCurrentGPSPath;
gint m_nGPSLocationGlyph;
} g_MainWindow = {0};
+
// Data
toolsettings_t g_Tools[] = {
{"Pointer Tool", {GDK_LEFT_PTR, NULL}},
@@ -220,6 +220,9 @@
// create drawing area
g_MainWindow.m_pDrawingArea = GTK_DRAWING_AREA(gtk_drawing_area_new());
+ g_print("creating map\n");
+ map_new(&g_MainWindow.m_pMap, GTK_WIDGET(g_MainWindow.m_pDrawingArea));
+
// add signal handlers to drawing area
gtk_widget_add_events(GTK_WIDGET(g_MainWindow.m_pDrawingArea), GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(g_MainWindow.m_pDrawingArea), "expose_event", G_CALLBACK(mainwindow_on_expose_event), NULL);
@@ -292,18 +295,18 @@
mainwindow_load_locationset_list();
/* add some data to the layers list */
- GtkTreeIter iter;
-
- int i;
- for(i=LAYER_FIRST ; i<=LAYER_LAST ; i++) {
- gboolean bEnabled = TRUE;
-
- gtk_list_store_append(GTK_LIST_STORE(pLayersListStore), &iter);
- gtk_list_store_set(GTK_LIST_STORE(pLayersListStore), &iter,
- LAYERLIST_COLUMN_ENABLED, bEnabled,
- LAYERLIST_COLUMN_NAME, g_aLayers[i].m_pszName,
- -1);
- }
+// GtkTreeIter iter;
+//
+// int i;
+// for(i=LAYER_FIRST ; i<=LAYER_LAST ; i++) {
+// gboolean bEnabled = TRUE;
+//
+// gtk_list_store_append(GTK_LIST_STORE(pLayersListStore), &iter);
+// gtk_list_store_set(GTK_LIST_STORE(pLayersListStore), &iter,
+// LAYERLIST_COLUMN_ENABLED, bEnabled,
+// LAYERLIST_COLUMN_NAME, g_aLayers[i].m_pszName,
+// -1);
+// }
g_timeout_add(TIMER_GPS_REDRAW_INTERVAL_MS,
(GSourceFunc)mainwindow_callback_on_gps_redraw_timeout,
@@ -393,7 +396,7 @@
void mainwindow_statusbar_update_zoomscale(void)
{
char buf[200];
- guint32 uZoomLevelScale = map_get_zoomlevel_scale();
+ guint32 uZoomLevelScale = map_get_zoomlevel_scale(g_MainWindow.m_pMap);
snprintf(buf, 199, "1:%d", uZoomLevelScale);
mainwindow_set_statusbar_zoomscale(buf);
@@ -403,7 +406,7 @@
{
char buf[200];
mappoint_t pt;
- map_get_centerpoint(&pt);
+ map_get_centerpoint(g_MainWindow.m_pMap, &pt);
g_snprintf(buf, 200, "Lat: %.5f, Lon: %.5f", pt.m_fLatitude, pt.m_fLongitude);
mainwindow_set_statusbar_position(buf);
}
@@ -517,7 +520,7 @@
gint16 nValue = (gint16)fValue;
gtk_range_set_value(range, (gdouble)nValue);
- map_set_zoomlevel(nValue);
+ map_set_zoomlevel(g_MainWindow.m_pMap, nValue);
mainwindow_statusbar_update_zoomscale();
mainwindow_draw_map();
@@ -528,16 +531,16 @@
//
static void zoom_in_one(void)
{
- map_set_zoomlevel( map_get_zoomlevel() + 1);
+ map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) + 1);
- gtk_range_set_value(GTK_RANGE(g_MainWindow.m_pZoomScale), map_get_zoomlevel());
+ gtk_range_set_value(GTK_RANGE(g_MainWindow.m_pZoomScale), map_get_zoomlevel(g_MainWindow.m_pMap));
}
static void zoom_out_one(void)
{
- map_set_zoomlevel( map_get_zoomlevel() - 1 );
+ map_set_zoomlevel(g_MainWindow.m_pMap, map_get_zoomlevel(g_MainWindow.m_pMap) - 1 );
- gtk_range_set_value(GTK_RANGE(g_MainWindow.m_pZoomScale), map_get_zoomlevel());
+ gtk_range_set_value(GTK_RANGE(g_MainWindow.m_pZoomScale), map_get_zoomlevel(g_MainWindow.m_pMap));
}
static void gui_set_tool(EToolType eTool)
@@ -614,10 +617,10 @@
gotowindow_show();
}
-void on_gotobutton_clicked(GtkToolButton *toolbutton, gpointer user_data)
-{
- gotowindow_show();
-}
+// void on_gotobutton_clicked(GtkToolButton *toolbutton, gpointer user_data)
+// {
+// gotowindow_show();
+// }
static gboolean mainwindow_on_mouse_button_click(GtkWidget* w, GdkEventButton *event)
{
@@ -626,14 +629,14 @@
gdk_window_get_pointer(w->window, &nX, &nY, NULL);
- // Left-click
- if(event->button == 1 && event->type == GDK_BUTTON_PRESS) {
+ // Left double-click
+ if(event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
if(g_MainWindow.m_eSelectedTool == kToolZoom) {
- map_center_on_windowpoint(nX, nY);
+ map_center_on_windowpoint(g_MainWindow.m_pMap, nX, nY);
zoom_in_one();
}
else if(g_MainWindow.m_eSelectedTool == kToolPointer) {
- map_center_on_windowpoint(nX, nY);
+ map_center_on_windowpoint(g_MainWindow.m_pMap, nX, nY);
}
else {
g_assert(FALSE);
@@ -642,16 +645,16 @@
mainwindow_statusbar_update_position();
}
// Right-click?
- else if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
- {
- // Save click location for use by callback
- g_MainWindow.m_ptClickLocation.m_nX = nX;
- g_MainWindow.m_ptClickLocation.m_nY = nY;
-
- // Show popup!
- gtk_menu_popup(g_MainWindow.m_pMapPopupMenu, NULL, NULL, NULL, NULL, event->button, event->time);
- return TRUE;
- }
+// else if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
+// {
+// // Save click location for use by callback
+// g_MainWindow.m_ptClickLocation.m_nX = nX;
+// g_MainWindow.m_ptClickLocation.m_nY = nY;
+//
+// // Show popup!
+// gtk_menu_popup(g_MainWindow.m_pMapPopupMenu, NULL, NULL, NULL, NULL, event->button, event->time);
+// return TRUE;
+// }
// map_redraw_if_needed();
return TRUE;
}
@@ -714,53 +717,27 @@
void mainwindow_draw_map(void)
{
-// g_print("mainwindow_draw_map()\n");
-
- void* pBusy = mainwindow_set_busy();
-
- Display* dpy;
- Drawable drawable;
-
- dpy = gdk_x11_drawable_get_xdisplay(g_MainWindow.m_pOffscreenPixmap);
- drawable = gdk_x11_drawable_get_xid(g_MainWindow.m_pOffscreenPixmap);
-
- cairo_t *pCairoInstance;
- pCairoInstance = cairo_create ();
- // draw on an off-screen buffer
- 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);
- }
-
- // glyph_draw_centered(pCairoInstance, g_MainWindow.m_nGPSLocationGlyph, 200, 200);
- cairo_destroy(pCairoInstance);
-
- gtk_widget_queue_draw(GTK_WIDGET(g_MainWindow.m_pDrawingArea));
-
- mainwindow_set_not_busy(&pBusy);
+ map_draw_thread_begin(g_MainWindow.m_pMap, GTK_WIDGET(g_MainWindow.m_pDrawingArea));
}
static gint mainwindow_on_configure_event(GtkWidget *pDrawingArea, GdkEventConfigure *event)
{
// Create a new backing pixmap of the appropriate size
- if(g_MainWindow.m_pOffscreenPixmap != NULL) {
- gdk_pixmap_unref(g_MainWindow.m_pOffscreenPixmap);
- }
- g_MainWindow.m_pOffscreenPixmap = gdk_pixmap_new(
- GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window,
- GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width,
- GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height,
- -1);
+// if(g_MainWindow.m_pOffscreenPixmap != NULL) {
+// gdk_pixmap_unref(g_MainWindow.m_pOffscreenPixmap);
+// }
+// g_MainWindow.m_pOffscreenPixmap = gdk_pixmap_new(
+// GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window,
+// GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width,
+// GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height,
+// -1);
// tell the map how big to draw
dimensions_t dim;
dim.m_uWidth = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width;
dim.m_uHeight = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height;
- map_set_dimensions(&dim);
+ map_set_dimensions(g_MainWindow.m_pMap, &dim);
mainwindow_draw_map();
return TRUE;
@@ -769,23 +746,26 @@
static gboolean mainwindow_on_expose_event(GtkWidget *pDrawingArea, GdkEventExpose *event, gpointer data)
{
// g_print("mainwindow_on_expose_event(x=%d,y=%d,w=%d,h=%d)\n", event->area.x, event->area.y, event->area.width, event->area.height);
+ GdkPixmap* pMapPixmap = map_get_pixmap(g_MainWindow.m_pMap);
// Copy relevant portion of off-screen bitmap to window
// TIMER_BEGIN(mytimer, "BEGIN EXPOSE");
gdk_draw_pixmap(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window,
GTK_WIDGET(g_MainWindow.m_pDrawingArea)->style->fg_gc[GTK_WIDGET_STATE(g_MainWindow.m_pDrawingArea)],
- g_MainWindow.m_pOffscreenPixmap,
+ pMapPixmap,
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
// TIMER_END(mytimer, "END EXPOSE");
+
+ map_release_pixmap(g_MainWindow.m_pMap);
return FALSE;
}
void mainwindow_on_addpointmenuitem_activate(GtkWidget *_unused, gpointer* __unused)
{
mappoint_t point;
- map_windowpoint_to_mappoint(&g_MainWindow.m_ptClickLocation, &point);
+ map_windowpoint_to_mappoint(g_MainWindow.m_pMap, &g_MainWindow.m_ptClickLocation, &point);
gint nLocationSetID = 1;
gint nNewLocationID;
@@ -804,7 +784,7 @@
// NOTE: we're setting tooltips on the image's
GtkWidget* pWidget = gtk_widget_get_parent(GTK_WIDGET(g_MainWindow.m_pStatusbarGPSIcon));
- gpsdata_t* pData = gpsclient_getdata();
+ const gpsdata_t* pData = gpsclient_getdata();
if(pData->m_eStatus == GPS_STATUS_LIVE) {
if(g_MainWindow.m_nCurrentGPSPath == 0) {
@@ -871,7 +851,10 @@
return TRUE;
}
-
+void mainwindow_set_centerpoint(mappoint_t* pPoint)
+{
+ map_set_centerpoint(g_MainWindow.m_pMap, pPoint);
+}
#ifdef ROADSTER_DEAD_CODE
Index: mainwindow.h
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mainwindow.h 28 Feb 2005 03:25:23 -0000 1.2
+++ mainwindow.h 1 Mar 2005 19:48:21 -0000 1.3
@@ -25,6 +25,7 @@
#define _MAINWINDOW_H
#include <glade/glade.h>
+#include "map.h"
#ifdef __cplusplus
extern "C"
@@ -93,6 +94,8 @@
void mainwindow_on_addpointmenuitem_activate(GtkWidget *_unused, gpointer* __unused);
void mainwindow_on_datasetmenuitem_activate(GtkWidget *pWidget, gpointer* p);
+void mainwindow_set_centerpoint(mappoint_t* pPoint);
+
#ifdef __cplusplus
}
#endif
Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- map.c 28 Feb 2005 03:25:23 -0000 1.11
+++ map.c 1 Mar 2005 19:48:21 -0000 1.12
@@ -33,271 +33,54 @@
#include "gui.h"
#include "map.h"
-#include "geometryset.h"
#include "mainwindow.h"
#include "util.h"
#include "db.h"
+#include "road.h"
+#include "point.h"
#include "layers.h"
#include "locationset.h"
[...1086 lines suppressed...]
+
+ // Step 2. Multiply the angle by the radius of the sphere to get arc length.
+ return fAOB_Rad * RADIUS_OF_WORLD_IN_METERS;
+}
+
+// ========================================================
+// Redraw
+// ========================================================
+
+void map_set_redraw_needed(gboolean bNeeded)
+{
+ pMap->m_bRedrawNeeded = bNeeded;
+}
+
+gboolean map_get_redraw_needed()
+{
+ return pMap->m_bRedrawNeeded;
+}
+#endif /* ROADSTER_DEAD_CODE */
+
Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- map.h 28 Feb 2005 03:25:23 -0000 1.2
+++ map.h 1 Mar 2005 19:48:21 -0000 1.3
@@ -26,11 +26,55 @@
#include <cairo.h>
+typedef enum {
+ kSublayerBottom,
+ kSublayerTop,
+} ESubLayer;
+
+#define MIN_LINE_LENGTH_FOR_LABEL (40)
+#define LABEL_PIXELS_ABOVE_LINE (2)
+#define LABEL_PIXEL_RELIEF_INSIDE_LINE (2) // when drawing a label inside a line, only do so if we would have at least this much blank space above+below the text
+
+// For road names: Bitstream Vera Sans Mono ?
+
+#define INCHES_PER_METER (39.37007)
+
+#define MIN_ZOOMLEVEL (1)
+#define MAX_ZOOMLEVEL (10)
+#define NUM_ZOOMLEVELS (10)
+
+#define WORLD_CIRCUMFERENCE_IN_METERS (40076000)
+#define WORLD_METERS_PER_DEGREE (WORLD_CIRCUMFERENCE_IN_METERS / 360.0)
+#define WORLD_METERS_TO_DEGREES(x) ((x) / WORLD_METERS_PER_DEGREE)
+#define WORLD_DEGREES_TO_METERS(x) ((x) * WORLD_METERS_PER_DEGREE)
+#define KILOMETERS_PER_METER (1000)
+#define WORLD_KILOMETERS_TO_DEGREES(x) ((x * KILOMETERS_PER_METER) / WORLD_METERS_PER_DEGREE)
+
+#define WORLD_CIRCUMFERENCE_IN_FEET (131482939.8324)
+#define WORLD_FEET_PER_DEGREE (WORLD_CIRCUMFERENCE_IN_FEET / 360.0)
+#define WORLD_FEET_TO_DEGREES(X) ((X) / WORLD_FEET_PER_DEGREE)
+#define FEET_PER_MILE (5280)
+#define WORLD_MILES_TO_DEGREES(x) ((x * FEET_PER_MILE) / WORLD_FEET_PER_DEGREE)
+
+// Earth is slightly egg shaped so there are infinite radius measurements:
+
+// at poles: ?
+// average: 6,371,010
+// at equator: 6,378,136 meters
+
+#define RADIUS_OF_WORLD_IN_METERS (6371010)
+
+#define DEG2RAD(x) ((x) * (M_PI / 180.0))
+#define RAD2DEG(x) ((x) * (180.0 / M_PI))
+
struct GtkWidget;
#define MIN_ZOOM_LEVEL 1
#define MAX_ZOOM_LEVEL 10
+#include "layers.h"
+#include "scenemanager.h"
+
// World space
typedef struct mappoint {
gdouble m_fLatitude;
@@ -65,7 +109,6 @@
extern zoomlevel_t g_sZoomLevels[];
-
typedef enum {
UNIT_FIRST=0,
UNIT_FEET=0,
@@ -79,54 +122,6 @@
extern gchar* g_aDistanceUnitNames[];
-enum ERoadNameSuffix { // these can't change once stored in DB
- ROAD_SUFFIX_FIRST = 0,
- ROAD_SUFFIX_NONE = 0,
-
- ROAD_SUFFIX_ROAD = 1,
- ROAD_SUFFIX_STREET,
- ROAD_SUFFIX_DRIVE,
- ROAD_SUFFIX_BOULEVARD, // blvd
- ROAD_SUFFIX_AVENUE,
- ROAD_SUFFIX_CIRCLE,
- ROAD_SUFFIX_SQUARE,
- ROAD_SUFFIX_PATH,
- ROAD_SUFFIX_WAY,
- ROAD_SUFFIX_PLAZA,
- ROAD_SUFFIX_TRAIL,
- ROAD_SUFFIX_LANE,
- ROAD_SUFFIX_CROSSING,
- ROAD_SUFFIX_PLACE,
- ROAD_SUFFIX_COURT,
- ROAD_SUFFIX_TURNPIKE,
- ROAD_SUFFIX_TERRACE,
- ROAD_SUFFIX_ROW,
- ROAD_SUFFIX_PARKWAY,
-
- ROAD_SUFFIX_BRIDGE,
- ROAD_SUFFIX_HIGHWAY,
- ROAD_SUFFIX_RUN,
- ROAD_SUFFIX_PASS,
-
- ROAD_SUFFIX_FREEWAY,
- ROAD_SUFFIX_ALLEY,
- ROAD_SUFFIX_CRESCENT,
- ROAD_SUFFIX_TUNNEL,
- ROAD_SUFFIX_WALK,
- ROAD_SUFFIX_BRANCE,
- ROAD_SUFFIX_COVE,
- ROAD_SUFFIX_BYPASS,
- ROAD_SUFFIX_LOOP,
- ROAD_SUFFIX_SPUR,
- ROAD_SUFFIX_RAMP,
- ROAD_SUFFIX_PIKE,
- ROAD_SUFFIX_GRADE,
- ROAD_SUFFIX_ROUTE,
- ROAD_SUFFIX_ARC,
-
- ROAD_SUFFIX_LAST = ROAD_SUFFIX_ARC
-};
-
typedef struct {
gint m_nZoomLevel;
gdouble m_fScreenLatitude;
@@ -136,38 +131,58 @@
gint m_nWindowHeight;
} rendermetrics_t;
-// ESuffixLength
-typedef enum {
- SUFFIX_LENGTH_SHORT,
- SUFFIX_LENGTH_LONG
-} ESuffixLength;
+typedef struct {
+ GPtrArray* m_pPointStringsArray; // this should probably change to an array of 'roads'
+} maplayer_data_t;
-void map_draw(cairo_t *cr);
+typedef struct {
+ // Mutex and the data it controls (always lock before reading/writing)
+ GMutex* m_pDataMutex;
+ mappoint_t m_MapCenter;
+ dimensions_t m_MapDimensions;
+ guint16 m_uZoomLevel;
+ maplayer_data_t* m_apLayerData[ NUM_LAYERS + 1 ];
+ GtkWidget* m_pTargetWidget;
+ scenemanager_t* m_pSceneManager;
+
+ // Mutex and the data it controls (always lock before reading/writing)
+ GMutex* m_pPixmapMutex;
+ GdkPixmap* m_pPixmap;
+} map_t;
+
+
+void map_init(void);
+gboolean map_new(map_t** ppMap, GtkWidget* pTargetWidget);
-const gchar* map_road_suffix_itoa(gint nSuffixID, ESuffixLength eSuffixLength);
-gboolean map_road_suffix_atoi(const gchar* pszSuffix, gint* pReturnSuffixID);
// Gets and Sets
-guint16 map_get_zoomlevel(void);
-guint32 map_get_zoomlevel_scale(void);
-void map_set_zoomlevel(guint16 uZoomLevel);
+guint16 map_get_zoomlevel(map_t* pMap);
+guint32 map_get_zoomlevel_scale(map_t* pMap);
+void map_set_zoomlevel(map_t* pMap, guint16 uZoomLevel);
//void map_get_render_metrics(rendermetrics_t* pMetrics);
-void map_set_redraw_needed(gboolean bNeeded);
-gboolean map_get_redraw_needed(void);
+void map_set_redraw_needed(map_t* pMap, gboolean bNeeded);
+gboolean map_get_redraw_needed(map_t* pMap);
-guint32 map_get_scale(void);
+guint32 map_get_scale(map_t* pMap);
-void map_set_centerpoint(const mappoint_t* pPoint);
-void map_get_centerpoint(mappoint_t* pReturnPoint);
-void map_set_dimensions(const dimensions_t* pDimensions);
+void map_set_centerpoint(map_t* pMap, const mappoint_t* pPoint);
+void map_get_centerpoint(map_t* pMap, mappoint_t* pReturnPoint);
+void map_set_dimensions(map_t* pMap, const dimensions_t* pDimensions);
// Conversions
-void map_windowpoint_to_mappoint(screenpoint_t* pScreenPoint, mappoint_t* pMapPoint);
-gdouble map_distance_in_units_to_degrees(gdouble fDistance, gint nDistanceUnit);
+void map_windowpoint_to_mappoint(map_t* pMap, screenpoint_t* pScreenPoint, mappoint_t* pMapPoint);
+gdouble map_distance_in_units_to_degrees(map_t* pMap, gdouble fDistance, gint nDistanceUnit);
// remove this!
-void map_center_on_windowpoint(guint16 uX, guint16 uY);
+void map_center_on_windowpoint(map_t* pMap, guint16 uX, guint16 uY);
+
+
+GdkPixmap* map_get_pixmap(map_t* pMap);
+void map_release_pixmap(map_t* pMap);
+void map_draw_thread_begin(map_t* pMap, GtkWidget* pTargetWidget);
+
+void map_draw(map_t* pMap, cairo_t *cr);
#endif
--- NEW FILE: road.c ---
/***************************************************************************
* road.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 <gnome.h>
#include "road.h"
#include "util.h"
struct {
gchar* m_pszLong;
gchar* m_pszShort;
} g_RoadNameSuffix[] = {
{"",""},
{"Road", "Rd"},
{"Street", "St"},
{"Drive", "Dr"},
{"Boulevard", "Bvd"},
{"Avenue", "Ave"},
{"Circle", "Crl"},
{"Square", "Sq"},
{"Path", "Pth"},
{"Way", "Wy"},
{"Plaza", "Plz"},
{"Trail", "Trl"},
{"Lane", "Ln"},
{"Crossing", "Xing"},
{"Place", "Pl"},
{"Court", "Ct"},
{"Turnpike", "Tpke"},
{"Terrace", "Ter"},
{"Row", "Row"},
{"Parkway", "Pky"},
{"Bridge", "Brg"},
{"Highway", "Hwy"},
{"Run", "Run"},
{"Pass", "Pass"},
{"Freeway", "Fwy"},
{"Alley", "Aly"},
{"Crescent", "Cres"},
{"Tunnel", "Tunl"},
{"Walk", "Walk"},
{"Terrace", "Trce"},
{"Branch", "Br"},
{"Cove", "Cv"},
{"Bypass", "Byp"},
{"Loop", "Loop"},
{"Spur", "Spur"},
{"Ramp", "Ramp"},
{"Pike", "Pike"},
{"Grade", "Grd"},
{"Route", "Rte"},
{"Arc", "Arc"},
};
struct {
gchar* m_pszName;
gint m_nID;
} g_RoadNameSuffixLookup[] = {
{"Rd", ROAD_SUFFIX_ROAD},
{"Road", ROAD_SUFFIX_ROAD},
{"St", ROAD_SUFFIX_STREET},
{"Street", ROAD_SUFFIX_STREET},
{"Dr", ROAD_SUFFIX_DRIVE},
{"Drive", ROAD_SUFFIX_DRIVE},
{"Blv", ROAD_SUFFIX_BOULEVARD},
{"Blvd", ROAD_SUFFIX_BOULEVARD},
{"Boulevard", ROAD_SUFFIX_BOULEVARD},
{"Av", ROAD_SUFFIX_AVENUE},
{"Ave", ROAD_SUFFIX_AVENUE},
{"Avenue", ROAD_SUFFIX_AVENUE},
{"Cir", ROAD_SUFFIX_CIRCLE},
{"Crl", ROAD_SUFFIX_CIRCLE},
{"Circle", ROAD_SUFFIX_CIRCLE},
{"Sq", ROAD_SUFFIX_SQUARE},
{"Square", ROAD_SUFFIX_SQUARE},
{"Pl", ROAD_SUFFIX_PLACE},
{"Place", ROAD_SUFFIX_PLACE},
{"Xing", ROAD_SUFFIX_CROSSING},
{"Crossing", ROAD_SUFFIX_CROSSING},
{"Ct", ROAD_SUFFIX_COURT},
{"Court", ROAD_SUFFIX_COURT},
{"Tpke", ROAD_SUFFIX_TURNPIKE},
{"Turnpike", ROAD_SUFFIX_TURNPIKE},
{"Ter", ROAD_SUFFIX_TERRACE},
{"Terrace", ROAD_SUFFIX_TERRACE},
{"Row", ROAD_SUFFIX_ROW},
{"Pth", ROAD_SUFFIX_PATH},
{"Path", ROAD_SUFFIX_PATH},
{"Wy", ROAD_SUFFIX_WAY},
{"Way", ROAD_SUFFIX_WAY},
{"Plz", ROAD_SUFFIX_PLAZA},
{"Plaza", ROAD_SUFFIX_PLAZA},
{"Trl", ROAD_SUFFIX_TRAIL},
{"Trail", ROAD_SUFFIX_TRAIL},
{"Ln", ROAD_SUFFIX_LANE},
{"Lane", ROAD_SUFFIX_LANE},
{"Pky", ROAD_SUFFIX_PARKWAY},
{"Parkway", ROAD_SUFFIX_PARKWAY},
{"Brg", ROAD_SUFFIX_BRIDGE},
{"Bridge", ROAD_SUFFIX_BRIDGE},
{"Hwy", ROAD_SUFFIX_HIGHWAY},
{"Highway", ROAD_SUFFIX_HIGHWAY},
{"Run", ROAD_SUFFIX_RUN},
{"Pass", ROAD_SUFFIX_PASS},
{"Freeway", ROAD_SUFFIX_FREEWAY},
{"Fwy", ROAD_SUFFIX_FREEWAY},
{"Alley", ROAD_SUFFIX_ALLEY},
{"Aly", ROAD_SUFFIX_ALLEY},
{"Crescent", ROAD_SUFFIX_CRESCENT},
{"Cres", ROAD_SUFFIX_CRESCENT},
{"Tunnel", ROAD_SUFFIX_TUNNEL},
{"Tunl", ROAD_SUFFIX_TUNNEL},
{"Walk", ROAD_SUFFIX_WALK},
{"Walk", ROAD_SUFFIX_WALK},
{"Branch", ROAD_SUFFIX_BRANCE},
{"Br", ROAD_SUFFIX_BRANCE},
{"Cove", ROAD_SUFFIX_COVE},
{"Cv", ROAD_SUFFIX_COVE},
{"Bypass", ROAD_SUFFIX_BYPASS},
{"Byp", ROAD_SUFFIX_BYPASS},
{"Loop", ROAD_SUFFIX_LOOP},
{"Spur", ROAD_SUFFIX_SPUR},
{"Ramp", ROAD_SUFFIX_RAMP},
{"Pike", ROAD_SUFFIX_PIKE},
{"Grade", ROAD_SUFFIX_GRADE},
{"Grd", ROAD_SUFFIX_GRADE},
{"Route", ROAD_SUFFIX_ROUTE},
{"Rte", ROAD_SUFFIX_ROUTE},
{"Arc", ROAD_SUFFIX_ARC},
};
// ========================================================
// Road Direction / Suffix conversions
// ========================================================
const gchar* road_suffix_itoa(gint nSuffixID, ESuffixLength eSuffixLength)
{
if(nSuffixID >= ROAD_SUFFIX_FIRST && nSuffixID <= ROAD_SUFFIX_LAST) {
if(eSuffixLength == ROAD_SUFFIX_LENGTH_SHORT) {
return g_RoadNameSuffix[nSuffixID].m_pszShort;
}
else {
return g_RoadNameSuffix[nSuffixID].m_pszLong;
}
}
if(nSuffixID != ROAD_SUFFIX_NONE) return "???";
return "";
}
gboolean road_suffix_atoi(const gchar* pszSuffix, gint* pReturnSuffixID)
{
gint i;
for(i=0 ; i<NUM_ELEMS(g_RoadNameSuffixLookup) ; i++) {
if(g_ascii_strcasecmp(pszSuffix, g_RoadNameSuffixLookup[i].m_pszName) == 0) {
*pReturnSuffixID = g_RoadNameSuffixLookup[i].m_nID;
return TRUE;
}
}
return FALSE;
}
--- NEW FILE: road.h ---
/***************************************************************************
* road.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 _ROAD_H_
#define _ROAD_H_
// ESuffixLength
typedef enum {
ROAD_SUFFIX_LENGTH_SHORT,
ROAD_SUFFIX_LENGTH_LONG
} ESuffixLength;
enum ERoadNameSuffix { // these can't change once stored in DB
ROAD_SUFFIX_FIRST = 0,
ROAD_SUFFIX_NONE = 0,
ROAD_SUFFIX_ROAD = 1,
ROAD_SUFFIX_STREET,
ROAD_SUFFIX_DRIVE,
ROAD_SUFFIX_BOULEVARD, // blvd
ROAD_SUFFIX_AVENUE,
ROAD_SUFFIX_CIRCLE,
ROAD_SUFFIX_SQUARE,
ROAD_SUFFIX_PATH,
ROAD_SUFFIX_WAY,
ROAD_SUFFIX_PLAZA,
ROAD_SUFFIX_TRAIL,
ROAD_SUFFIX_LANE,
ROAD_SUFFIX_CROSSING,
ROAD_SUFFIX_PLACE,
ROAD_SUFFIX_COURT,
ROAD_SUFFIX_TURNPIKE,
ROAD_SUFFIX_TERRACE,
ROAD_SUFFIX_ROW,
ROAD_SUFFIX_PARKWAY,
ROAD_SUFFIX_BRIDGE,
ROAD_SUFFIX_HIGHWAY,
ROAD_SUFFIX_RUN,
ROAD_SUFFIX_PASS,
ROAD_SUFFIX_FREEWAY,
ROAD_SUFFIX_ALLEY,
ROAD_SUFFIX_CRESCENT,
ROAD_SUFFIX_TUNNEL,
ROAD_SUFFIX_WALK,
ROAD_SUFFIX_BRANCE,
ROAD_SUFFIX_COVE,
ROAD_SUFFIX_BYPASS,
ROAD_SUFFIX_LOOP,
ROAD_SUFFIX_SPUR,
ROAD_SUFFIX_RAMP,
ROAD_SUFFIX_PIKE,
ROAD_SUFFIX_GRADE,
ROAD_SUFFIX_ROUTE,
ROAD_SUFFIX_ARC,
ROAD_SUFFIX_LAST = ROAD_SUFFIX_ARC
};
const gchar* road_suffix_itoa(gint nSuffixID, ESuffixLength eSuffixLength);
gboolean road_suffix_atoi(const gchar* pszSuffix, gint* pReturnSuffixID);
#endif
Index: scenemanager.c
===================================================================
RCS file: /cvs/cairo/roadster/src/scenemanager.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- scenemanager.c 23 Feb 2005 17:22:07 -0000 1.5
+++ scenemanager.c 1 Mar 2005 19:48:21 -0000 1.6
@@ -22,7 +22,6 @@
*/
#include <gtk/gtk.h>
-#include "geometryset.h"
#include "scenemanager.h"
/*
@@ -36,57 +35,50 @@
// gchar* m_pszLabel;
// } roadlabel_t;
-struct {
- GPtrArray* m_p;
- GHashTable* m_pLabelHash;
-} g_SceneManager;
-
void scenemanager_init(void)
{
- g_SceneManager.m_pLabelHash = g_hash_table_new(g_str_hash, g_str_equal);
}
-gboolean scenemanager_can_draw_label(const gchar* pszLabel)
+void scenemanager_new(scenemanager_t** ppReturn)
+{
+ scenemanager_t* pNew = g_new0(scenemanager_t, 1);
+ pNew->m_pLabelHash = g_hash_table_new(g_str_hash, g_str_equal);
+ *ppReturn = pNew;
+}
+
+gboolean scenemanager_can_draw_label(scenemanager_t* pSceneManager, const gchar* pszLabel)
{
+ g_assert(pSceneManager != NULL);
+
gpointer pKey;
gpointer pValue;
// can draw if it doesn't exist in table
- gboolean bOK = (g_hash_table_lookup_extended(g_SceneManager.m_pLabelHash,
- pszLabel,
- &pKey, &pValue) == FALSE);
+ gboolean bOK = (g_hash_table_lookup_extended(pSceneManager->m_pLabelHash,
+ pszLabel, &pKey, &pValue) == FALSE);
// g_print("permission for %s: %s\n", pszLabel, bOK ? "YES" : "NO");
return bOK;
}
-void scenemanager_label_drawn(const gchar* pszLabel)
+void scenemanager_label_drawn(scenemanager_t* pSceneManager, const gchar* pszLabel)
{
+ g_assert(pSceneManager != NULL);
// g_print("drawn! %s\n", pszLabel);
- g_hash_table_insert(g_SceneManager.m_pLabelHash, pszLabel, NULL);
+ g_hash_table_insert(pSceneManager->m_pLabelHash, pszLabel, NULL);
}
-void scenemanager_clear(void)
+void scenemanager_clear(scenemanager_t* pSceneManager)
{
- g_hash_table_destroy(g_SceneManager.m_pLabelHash);
+ g_assert(pSceneManager != NULL);
- scenemanager_init();
+ g_hash_table_destroy(pSceneManager->m_pLabelHash);
+ pSceneManager->m_pLabelHash = g_hash_table_new(g_str_hash, g_str_equal);
}
#if ROADSTER_DEAD_CODE
-static void scenemanager_add_label_line(geometryset_t* pGeometry, gchar* pszLabel)
-{
-
-}
-
-static void scenemanager_add_label_polygon(geometryset_t* pGeometry, gchar* pszLabel)
-{
-
-}
-
-static void scenemanager_draw(void)
-{
-
-}
+static void scenemanager_add_label_line(geometryset_t* pGeometry, gchar* pszLabel) {}
+static void scenemanager_add_label_polygon(geometryset_t* pGeometry, gchar* pszLabel) {}
+static void scenemanager_draw(void) {}
#endif /* ROADSTER_DEAD_CODE */
Index: scenemanager.h
===================================================================
RCS file: /cvs/cairo/roadster/src/scenemanager.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- scenemanager.h 23 Feb 2005 17:43:50 -0000 1.1
+++ scenemanager.h 1 Mar 2005 19:48:21 -0000 1.2
@@ -21,8 +21,22 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#ifndef _SCENEMANAGER_H_
+#define _SCENEMANAGER_H_
+
+//#include <gnome.h>
+
+typedef struct scenemanager {
+ GPtrArray* m_p;
+ GHashTable* m_pLabelHash;
+} scenemanager_t;
+
void scenemanager_init(void);
-gboolean scenemanager_can_draw_label(const gchar* pszLabel);
-void scenemanager_label_drawn(const gchar* pszLabel);
-void scenemanager_clear(void);
+void scenemanager_new(scenemanager_t** ppReturn);
+
+gboolean scenemanager_can_draw_label(scenemanager_t* pSceneManager, const gchar* pszLabel);
+void scenemanager_label_drawn(scenemanager_t* pSceneManager, const gchar* pszLabel);
+void scenemanager_clear(scenemanager_t* pSceneManager);
+
+#endif
Index: search.c
===================================================================
RCS file: /cvs/cairo/roadster/src/search.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- search.c 23 Feb 2005 17:22:07 -0000 1.3
+++ search.c 1 Mar 2005 19:48:21 -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 "search.h"
@@ -34,20 +34,20 @@
gchar* pWriter = p;
// skip white
- while(*pReader == ' ') {
+ while(g_ascii_isspace(*pReader)) {
pReader++;
}
// remove double spaces
while(*pReader != '\0') {
- if(*pReader == ' ') {
- if(*(pReader+1) == ' ' || *(pReader+1) == '\0') {
+ if(g_ascii_isspace(*pReader)) {
+ if(g_ascii_isspace(*(pReader+1)) || *(pReader+1) == '\0') {
// don't copy this character (space) if the next one is a space also
// or if it's the last character
}
else {
// yes, copy this space
- *pWriter = *pReader;
+ *pWriter = ' '; // this also turns newlines etc. into spaces
pWriter++;
}
}
Index: search_location.c
===================================================================
RCS file: /cvs/cairo/roadster/src/search_location.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- search_location.c 28 Feb 2005 03:25:23 -0000 1.5
+++ search_location.c 1 Mar 2005 19:48:21 -0000 1.6
@@ -47,6 +47,8 @@
void search_location_execute(const gchar* pszSentence, gint nLocationSetID, gfloat fDistance, gint nDistanceUnit)
{
+ return;
+/*
g_print("pszSentence = %s, nLocationSetID = %d, fDistance = %f, nDistanceUnit=%d\n", pszSentence, nLocationSetID, fDistance, nDistanceUnit);
TIMER_BEGIN(search, "\n\n****************************\nSEARCH BEGIN");
@@ -62,8 +64,10 @@
g_free(locationsearch.m_pszCleanedSentence);
TIMER_END(search, "SEARCH END");
+*/
}
+/*
void search_location_on_cleaned_sentence(locationsearch_t* pLocationSearch)
{
// Create an array of the words
@@ -172,3 +176,4 @@
searchwindow_add_result(0, p, &pt);
g_free(p);
}
+*/
Index: search_road.c
===================================================================
RCS file: /cvs/cairo/roadster/src/search_road.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- search_road.c 28 Feb 2005 03:25:23 -0000 1.9
+++ search_road.c 1 Mar 2005 19:48:21 -0000 1.10
@@ -27,25 +27,26 @@
#include "db.h"
#include "util.h"
-//#include "geometryset.h"
#include "pointstring.h"
#include "point.h"
#include "searchwindow.h"
#include "search.h"
#include "search_road.h"
+#include "road.h"
typedef struct {
gint m_nNumber; // house number eg. 51
gchar* m_pszRoadName; // road name eg. "Washington"
gint m_nCityID; //
gint m_nStateID;
- gint m_pszZIPCode;
+ gchar* m_pszZIPCode;
gint m_nSuffixID; // a number representing eg. Ave
} roadsearch_t;
-#define ROADSEARCH_NUMBER_NONE (-1)
-#define SEARCH_RESULT_COUNT_LIMIT (200) // how many rows to get from DB
-#define MAX_QUERY (4000)
+#define ROADSEARCH_NUMBER_NONE (-1)
+#define SEARCH_RESULT_COUNT_LIMIT (200) // how many rows to get from DB
+#define MAX_QUERY (4000)
+#define ROAD_MIN_LENGTH_FOR_WILDCARD_SEARCH (3)
// if glib < 2.6
#if ((GLIB_MAJOR_VERSION < 2) || ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 6)))
@@ -223,7 +224,7 @@
if(nRemainingWordCount >= 2) {
gint nSuffixID;
- if(map_road_suffix_atoi(aWords[iLast], &nSuffixID)) {
+ if(road_suffix_atoi(aWords[iLast], &nSuffixID)) {
// matched
roadsearch.m_nSuffixID = nSuffixID;
iLast--;
@@ -309,6 +310,14 @@
gchar* pszSafeRoadName = db_make_escaped_string(pRoadSearch->m_pszRoadName);
g_print("pRoadSearch->m_pszRoadName = %s, pszSafeRoadName = %s\n", pRoadSearch->m_pszRoadName, pszSafeRoadName);
+ gchar* pszRoadNameCondition;
+ if(strlen(pRoadSearch->m_pszRoadName) < ROAD_MIN_LENGTH_FOR_WILDCARD_SEARCH) {
+ pszRoadNameCondition = g_strdup_printf("RoadName.Name='%s'", pszSafeRoadName);
+ }
+ else {
+ pszRoadNameCondition = g_strdup_printf("RoadName.Name LIKE '%s%%'", pszSafeRoadName);
+ }
+
g_snprintf(azQuery, MAX_QUERY,
"SELECT Road.ID, RoadName.Name, RoadName.SuffixID, AsText(Road.Coordinates), Road.AddressLeftStart, Road.AddressLeftEnd, Road.AddressRightStart, Road.AddressRightEnd, CityLeft.Name, CityRight.Name"
", StateLeft.Code, StateRight.Code, Road.ZIPCodeLeft, Road.ZIPCodeRight"
@@ -321,18 +330,18 @@
// right side
" LEFT JOIN City AS CityRight ON (Road.CityRightID=CityRight.ID)"
" LEFT JOIN State AS StateRight ON (CityRight.StateID=StateRight.ID)"
- " WHERE RoadName.Name LIKE '%s%%'"
+ " WHERE %s"
// " WHERE RoadName.Name='%s'"
" AND Road.ID IS NOT NULL" // don't include rows where the Road didn't match
// begin clauses
"%s"
"%s"
- "%s"
- "%s"
-// " ORDER BY RoadName.Name"
+ "%s"
+ "%s"
" LIMIT %d;",
pszAddressClause,
- pszSafeRoadName,
+
+ pszRoadNameCondition,
// clauses
pszSuffixClause,
@@ -344,6 +353,7 @@
// free strings
db_free_escaped_string(pszSafeRoadName);
g_free(pszAddressClause);
+ g_free(pszRoadNameCondition);
g_free(pszSuffixClause);
g_free(pszZIPClause);
g_free(pszCityClause);
@@ -552,35 +562,35 @@
// show no numbers if they're both 0
g_snprintf(azBuffer, BUFFER_SIZE, "%s %s\n%s",
pszRoadName,
- map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG),
+ road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG),
pszCSZRight);
}
else if(nAddressRightStart < nAddressRightEnd) {
- g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressRightStart, nAddressRightEnd, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZRight);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressRightStart, nAddressRightEnd, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZRight);
}
else {
// reverse start/end for the dear user :)
- g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressRightEnd, nAddressRightStart, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZRight);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressRightEnd, nAddressRightStart, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZRight);
}
searchwindow_add_result(nRoadID, azBuffer, &ptAddress);
// do left side, same as right side (see above)
if(nAddressLeftStart == 0 && nAddressLeftEnd == 0) {
- g_snprintf(azBuffer, BUFFER_SIZE, "%s %s\n%s", pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZLeft);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%s %s\n%s", pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZLeft);
}
else if(nAddressLeftStart < nAddressLeftEnd) {
- g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressLeftStart, nAddressLeftEnd, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZLeft);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressLeftStart, nAddressLeftEnd, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZLeft);
}
else {
// swap address to keep smaller number to the left
- g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressLeftEnd, nAddressLeftStart, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZLeft);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d-%d %s %s\n%s", nAddressLeftEnd, nAddressLeftStart, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZLeft);
}
searchwindow_add_result(nRoadID, azBuffer, &ptAddress);
}
else { // else the search had a road number
// NOTE: we have to filter out results like "97-157" when searching for "124" because it's
// on the wrong side of the road.
-//g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s", nRoadNumber, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG));
+//g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s", nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG));
// check left side of street
// NOTE: if search was for an even, at least one (and hopefully both) of the range should be even
@@ -599,7 +609,7 @@
gfloat fPercent = (gfloat)(nRoadNumber - nAddressLeftStart) / (gfloat)nRange;
pointstring_walk_percentage(pPointString, fPercent, ROADSIDE_LEFT, &ptAddress);
}
- g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZLeft);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZLeft);
searchwindow_add_result(nRoadID, azBuffer, &ptAddress);
}
else if(nRoadNumber >= nAddressLeftEnd && nRoadNumber <= nAddressLeftStart) {
@@ -615,7 +625,7 @@
// flip percent (23 becomes 77, etc.)
pointstring_walk_percentage(pPointString, (100.0 - fPercent), ROADSIDE_RIGHT, &ptAddress);
}
- g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZLeft);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZLeft);
searchwindow_add_result(nRoadID, azBuffer, &ptAddress);
}
}
@@ -636,7 +646,7 @@
gfloat fPercent = (gfloat)(nRoadNumber - nAddressRightStart) / (gfloat)nRange;
pointstring_walk_percentage(pPointString, fPercent, ROADSIDE_RIGHT, &ptAddress);
}
- g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZRight);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZRight);
searchwindow_add_result(nRoadID, azBuffer, &ptAddress);
}
else if(nRoadNumber >= nAddressRightEnd && nRoadNumber <= nAddressRightStart) {
@@ -652,7 +662,7 @@
// flip percent (23 becomes 77, etc.)
pointstring_walk_percentage(pPointString, (100.0 - fPercent), ROADSIDE_LEFT, &ptAddress);
}
- g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, map_road_suffix_itoa(nRoadSuffixID, SUFFIX_LENGTH_LONG), pszCSZRight);
+ g_snprintf(azBuffer, BUFFER_SIZE, "%d %s %s\n%s", nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZRight);
searchwindow_add_result(nRoadID, azBuffer, &ptAddress);
}
}
Index: searchwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/searchwindow.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- searchwindow.c 28 Feb 2005 03:25:23 -0000 1.6
+++ searchwindow.c 1 Mar 2005 19:48:21 -0000 1.7
@@ -264,9 +264,7 @@
RESULTLIST_LONGITUDE, &pt.m_fLongitude,
-1);
- g_print("%f,%f\n", pt.m_fLatitude, pt.m_fLongitude);
-
- map_set_centerpoint(&pt);
+ mainwindow_set_centerpoint(&pt);
mainwindow_draw_map();
mainwindow_statusbar_update_position();
// g_print("yay: %s\n", pszText);
Index: util.h
===================================================================
RCS file: /cvs/cairo/roadster/src/util.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- util.h 23 Feb 2005 17:43:50 -0000 1.1
+++ util.h 1 Mar 2005 19:48:21 -0000 1.2
@@ -30,7 +30,7 @@
void util_random_color(void* pColor);
-#if 0
+#if 1
#define TIMER_BEGIN(name, str) GTimer* name = g_timer_new(); g_print("\n%s (%f)\n", str, g_timer_elapsed(name, NULL))
#define TIMER_SHOW(name, str) g_print(" %s (%f)\n", str, g_timer_elapsed(name, NULL))
#define TIMER_END(name, str) g_print("%s (%f)\n", str, g_timer_elapsed(name, NULL)); g_timer_destroy(name); name = NULL
More information about the cairo-commit
mailing list