diff options
author | Ian McIntosh <ian_mcintosh@linuxadvocate.org> | 2005-09-30 20:42:12 +0000 |
---|---|---|
committer | Ian McIntosh <ian_mcintosh@linuxadvocate.org> | 2005-09-30 20:42:12 +0000 |
commit | b3f9abdaad3fc4b4d90b0beab231148cf73e43d3 (patch) | |
tree | 15d7fb6d30aaf8f5f6e6eef8e7173934875d081c | |
parent | 69d0fab2dc735bcb64553ae3df1eced332b6fa94 (diff) |
Removed.
Removed welcome window.
Added bounding rect calculation to pointstring loading.
Update to new pointstring loading function.
Removed unneeded includes.
Add rect overlap test function.
Use rect overlap test from map.c.
Remove unused init function.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/db.c | 17 | ||||
-rw-r--r-- | src/db.h | 5 | ||||
-rw-r--r-- | src/gui.c | 5 | ||||
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/mainwindow.c | 9 | ||||
-rw-r--r-- | src/map.c | 13 | ||||
-rw-r--r-- | src/map.h | 2 | ||||
-rw-r--r-- | src/map_draw_cairo.c | 1 | ||||
-rw-r--r-- | src/map_draw_gdk.c | 49 | ||||
-rw-r--r-- | src/road.h | 4 | ||||
-rw-r--r-- | src/search_road.c | 5 | ||||
-rw-r--r-- | src/tooltip.c | 5 | ||||
-rw-r--r-- | src/tooltip.h | 1 |
15 files changed, 57 insertions, 78 deletions
@@ -1,5 +1,16 @@ 2005-09-30 Ian McIntosh <ian_mcintosh@linuxadvocate.org> + * 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. + +2005-09-30 Ian McIntosh <ian_mcintosh@linuxadvocate.org> + * src/road.c: Removed alloc/dealloc of road_t. * src/point.c: * src/point.h: diff --git a/src/Makefile.am b/src/Makefile.am index 1ed79fe..420e921 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,7 +33,6 @@ roadster_SOURCES = \ import_tiger.c\ importwindow.c\ util.c\ - welcomewindow.c\ gpsclient.c\ location.c\ locationset.c\ @@ -44,8 +43,6 @@ roadster_SOURCES = \ search_city.c\ search.c\ scenemanager.c\ - point.c\ - pointstring.c\ glyph.c\ road.c\ animator.c\ @@ -520,7 +520,7 @@ void db_parse_wkb_point(const gint8* data, mappoint_t* pPoint) 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 @@ void db_parse_wkb_linestring(const gint8* data, GArray* pPointsArray) 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++; } @@ -41,8 +41,6 @@ typedef MYSQL_ROW db_row_t; #define DB_FEATURES_TABLENAME ("Feature") #include "map.h" -//#include "layers.h" -#include "pointstring.h" void db_create_tables(void); @@ -80,7 +78,8 @@ gchar* db_make_escaped_string(const gchar* pszString); 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); @@ -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 @@ void gui_init() 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 @@ GladeXML* gui_load_xml(gchar* pszFileName, gchar* pszXMLTreeRoot) void gui_run() { - welcomewindow_show(); + mainwindow_show(); gtk_main(); } @@ -137,11 +137,6 @@ gboolean main_init(void) 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"); diff --git a/src/mainwindow.c b/src/mainwindow.c index 0fe0a40..0aa1420 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -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" @@ -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 @@ static gboolean map_data_load_geometry(map_t* pMap, maprect_t* pRect) // 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 @@ gboolean map_location_selection_remove(map_t* pMap, gint nLocationID) } 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; +} @@ -342,4 +342,6 @@ const gchar* map_location_selection_get_attribute(const map_t* pMap, const locat 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 diff --git a/src/map_draw_cairo.c b/src/map_draw_cairo.c index 4e3ec3d..35d3475 100644 --- a/src/map_draw_cairo.c +++ b/src/map_draw_cairo.c @@ -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" diff --git a/src/map_draw_gdk.c b/src/map_draw_gdk.c index 1b85eeb..d5c5920 100644 --- a/src/map_draw_gdk.c +++ b/src/map_draw_gdk.c @@ -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 @@ static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, renderm 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 @@ static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, renderm 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 @@ static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetr 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 @@ static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetr 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); } } @@ -24,6 +24,8 @@ #ifndef _ROAD_H_ #define _ROAD_H_ +#include "map.h" + typedef struct { GArray* pMapPointsArray; @@ -32,6 +34,8 @@ typedef struct { gint nAddressLeftEnd; gint nAddressRightStart; gint nAddressRightEnd; + + maprect_t rWorldBoundingBox; } road_t; // ESuffixLength diff --git a/src/search_road.c b/src/search_road.c index 50f58f2..0724a5e 100644 --- a/src/search_road.c +++ b/src/search_road.c @@ -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 @@ void search_road_on_roadsearch_struct(const roadsearch_t* pRoadSearch) 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]); diff --git a/src/tooltip.c b/src/tooltip.c index 477bf5d..7ac3c3b 100644 --- a/src/tooltip.c +++ b/src/tooltip.c @@ -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() diff --git a/src/tooltip.h b/src/tooltip.h index a2a7b1a..11ecb46 100644 --- a/src/tooltip.h +++ b/src/tooltip.h @@ -31,7 +31,6 @@ typedef struct { 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); |