[cairo-commit] roadster/src Makefile.am, 1.21, 1.22 db.c, 1.31, 1.32 db.h, 1.13, 1.14 gui.c, 1.13, 1.14 main.c, 1.30, 1.31 mainwindow.c, 1.45, 1.46 map.c, 1.49, 1.50 map.h, 1.24, 1.25 map_draw_cairo.c, 1.25, 1.26 map_draw_gdk.c, 1.23, 1.24 road.h, 1.5, 1.6 search_road.c, 1.27, 1.28 tooltip.c, 1.5, 1.6 tooltip.h, 1.3, 1.4

Ian McIntosh commit at pdx.freedesktop.org
Fri Sep 30 18:42:15 PDT 2005


Committed by: ian

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

Modified Files:
	Makefile.am db.c db.h gui.c main.c mainwindow.c map.c map.h 
	map_draw_cairo.c map_draw_gdk.c road.h search_road.c tooltip.c 
	tooltip.h 
Log Message:
	* src/welcomewindow.c: Removed.
	* src/gui.c: Removed welcome window.
	* src/db.c: Added bounding rect calculation to pointstring loading.
	* src/search_road.c: Update to new pointstring loading function.
	* src/mainwindow.c: Removed unneeded includes.
	* src/map.c: Add rect overlap test function.
	* src/map_draw_gdk.c: Use rect overlap test from map.c.
	* src/tooltip.c: Remove unused init function.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/roadster/src/Makefile.am,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- Makefile.am	30 Sep 2005 23:55:31 -0000	1.21
+++ Makefile.am	1 Oct 2005 01:42:12 -0000	1.22
@@ -33,7 +33,6 @@
 	import_tiger.c\
 	importwindow.c\
 	util.c\
-	welcomewindow.c\
 	gpsclient.c\
 	location.c\
 	locationset.c\
@@ -44,8 +43,6 @@
 	search_city.c\
 	search.c\
 	scenemanager.c\
-	point.c\
-	pointstring.c\
 	glyph.c\
 	road.c\
 	animator.c\

Index: db.c
===================================================================
RCS file: /cvs/cairo/roadster/src/db.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- db.c	1 Oct 2005 00:56:20 -0000	1.31
+++ db.c	1 Oct 2005 01:42:12 -0000	1.32
@@ -520,7 +520,7 @@
 	data += sizeof(double);
 }
 
-void db_parse_wkb_linestring(const gint8* data, GArray* pPointsArray)
+void db_parse_wkb_linestring(const gint8* data, GArray* pMapPointsArray, maprect_t* pBoundingRect)
 {
 	g_assert(sizeof(double) == 8);	// mysql gives us 8 bytes per point
 
@@ -534,18 +534,27 @@
 	gint nNumPoints = *((gint32*)data);	// NOTE for later: this field doesn't exist for type POINT
 	data += sizeof(gint32);
 
-    g_array_set_size(pPointsArray, nNumPoints);
+    g_array_set_size(pMapPointsArray, nNumPoints);
+
+	pBoundingRect->A.fLatitude = MAX_LATITUDE;
+	pBoundingRect->A.fLongitude = MAX_LONGITUDE;
+	pBoundingRect->B.fLatitude = MIN_LATITUDE;
+	pBoundingRect->B.fLongitude = MIN_LONGITUDE;
 
 	gint i = 0;
 	while(nNumPoints > 0) {
-		mappoint_t* p = &g_array_index(pPointsArray, mappoint_t, i);
+		mappoint_t* p = &g_array_index(pMapPointsArray, mappoint_t, i);
 
 		p->fLatitude = *((double*)data);
+		pBoundingRect->A.fLatitude = min(pBoundingRect->A.fLatitude, p->fLatitude);
+		pBoundingRect->B.fLatitude = max(pBoundingRect->B.fLatitude, p->fLatitude);
 		data += sizeof(double);
+
 		p->fLongitude = *((double*)data);
+		pBoundingRect->A.fLongitude = min(pBoundingRect->A.fLongitude, p->fLongitude);
+		pBoundingRect->B.fLongitude = max(pBoundingRect->B.fLongitude, p->fLongitude);
 		data += sizeof(double);
 
-//		g_array_append_val(pPointsArray, p);
 		nNumPoints--;
 		i++;
 	}

Index: db.h
===================================================================
RCS file: /cvs/cairo/roadster/src/db.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- db.h	1 Oct 2005 00:56:20 -0000	1.13
+++ db.h	1 Oct 2005 01:42:12 -0000	1.14
@@ -41,8 +41,6 @@
 #define DB_FEATURES_TABLENAME	("Feature")
 
 #include "map.h"
-//#include "layers.h"
-#include "pointstring.h"
 
 void db_create_tables(void);
 
@@ -80,7 +78,8 @@
 void db_free_escaped_string(gchar* pszString);
 
 //void db_parse_wkb_linestring(const gint8* data, GPtrArray* pPointsArray, gboolean (*callback_alloc_point)(mappoint_t**));
-void db_parse_wkb_linestring(const gint8* data, GArray* pPointsArray);
+//void db_parse_wkb_linestring(const gint8* data, GArray* pMapPointsArray);
+void db_parse_wkb_linestring(const gint8* data, GArray* pMapPointsArray, maprect_t* pBoundingRect);
 void db_parse_wkb_point(const gint8* data, mappoint_t* pPoint);
 
 void db_enable_keys(void);

Index: gui.c
===================================================================
RCS file: /cvs/cairo/roadster/src/gui.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- gui.c	30 Sep 2005 05:09:51 -0000	1.13
+++ gui.c	1 Oct 2005 01:42:12 -0000	1.14
@@ -34,7 +34,6 @@
 #include "mainwindow.h"
 #include "gotowindow.h"
 #include "importwindow.h"
-#include "welcomewindow.h"
 #include "searchwindow.h"
 #include "locationeditwindow.h"
 
@@ -53,8 +52,6 @@
 	g_print("- initializing importwindow\n");
 	importwindow_init(pGladeXML);
 	//datasetwindow_init(pGladeXML);
-	g_print("- initializing welcomewindow\n");
-	welcomewindow_init(pGladeXML);
 	g_print("- initializing locationeditwindow\n");
 	locationeditwindow_init(pGladeXML);
 }
@@ -85,7 +82,7 @@
 
 void gui_run()
 {
-	welcomewindow_show();
+	mainwindow_show();
 	gtk_main();
 }
 

Index: main.c
===================================================================
RCS file: /cvs/cairo/roadster/src/main.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- main.c	1 Oct 2005 00:56:20 -0000	1.30
+++ main.c	1 Oct 2005 01:42:12 -0000	1.31
@@ -137,11 +137,6 @@
 	g_free(pszApplicationDir);
 #endif
 
-//     g_print("initializing points\n");
-//     point_init();
-//     g_print("initializing pointstrings\n");
-//     pointstring_init();
-
 	g_print("initializing map styles\n");
 	map_style_init();
 	g_print("initializing map\n");

Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- mainwindow.c	30 Sep 2005 23:55:31 -0000	1.45
+++ mainwindow.c	1 Oct 2005 01:42:12 -0000	1.46
@@ -27,10 +27,10 @@
 
 #include <gtk/gtk.h>
 #include <gtk/gtksignal.h>
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
-#include <cairo.h>
-#include <cairo-xlib.h>
+//#include <gdk/gdk.h>
+//#include <gdk/gdkx.h>
+//#include <cairo.h>
+//#include <cairo-xlib.h>
 
 #include "main.h"
 #include "search_road.h"
@@ -41,7 +41,6 @@
 #include "map.h"
 #include "map_style.h"
 #include "importwindow.h"
-#include "welcomewindow.h"
 #include "locationset.h"
 #include "gpsclient.h"
 #include "mainwindow.h"

Index: map.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- map.c	1 Oct 2005 00:56:20 -0000	1.49
+++ map.c	1 Oct 2005 01:42:12 -0000	1.50
@@ -34,7 +34,6 @@
 #include "util.h"
 #include "db.h"
 #include "road.h"
-#include "point.h"
 #include "locationset.h"
 #include "location.h"
 #include "scenemanager.h"
@@ -630,7 +629,7 @@
 
 			// perhaps let the wkb parser create the array (at the perfect size)
 			pNewRoad->pMapPointsArray = g_array_new(FALSE, FALSE, sizeof(road_t));
-			db_parse_wkb_linestring(aRow[2], pNewRoad->pMapPointsArray);
+			db_parse_wkb_linestring(aRow[2], pNewRoad->pMapPointsArray, &(pNewRoad->rWorldBoundingBox));
 
 #ifdef ENABLE_RIVER_TO_LAKE_LOADTIME_HACK	// XXX: combine this and above hack and you get lakes with squiggly edges. whoops. :)
 			if(nTypeID == MAP_OBJECT_TYPE_RIVER) {
@@ -1362,3 +1361,13 @@
 	}
 	return FALSE;	// removed
 }
+
+gboolean map_rects_overlap(const maprect_t* p1, const maprect_t* p2)
+{
+	if(p1->B.fLatitude < p2->A.fLatitude) return FALSE;
+	if(p1->B.fLongitude < p2->A.fLongitude) return FALSE;
+	if(p1->A.fLatitude > p2->B.fLatitude) return FALSE;
+	if(p1->A.fLongitude > p2->B.fLongitude) return FALSE;
+
+	return TRUE;
+}

Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- map.h	30 Sep 2005 05:09:51 -0000	1.24
+++ map.h	1 Oct 2005 01:42:12 -0000	1.25
@@ -342,4 +342,6 @@
 gboolean map_object_type_atoi(const gchar* pszName, gint* pnReturnObjectTypeID);
 gboolean map_layer_render_type_atoi(const gchar* pszName, gint* pnReturnRenderTypeID);
 
+gboolean map_rects_overlap(const maprect_t* p1, const maprect_t* p2);
+
 #endif

Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- map_draw_cairo.c	1 Oct 2005 00:56:20 -0000	1.25
+++ map_draw_cairo.c	1 Oct 2005 01:42:12 -0000	1.26
@@ -51,7 +51,6 @@
 #include "mainwindow.h"
 #include "util.h"
 #include "road.h"
-#include "point.h"
 #include "map_style.h"
 #include "location.h"
 #include "locationset.h"

Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- map_draw_gdk.c	1 Oct 2005 00:56:20 -0000	1.23
+++ map_draw_gdk.c	1 Oct 2005 01:42:12 -0000	1.24
@@ -37,7 +37,6 @@
 #include "util.h"
 #include "db.h"
 #include "road.h"
-#include "point.h"
 #include "map_style.h"
 #include "locationset.h"
 #include "location.h"
@@ -153,10 +152,9 @@
 	for(iString=0 ; iString<pRoadsArray->len ; iString++) {
 		pRoad = g_ptr_array_index(pRoadsArray, iString);
 
-		gdouble fMaxLat = MIN_LATITUDE;	// init to the worst possible value so first point will override
-		gdouble fMinLat = MAX_LATITUDE;
-		gdouble fMaxLon = MIN_LONGITUDE;
-		gdouble fMinLon = MAX_LONGITUDE;
+		if(!map_rects_overlap(&(pRoad->rWorldBoundingBox), &(pRenderMetrics->rWorldBoundingBox))) {
+			continue;
+		}
 
 		if(pRoad->pMapPointsArray->len >= 2) {
 			GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
@@ -170,25 +168,10 @@
 			for(iPoint=0 ; iPoint<pRoad->pMapPointsArray->len ; iPoint++) {
 				pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint);
 
-				// find extents
-				fMaxLat = max(pPoint->fLatitude,fMaxLat);
-				fMinLat = min(pPoint->fLatitude,fMinLat);
-				fMaxLon = max(pPoint->fLongitude,fMaxLon);
-				fMinLon = min(pPoint->fLongitude,fMinLon);
-
 				aPoints[iPoint].x = pLayerStyle->nPixelOffsetX + (gint)SCALE_X(pRenderMetrics, pPoint->fLongitude);
 				aPoints[iPoint].y = pLayerStyle->nPixelOffsetY + (gint)SCALE_Y(pRenderMetrics, pPoint->fLatitude);
 			}
 
-			// rectangle overlap test
-			if(fMaxLat < pRenderMetrics->rWorldBoundingBox.A.fLatitude
-			   || fMaxLon < pRenderMetrics->rWorldBoundingBox.A.fLongitude
-			   || fMinLat > pRenderMetrics->rWorldBoundingBox.B.fLatitude
-			   || fMinLon > pRenderMetrics->rWorldBoundingBox.B.fLongitude)
-			{
-			    continue;	// not visible
-			}
-
 			gdk_draw_polygon(pPixmap, pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)],
 				TRUE, aPoints, pRoad->pMapPointsArray->len);
    		}
@@ -271,16 +254,15 @@
 	for(iString=0 ; iString<pRoadsArray->len ; iString++) {
 		pRoad = g_ptr_array_index(pRoadsArray, iString);
 
+		if(!map_rects_overlap(&(pRoad->rWorldBoundingBox), &(pRenderMetrics->rWorldBoundingBox))) {
+			continue;
+		}
+
 		if(pRoad->pMapPointsArray->len > MAX_GDK_LINE_SEGMENTS) {
 			//g_warning("not drawing line with > %d segments\n", MAX_GDK_LINE_SEGMENTS);
 			continue;
 		}
 
-		gdouble fMaxLat = MIN_LATITUDE;	// init to the worst possible value so first point will override
-		gdouble fMinLat = MAX_LATITUDE;
-		gdouble fMaxLon = MIN_LONGITUDE;
-		gdouble fMinLon = MAX_LONGITUDE;
-
 		if(pRoad->pMapPointsArray->len >= 2) {
 			// Copy all points into this array.  Yuuup this is slow. :)
 			GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS];
@@ -288,27 +270,10 @@
 			for(iPoint=0 ; iPoint<pRoad->pMapPointsArray->len ; iPoint++) {
 				pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint);
 
-				// find extents
-				fMaxLat = max(pPoint->fLatitude,fMaxLat);
-				fMinLat = min(pPoint->fLatitude,fMinLat);
-				fMaxLon = max(pPoint->fLongitude,fMaxLon);
-				fMinLon = min(pPoint->fLongitude,fMinLon);
-
 				aPoints[iPoint].x = pLayerStyle->nPixelOffsetX + (gint)SCALE_X(pRenderMetrics, pPoint->fLongitude);
 				aPoints[iPoint].y = pLayerStyle->nPixelOffsetY + (gint)SCALE_Y(pRenderMetrics, pPoint->fLatitude);
 			}
 
-			// basic rectangle overlap test
-			// XXX: not quite right. the points that make up a road may be offscreen,
-			// but a thick road should still be visible
-			if(fMaxLat < pRenderMetrics->rWorldBoundingBox.A.fLatitude
-			   || fMaxLon < pRenderMetrics->rWorldBoundingBox.A.fLongitude
-			   || fMinLat > pRenderMetrics->rWorldBoundingBox.B.fLatitude
-			   || fMinLon > pRenderMetrics->rWorldBoundingBox.B.fLongitude)
-			{
-			    continue;	// not visible
-			}
-
 			gdk_draw_lines(pPixmap, pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)], aPoints, pRoad->pMapPointsArray->len);
    		}
 	}

Index: road.h
===================================================================
RCS file: /cvs/cairo/roadster/src/road.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- road.h	1 Oct 2005 00:56:20 -0000	1.5
+++ road.h	1 Oct 2005 01:42:12 -0000	1.6
@@ -24,6 +24,8 @@
 #ifndef _ROAD_H_
 #define _ROAD_H_
 
+#include "map.h"
+
 typedef struct {
 	GArray* pMapPointsArray;
 
@@ -32,6 +34,8 @@
 	gint nAddressLeftEnd;
 	gint nAddressRightStart;
 	gint nAddressRightEnd;
+
+	maprect_t rWorldBoundingBox;
 } road_t;
 
 // ESuffixLength

Index: search_road.c
===================================================================
RCS file: /cvs/cairo/roadster/src/search_road.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- search_road.c	1 Oct 2005 00:56:20 -0000	1.27
+++ search_road.c	1 Oct 2005 01:42:12 -0000	1.28
@@ -28,8 +28,6 @@
 #include "main.h"
 #include "db.h"
 #include "util.h"
-#include "pointstring.h"
-#include "point.h"
 #include "search.h"
 #include "search_road.h"
 #include "road.h"
@@ -351,7 +349,8 @@
 			if(nCount <= SEARCH_RESULT_COUNT_LIMIT) {
 
 				GArray* pMapPointsArray = g_array_new(FALSE, FALSE, sizeof(mappoint_t));
-				db_parse_wkb_linestring(aRow[3], pMapPointsArray);
+				maprect_t r;
+				db_parse_wkb_linestring(aRow[3], pMapPointsArray, &r);
 				search_road_filter_result(aRow[1], pRoadSearch->nNumber, atoi(aRow[2]), atoi(aRow[4]), atoi(aRow[5]), atoi(aRow[6]), atoi(aRow[7]), aRow[8], aRow[9], aRow[10], aRow[11], aRow[12], aRow[13], pMapPointsArray);
 				//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]);
 				

Index: tooltip.c
===================================================================
RCS file: /cvs/cairo/roadster/src/tooltip.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- tooltip.c	25 Sep 2005 19:02:37 -0000	1.5
+++ tooltip.c	1 Oct 2005 01:42:12 -0000	1.6
@@ -26,11 +26,6 @@
 #include "main.h"
 #include "tooltip.h"
 
-void tooltip_init()
-{
-
-}
-
 static gboolean tooltip_on_mouse_motion(GtkWidget* w, GdkEventMotion *event);
 
 tooltip_t* tooltip_new()

Index: tooltip.h
===================================================================
RCS file: /cvs/cairo/roadster/src/tooltip.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tooltip.h	25 Sep 2005 19:02:37 -0000	1.3
+++ tooltip.h	1 Oct 2005 01:42:12 -0000	1.4
@@ -31,7 +31,6 @@
 	gboolean bEnabled;
 } tooltip_t;
 
-void tooltip_init();
 tooltip_t* tooltip_new();
 void tooltip_set_markup(tooltip_t* pTooltip, const gchar* pszMarkup);
 void tooltip_set_upper_left_corner(tooltip_t* pTooltip, gint nX, gint nY);



More information about the cairo-commit mailing list