diff options
author | Ian McIntosh <ian_mcintosh@linuxadvocate.org> | 2005-09-30 19:56:19 +0000 |
---|---|---|
committer | Ian McIntosh <ian_mcintosh@linuxadvocate.org> | 2005-09-30 19:56:19 +0000 |
commit | 69d0fab2dc735bcb64553ae3df1eced332b6fa94 (patch) | |
tree | 90d1a09e2987b169a1fa35ac592d447f09d63df5 | |
parent | 362ddf4ed34d7f5c48c375ae0146f76ccc64cc64 (diff) |
Removed alloc/dealloc of road_t.
Removed, since road_t now has a basic GArray of mappoint_t objects.
Use new road_t format.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/db.c | 16 | ||||
-rw-r--r-- | src/db.h | 3 | ||||
-rw-r--r-- | src/main.c | 12 | ||||
-rw-r--r-- | src/map.c | 58 | ||||
-rw-r--r-- | src/map_draw_cairo.c | 64 | ||||
-rw-r--r-- | src/map_draw_gdk.c | 35 | ||||
-rw-r--r-- | src/point.c | 85 | ||||
-rw-r--r-- | src/point.h | 27 | ||||
-rw-r--r-- | src/pointstring.c | 115 | ||||
-rw-r--r-- | src/pointstring.h | 38 | ||||
-rw-r--r-- | src/road.c | 39 | ||||
-rw-r--r-- | src/road.h | 8 | ||||
-rw-r--r-- | src/search_road.c | 54 |
14 files changed, 117 insertions, 446 deletions
@@ -1,5 +1,14 @@ 2005-09-30 Ian McIntosh <ian_mcintosh@linuxadvocate.org> + * src/road.c: Removed alloc/dealloc of road_t. + * src/point.c: + * src/point.h: + * src/pointstring.c: + * src/pointstring.h: Removed, since road_t now has a basic GArray of mappoint_t objects. + * src/*.c: Use new road_t format. + +2005-09-30 Ian McIntosh <ian_mcintosh@linuxadvocate.org> + * src/locationselection.c: * src/locationselection.h: * src/track.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, GPtrArray* pPointsArray, gboolean (*callback_alloc_point)(mappoint_t**)) +void db_parse_wkb_linestring(const gint8* data, GArray* pPointsArray) { g_assert(sizeof(double) == 8); // mysql gives us 8 bytes per point @@ -534,18 +534,20 @@ void db_parse_wkb_linestring(const gint8* data, GPtrArray* pPointsArray, gboolea gint nNumPoints = *((gint32*)data); // NOTE for later: this field doesn't exist for type POINT data += sizeof(gint32); + g_array_set_size(pPointsArray, nNumPoints); + + gint i = 0; while(nNumPoints > 0) { - mappoint_t* pPoint = NULL; - if(!callback_alloc_point(&pPoint)) return; + mappoint_t* p = &g_array_index(pPointsArray, mappoint_t, i); - pPoint->fLatitude = *((double*)data); + p->fLatitude = *((double*)data); data += sizeof(double); - pPoint->fLongitude = *((double*)data); + p->fLongitude = *((double*)data); data += sizeof(double); - g_ptr_array_add(pPointsArray, pPoint); - +// g_array_append_val(pPointsArray, p); nNumPoints--; + i++; } } @@ -79,7 +79,8 @@ void db_end_thread(void); 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, GPtrArray* pPointsArray, gboolean (*callback_alloc_point)(mappoint_t**)); +void db_parse_wkb_linestring(const gint8* data, GArray* pPointsArray); void db_parse_wkb_point(const gint8* data, mappoint_t* pPoint); void db_enable_keys(void); @@ -32,7 +32,6 @@ #include "map.h" #include "gpsclient.h" #include "scenemanager.h" -#include "road.h" #include "locationset.h" #include "location.h" #include "search.h" @@ -138,13 +137,10 @@ 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 roads\n"); - road_init(); +// g_print("initializing points\n"); +// point_init(); +// g_print("initializing pointstrings\n"); +// pointstring_init(); g_print("initializing map styles\n"); map_style_init(); @@ -603,7 +603,6 @@ static gboolean map_data_load_geometry(map_t* pMap, maprect_t* pRect) // aRow[6] is road address left end // aRow[7] is road address right start // aRow[8] is road address right end -// g_print("data: %s, %s, %s, %s, %s\n", aRow[0], aRow[1], aRow[2], aRow[3], aRow[4]); // Get layer type that this belongs on gint nTypeID = atoi(aRow[1]); @@ -612,49 +611,31 @@ static gboolean map_data_load_geometry(map_t* pMap, maprect_t* pRect) continue; } - if(nTypeID == 12) g_warning("(got a 12)"); - - road_t* pNewRoad = NULL; - road_alloc(&pNewRoad); + //road_t* pNewRoad = NULL; + //road_alloc(&pNewRoad); + road_t* pNewRoad = g_new0(road_t, 1); // Build name by adding suffix, if one is present - gchar azFullName[100] = ""; - - // does it have a name? if(aRow[3] != NULL && aRow[4] != NULL) { - gint nSuffixID = atoi(aRow[4]); - const gchar* pszSuffix = road_suffix_itoa(nSuffixID, ROAD_SUFFIX_LENGTH_SHORT); - g_snprintf(azFullName, 100, "%s%s%s", - aRow[3], (pszSuffix[0] != '\0') ? " " : "", pszSuffix); + const gchar* pszSuffix = road_suffix_itoa(atoi(aRow[4]), ROAD_SUFFIX_LENGTH_SHORT); + pNewRoad->pszName = g_strdup_printf("%s%s%s", aRow[3], (pszSuffix[0] != '\0') ? " " : "", pszSuffix); + } + else { + pNewRoad->pszName = g_strdup(""); // XXX: could we maybe not do this? } pNewRoad->nAddressLeftStart = atoi(aRow[5]); pNewRoad->nAddressLeftEnd = atoi(aRow[6]); pNewRoad->nAddressRightStart = atoi(aRow[7]); pNewRoad->nAddressRightEnd = atoi(aRow[8]); - pNewRoad->pszName = g_strdup(azFullName); - -#ifdef ENABLE_RIVER_SMOOTHING - if(nTypeID == MAP_OBJECT_TYPE_RIVER) { - // XXX: Hacky. Add randomness to river lines - GPtrArray* pTempArray = g_ptr_array_new(); - db_parse_wkb_linestring(aRow[2], pTempArray, point_alloc); - map_enhance_linestring(pTempArray, pNewRoad->pPointsArray, point_alloc, - 0.00025, // distance between points - 0.000060); // randomness - g_ptr_array_free(pTempArray, TRUE); - } - else { - db_parse_wkb_linestring(aRow[2], pNewRoad->pPointsArray, point_alloc); - } -#else - db_parse_wkb_linestring(aRow[2], pNewRoad->pPointsArray, point_alloc); -#endif + // 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); #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) { - mappoint_t* pPointA = g_ptr_array_index(pNewRoad->pPointsArray, 0); - mappoint_t* pPointB = g_ptr_array_index(pNewRoad->pPointsArray, pNewRoad->pPointsArray->len-1); + mappoint_t* pPointA = &g_array_index(pNewRoad->pMapPointsArray, mappoint_t, 0); + mappoint_t* pPointB = &g_array_index(pNewRoad->pMapPointsArray, mappoint_t, pNewRoad->pMapPointsArray->len-1); if(pPointA->fLatitude == pPointB->fLatitude && pPointA->fLongitude == pPointB->fLongitude) { nTypeID = MAP_OBJECT_TYPE_LAKE; @@ -675,7 +656,7 @@ static gboolean map_data_load_geometry(map_t* pMap, maprect_t* pRect) return TRUE; } else { -// g_print(" no rows\n"); + //g_print(" no rows\n"); return FALSE; } } @@ -769,7 +750,8 @@ static void map_data_clear(map_t* pMap) // Free each for(j = (pLayerData->pRoadsArray->len - 1) ; j>=0 ; j--) { road_t* pRoad = g_ptr_array_remove_index_fast(pLayerData->pRoadsArray, j); - road_free(pRoad); + g_array_free(pRoad->pMapPointsArray, TRUE); + g_free(pRoad); } g_assert(pLayerData->pRoadsArray->len == 0); } @@ -916,13 +898,13 @@ static gboolean map_hit_test_layer_roads(GPtrArray* pRoadsArray, gdouble fMaxDis gint iString; for(iString=0 ; iString<pRoadsArray->len ; iString++) { road_t* pRoad = g_ptr_array_index(pRoadsArray, iString); - if(pRoad->pPointsArray->len < 2) continue; + if(pRoad->pMapPointsArray->len < 2) continue; // start on 1 so we can do -1 trick below gint iPoint; - for(iPoint=1 ; iPoint<pRoad->pPointsArray->len ; iPoint++) { - mappoint_t* pPoint1 = g_ptr_array_index(pRoad->pPointsArray, iPoint-1); - mappoint_t* pPoint2 = g_ptr_array_index(pRoad->pPointsArray, iPoint); + for(iPoint=1 ; iPoint<pRoad->pMapPointsArray->len ; iPoint++) { + mappoint_t* pPoint1 = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint-1); + mappoint_t* pPoint2 = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint); mappoint_t pointClosest; gdouble fPercentAlongLine; diff --git a/src/map_draw_cairo.c b/src/map_draw_cairo.c index 3bea47d..4e3ec3d 100644 --- a/src/map_draw_cairo.c +++ b/src/map_draw_cairo.c @@ -70,8 +70,8 @@ static void map_draw_cairo_layer_points(map_t* pMap, cairo_t* pCairo, rendermetr //static void map_draw_cairo_locationselection(map_t* pMap, cairo_t *pCairo, rendermetrics_t* pRenderMetrics, GPtrArray* pLocationSelectionArray); // Draw labels for a single line/polygon -static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, const gchar* pszLabel); -static void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, const gchar* pszLabel); +static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GArray* pMapPointsArray, const gchar* pszLabel); +static void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GArray* pMapPointsArray, const gchar* pszLabel); // Draw map extras static void map_draw_cairo_map_scale(map_t* pMap, cairo_t *pCairo, rendermetrics_t* pRenderMetrics); @@ -142,7 +142,7 @@ void map_draw_cairo(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPi gint i; for(i=pMap->pLayersArray->len-1 ; i>=0 ; i--) { maplayer_t* pLayer = g_ptr_array_index(pMap->pLayersArray, i); - + if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_LINES) { if(nDrawFlags & DRAWFLAG_GEOMETRY) { map_draw_cairo_layer_roads(pMap, pCairo, pRenderMetrics, @@ -237,7 +237,7 @@ void map_draw_cairo_layer_road_labels(map_t* pMap, cairo_t* pCairo, rendermetric if(pLayerStyle->fFontSize == 0) return; - gchar* pszFontFamily = ROAD_FONT; // XXX: remove hardcoded font + gchar* pszFontFamily = ROAD_FONT; // XXX: remove hardcoded font // set font for whole layer cairo_save(pCairo); @@ -247,7 +247,7 @@ void map_draw_cairo_layer_road_labels(map_t* pMap, cairo_t* pCairo, rendermetric for(i=0 ; i<pRoadsArray->len ; i++) { road_t* pRoad = g_ptr_array_index(pRoadsArray, i); if(pRoad->pszName[0] != '\0') { - map_draw_cairo_road_label(pMap, pCairo, pLayerStyle, pRenderMetrics, pRoad->pPointsArray, pRoad->pszName); + map_draw_cairo_road_label(pMap, pCairo, pLayerStyle, pRenderMetrics, pRoad->pMapPointsArray, pRoad->pszName); } } cairo_restore(pCairo); @@ -273,7 +273,7 @@ void map_draw_cairo_layer_polygon_labels(map_t* pMap, cairo_t* pCairo, rendermet for(i=0 ; i<pRoadsArray->len ; i++) { road_t* pRoad = g_ptr_array_index(pRoadsArray, i); if(pRoad->pszName[0] != '\0') { - map_draw_cairo_polygon_label(pMap, pCairo, pLayerStyle, pRenderMetrics, pRoad->pPointsArray, pRoad->pszName); + map_draw_cairo_polygon_label(pMap, pCairo, pLayerStyle, pRenderMetrics, pRoad->pMapPointsArray, pRoad->pszName); } } cairo_restore(pCairo); @@ -331,8 +331,8 @@ void map_draw_cairo_layer_roads(map_t* pMap, cairo_t* pCairo, rendermetrics_t* p for(iString=0 ; iString<pRoadsArray->len ; iString++) { pRoad = g_ptr_array_index(pRoadsArray, iString); - if(pRoad->pPointsArray->len >= 2) { - pPoint = g_ptr_array_index(pRoad->pPointsArray, 0); + if(pRoad->pMapPointsArray->len >= 2) { + pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, 0); // go to index 0 cairo_move_to(pCairo, @@ -340,8 +340,8 @@ void map_draw_cairo_layer_roads(map_t* pMap, cairo_t* pCairo, rendermetrics_t* p pLayerStyle->nPixelOffsetY + SCALE_Y(pRenderMetrics, pPoint->fLatitude)); // start at index 1 (0 was used above) - for(iPoint=1 ; iPoint<pRoad->pPointsArray->len ; iPoint++) { - pPoint = g_ptr_array_index(pRoad->pPointsArray, iPoint);//~ g_print(" point (%.05f,%.05f)\n", ScaleX(pPoint->fLongitude), ScaleY(pPoint->fLatitude)); + for(iPoint=1 ; iPoint<pRoad->pMapPointsArray->len ; iPoint++) { + pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint);//~ g_print(" point (%.05f,%.05f)\n", ScaleX(pPoint->fLongitude), ScaleY(pPoint->fLatitude)); cairo_line_to(pCairo, pLayerStyle->nPixelOffsetX + SCALE_X(pRenderMetrics, pPoint->fLongitude), pLayerStyle->nPixelOffsetY + SCALE_Y(pRenderMetrics, pPoint->fLatitude)); @@ -384,16 +384,16 @@ void map_draw_cairo_layer_polygons(map_t* pMap, cairo_t* pCairo, rendermetrics_t for(iString=0 ; iString<pRoadsArray->len ; iString++) { pRoad = g_ptr_array_index(pRoadsArray, iString); - if(pRoad->pPointsArray->len >= 3) { - pPoint = g_ptr_array_index(pRoad->pPointsArray, 0); + if(pRoad->pMapPointsArray->len >= 3) { + pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, 0); // move to index 0 cairo_move_to(pCairo, SCALE_X(pRenderMetrics, pPoint->fLongitude), SCALE_Y(pRenderMetrics, pPoint->fLatitude)); // start at index 1 (0 was used above) gint iPoint; - for(iPoint=1 ; iPoint<pRoad->pPointsArray->len ; iPoint++) { - pPoint = g_ptr_array_index(pRoad->pPointsArray, iPoint); + for(iPoint=1 ; iPoint<pRoad->pMapPointsArray->len ; iPoint++) { + pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint); cairo_line_to(pCairo, SCALE_X(pRenderMetrics, pPoint->fLongitude), SCALE_Y(pRenderMetrics, pPoint->fLatitude)); } } @@ -465,15 +465,15 @@ typedef struct labelposition { // // Draw a label along a 2-point line // -static void map_draw_cairo_road_label_one_segment(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, const gchar* pszLabel) +static void map_draw_cairo_road_label_one_segment(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GArray* pMapPointsArray, const gchar* pszLabel) { // get permission to draw this label if(FALSE == scenemanager_can_draw_label_at(pMap->pSceneManager, pszLabel, NULL, SCENEMANAGER_FLAG_PARTLY_ON_SCREEN)) { return; } - mappoint_t* pMapPoint1 = g_ptr_array_index(pPointsArray, 0); - mappoint_t* pMapPoint2 = g_ptr_array_index(pPointsArray, 1); + mappoint_t* pMapPoint1 = &g_array_index(pMapPointsArray, mappoint_t, 0); + mappoint_t* pMapPoint2 = &g_array_index(pMapPointsArray, mappoint_t, 1); // swap first and second points such that the line goes left-to-right if(pMapPoint2->fLongitude < pMapPoint1->fLongitude) { @@ -632,17 +632,17 @@ static gint map_draw_cairo_road_label_position_sort(gconstpointer pA, gconstpoin return 1; } -static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, const gchar* pszLabel) +static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GArray* pMapPointsArray, const gchar* pszLabel) { - if(pPointsArray->len < 2) return; + if(pMapPointsArray->len < 2) return; // pass off single segments to a specialized function - if(pPointsArray->len == 2) { - map_draw_cairo_road_label_one_segment(pMap, pCairo, pLayerStyle, pRenderMetrics, pPointsArray, pszLabel); + if(pMapPointsArray->len == 2) { + map_draw_cairo_road_label_one_segment(pMap, pCairo, pLayerStyle, pRenderMetrics, pMapPointsArray, pszLabel); return; } - if(pPointsArray->len > ROAD_MAX_SEGMENTS) { + if(pMapPointsArray->len > ROAD_MAX_SEGMENTS) { g_warning("not drawing label for road '%s' with > %d segments.\n", pszLabel, ROAD_MAX_SEGMENTS); return; } @@ -668,7 +668,7 @@ static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyl gdouble aSlopes[ROAD_MAX_SEGMENTS]; mappoint_t* apPoints[ROAD_MAX_SEGMENTS]; - gint nNumPoints = pPointsArray->len; + gint nNumPoints = pMapPointsArray->len; mappoint_t* pMapPoint1; mappoint_t* pMapPoint2; @@ -676,7 +676,7 @@ static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyl // load point string into an array gint iRead; for(iRead=0 ; iRead<nNumPoints ; iRead++) { - apPoints[iRead] = g_ptr_array_index(pPointsArray, iRead); + apPoints[iRead] = &g_array_index(pMapPointsArray, mappoint_t, iRead); } // measure total line length @@ -803,7 +803,7 @@ static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyl // reverse the array gint iRead,iWrite; for(iWrite=0, iRead=nNumPoints-1 ; iRead>= 0 ; iWrite++, iRead--) { - apPoints[iWrite] = g_ptr_array_index(pPointsArray, iRead); + apPoints[iWrite] = &g_array_index(pMapPointsArray, mappoint_t, iRead); } } @@ -1135,9 +1135,9 @@ static void map_draw_cairo_road_label(map_t* pMap, cairo_t *pCairo, maplayerstyl // // Draw a single polygon label // -void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GPtrArray* pPointsArray, const gchar* pszLabel) +void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* pLayerStyle, rendermetrics_t* pRenderMetrics, GArray* pMapPointsArray, const gchar* pszLabel) { - if(pPointsArray->len < 3) return; + if(pMapPointsArray->len < 3) return; if(FALSE == scenemanager_can_draw_label_at(pMap->pSceneManager, pszLabel, NULL, SCENEMANAGER_FLAG_PARTLY_ON_SCREEN)) { return; @@ -1149,8 +1149,8 @@ void map_draw_cairo_polygon_label(map_t* pMap, cairo_t *pCairo, maplayerstyle_t* gdouble fMinLon = MAX_LONGITUDE; gint i; - for(i=0 ; i<pPointsArray->len ; i++) { - mappoint_t* pMapPoint = g_ptr_array_index(pPointsArray, i); + for(i=0 ; i<pMapPointsArray->len ; i++) { + mappoint_t* pMapPoint = &g_array_index(pMapPointsArray, mappoint_t, i); // find polygon bounding box for visibility test below fMaxLat = max(pMapPoint->fLatitude,fMaxLat); @@ -1683,7 +1683,6 @@ static void map_draw_cairo_locationselection(map_t* pMap, cairo_t *pCairo, rende #endif #ifdef ROADSTER_DEAD_CODE - /* ======= // @@ -1798,10 +1797,5 @@ void map_draw_cairo_gps_trail(map_t* pMap, cairo_t* pCairo, pointstring_t* pPoin cairo_stroke(pCairo); } } - - -#if 0 this is the curvy road labeler -void map_draw_cairo_road_label(...) -{ */ #endif diff --git a/src/map_draw_gdk.c b/src/map_draw_gdk.c index d0011c5..1b85eeb 100644 --- a/src/map_draw_gdk.c +++ b/src/map_draw_gdk.c @@ -92,18 +92,18 @@ void map_draw_gdk(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPixm maplayer_t* pLayer = g_ptr_array_index(pMap->pLayersArray, i); if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_FILL) { - map_draw_gdk_layer_fill(pMap, pPixmap, pRenderMetrics, - pLayer->paStylesAtZoomLevels[pRenderMetrics->nZoomLevel-1]); // style + map_draw_gdk_layer_fill(pMap, pPixmap, pRenderMetrics, + pLayer->paStylesAtZoomLevels[pRenderMetrics->nZoomLevel-1]); // style } else if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_LINES) { - map_draw_gdk_layer_lines(pMap, pPixmap, pRenderMetrics, - pMap->apLayerData[pLayer->nDataSource]->pRoadsArray, // data - pLayer->paStylesAtZoomLevels[pRenderMetrics->nZoomLevel-1]); // style + map_draw_gdk_layer_lines(pMap, pPixmap, pRenderMetrics, + pMap->apLayerData[pLayer->nDataSource]->pRoadsArray, // data + pLayer->paStylesAtZoomLevels[pRenderMetrics->nZoomLevel-1]); // style } else if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_POLYGONS) { map_draw_gdk_layer_polygons(pMap, pPixmap, pRenderMetrics, pMap->apLayerData[pLayer->nDataSource]->pRoadsArray, // data - pLayer->paStylesAtZoomLevels[pRenderMetrics->nZoomLevel-1]); // style + pLayer->paStylesAtZoomLevels[pRenderMetrics->nZoomLevel-1]); // style } else if(pLayer->nDrawType == MAP_LAYER_RENDERTYPE_LOCATIONS) { map_draw_gdk_locations(pMap, pPixmap, pRenderMetrics); @@ -112,7 +112,6 @@ void map_draw_gdk(map_t* pMap, rendermetrics_t* pRenderMetrics, GdkPixmap* pPixm //map_draw_gdk_locations(pMap, pPixmap, pRenderMetrics); } } -// map_draw_gdk_tracks(pMap, pPixmap, pRenderMetrics); } // 3. Labels @@ -159,17 +158,17 @@ static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, renderm gdouble fMaxLon = MIN_LONGITUDE; gdouble fMinLon = MAX_LONGITUDE; - if(pRoad->pPointsArray->len >= 2) { + if(pRoad->pMapPointsArray->len >= 2) { GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS]; - if(pRoad->pPointsArray->len > MAX_GDK_LINE_SEGMENTS) { + if(pRoad->pMapPointsArray->len > MAX_GDK_LINE_SEGMENTS) { g_warning("not drawing line with > %d segments\n", MAX_GDK_LINE_SEGMENTS); continue; } // XXX: the bounding box should be pre-calculated!!!! - for(iPoint=0 ; iPoint<pRoad->pPointsArray->len ; iPoint++) { - pPoint = g_ptr_array_index(pRoad->pPointsArray, iPoint); + for(iPoint=0 ; iPoint<pRoad->pMapPointsArray->len ; iPoint++) { + pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint); // find extents fMaxLat = max(pPoint->fLatitude,fMaxLat); @@ -191,7 +190,7 @@ static void map_draw_gdk_layer_polygons(map_t* pMap, GdkPixmap* pPixmap, renderm } gdk_draw_polygon(pPixmap, pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)], - TRUE, aPoints, pRoad->pPointsArray->len); + TRUE, aPoints, pRoad->pMapPointsArray->len); } } if(pLayerStyle->pGlyphFill != NULL) { @@ -272,7 +271,7 @@ 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(pRoad->pPointsArray->len > MAX_GDK_LINE_SEGMENTS) { + if(pRoad->pMapPointsArray->len > MAX_GDK_LINE_SEGMENTS) { //g_warning("not drawing line with > %d segments\n", MAX_GDK_LINE_SEGMENTS); continue; } @@ -282,12 +281,12 @@ static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetr gdouble fMaxLon = MIN_LONGITUDE; gdouble fMinLon = MAX_LONGITUDE; - if(pRoad->pPointsArray->len >= 2) { + if(pRoad->pMapPointsArray->len >= 2) { // Copy all points into this array. Yuuup this is slow. :) GdkPoint aPoints[MAX_GDK_LINE_SEGMENTS]; - for(iPoint=0 ; iPoint<pRoad->pPointsArray->len ; iPoint++) { - pPoint = g_ptr_array_index(pRoad->pPointsArray, iPoint); + for(iPoint=0 ; iPoint<pRoad->pMapPointsArray->len ; iPoint++) { + pPoint = &g_array_index(pRoad->pMapPointsArray, mappoint_t, iPoint); // find extents fMaxLat = max(pPoint->fLatitude,fMaxLat); @@ -310,7 +309,7 @@ static void map_draw_gdk_layer_lines(map_t* pMap, GdkPixmap* pPixmap, rendermetr continue; // not visible } - gdk_draw_lines(pPixmap, pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)], aPoints, pRoad->pPointsArray->len); + gdk_draw_lines(pPixmap, pMap->pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->pTargetWidget)], aPoints, pRoad->pMapPointsArray->len); } } } @@ -394,7 +393,7 @@ static void map_draw_gdk_locationset(map_t* pMap, GdkPixmap* pPixmap, rendermetr // { // gint i; // for(i=0 ; i<pMap->pTracksArray->len ; i++) { -// gint hTrack = g_array_index(pMap->pTracksArray, gint, i); +// gint hTrack = &g_array_index(pMap->pTracksArray, gint, i); // // GdkColor clr; // clr.red = (gint)(0.5 * 65535.0); diff --git a/src/point.c b/src/point.c deleted file mode 100644 index 9eec7d0..0000000 --- a/src/point.c +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * point.c - * - * Copyright 2005 Ian McIntosh - * ian_mcintosh@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 "main.h" -#include "map.h" -#include "point.h" - -#ifdef USE_GFREELIST -#include "gfreelist.h" -GFreeList* g_pPointFreeList; -#else -GMemChunk* g_pPointChunkAllocator; -#endif - -void point_init(void) -{ -#ifdef USE_GFREELIST - g_pPointFreeList = g_free_list_new(sizeof(mappoint_t), 1000); -#else - // create memory allocators - g_pPointChunkAllocator = g_mem_chunk_new("ROADSTER points", - sizeof(mappoint_t), sizeof(mappoint_t)*1000, G_ALLOC_AND_FREE); -#endif -} - -/******************************************************* -** 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 -#ifdef USE_GFREELIST - mappoint_t* pNew = g_free_list_alloc(g_pPointFreeList); - memset(pNew, 0, sizeof(mappoint_t)); -#else - mappoint_t* pNew = g_mem_chunk_alloc0(g_pPointChunkAllocator); -#endif - if(pNew) { - *ppPoint = pNew; - return TRUE; - } - return FALSE; -} - -void point_free(mappoint_t* pPoint) -{ - g_return_if_fail(pPoint != NULL); - - // give back to allocator -#ifdef USE_GFREELIST - g_free_list_free(g_pPointFreeList, pPoint); -#else - g_mem_chunk_free(g_pPointChunkAllocator, pPoint); -#endif -} - -void point_debug_print(mappoint_t* pPoint) -{ - g_print("pt (%f, %f)\n", pPoint->fLatitude, pPoint->fLongitude); -} - diff --git a/src/point.h b/src/point.h deleted file mode 100644 index a7d6dc4..0000000 --- a/src/point.h +++ /dev/null @@ -1,27 +0,0 @@ -/*************************************************************************** - * point.h - * - * Copyright 2005 Ian McIntosh - * ian_mcintosh@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); - diff --git a/src/pointstring.c b/src/pointstring.c deleted file mode 100644 index b5c1ce4..0000000 --- a/src/pointstring.c +++ /dev/null @@ -1,115 +0,0 @@ -/*************************************************************************** - * pointstring.c - * - * Copyright 2005 Ian McIntosh - * ian_mcintosh@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 "main.h" -#include "map.h" -#include "point.h" -#include "pointstring.h" - -#ifdef USE_GFREELIST -#include "gfreelist.h" -GFreeList* g_pPointStringFreeList = NULL; -#else -GMemChunk* g_pPointStringChunkAllocator = NULL; -#endif - -void pointstring_init(void) -{ -#ifdef USE_GFREELIST - g_pPointStringFreeList = g_free_list_new(sizeof(pointstring_t), 1000); -#else - g_pPointStringChunkAllocator = g_mem_chunk_new("ROADSTER pointstrings", - sizeof(pointstring_t), sizeof(pointstring_t)*1000, G_ALLOC_AND_FREE); -#endif -} - -/******************************************************* -** 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 -#ifdef USE_GFREELIST - g_assert(g_pPointStringFreeList != NULL); - pointstring_t* pNew = g_free_list_alloc(g_pPointStringFreeList); - memset(pNew, 0, sizeof(pointstring_t)); -#else - g_assert(g_pPointStringChunkAllocator != NULL); - pointstring_t* pNew = g_mem_chunk_alloc0(g_pPointStringChunkAllocator); -#endif - if(pNew) { - // configure it - pNew->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->pPointsArray->len - 1) ; i>=0 ; i--) { - mappoint_t* pPoint = g_ptr_array_remove_index_fast(pPointString->pPointsArray, i); - point_free(pPoint); - } - g_assert(pPointString->pPointsArray->len == 0); - - g_ptr_array_free(pPointString->pPointsArray, TRUE); - g_free(pPointString->pszName); - -#ifdef USE_GFREELIST - g_free_list_free(g_pPointStringFreeList, pPointString); -#else - g_mem_chunk_free(g_pPointStringChunkAllocator, pPointString); -#endif -} - -// copies pPoint and adds it -void pointstring_append_point(pointstring_t* pPointString, const mappoint_t* pPoint) -{ - mappoint_t* pNewPoint = NULL; - point_alloc(&pNewPoint); - - memcpy(pNewPoint, pPoint, sizeof(mappoint_t)); - - g_ptr_array_add(pPointString->pPointsArray, pNewPoint); -} - -void pointstring_debug_print(pointstring_t* pPointString) -{ - int i; - for(i=0 ; i<pPointString->pPointsArray->len ; i++) { - mappoint_t* pPoint = g_ptr_array_index(pPointString->pPointsArray, i); - g_print("(%f, %f)", pPoint->fLatitude, pPoint->fLongitude); - } -} diff --git a/src/pointstring.h b/src/pointstring.h deleted file mode 100644 index 6b8b245..0000000 --- a/src/pointstring.h +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - * pointstring.h - * - * Copyright 2005 Ian McIntosh - * ian_mcintosh@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* pszName; - GPtrArray* 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, const mappoint_t* pPoint); - -#endif @@ -28,45 +28,6 @@ #include "map.h" #include "gfreelist.h" -GFreeList* g_pRoadFreeList = NULL; - -void road_init(void) -{ - g_pRoadFreeList = g_free_list_new(sizeof(road_t), 1000); -} - -gboolean road_alloc(road_t** ppReturnRoad) -{ - g_return_val_if_fail(ppReturnRoad != NULL, FALSE); - g_return_val_if_fail(*ppReturnRoad == NULL, FALSE); // must be a pointer to a NULL pointer - - road_t* pNew = g_free_list_alloc(g_pRoadFreeList); - memset(pNew, 0, sizeof(road_t)); - - pNew->pPointsArray = g_ptr_array_new(); - - // return it - *ppReturnRoad = pNew; - return TRUE; -} - -void road_free(road_t* pRoad) -{ - g_return_if_fail(pRoad != NULL); - - int i; - for(i = (pRoad->pPointsArray->len - 1) ; i>=0 ; i--) { - mappoint_t* pPoint = g_ptr_array_remove_index_fast(pRoad->pPointsArray, i); - point_free(pPoint); - } - g_assert(pRoad->pPointsArray->len == 0); - - g_ptr_array_free(pRoad->pPointsArray, TRUE); - - // give back to allocator - g_free_list_free(g_pRoadFreeList, pRoad); -} - struct { gchar* pszLong; gchar* pszShort; @@ -25,8 +25,7 @@ #define _ROAD_H_ typedef struct { - GPtrArray* pPointsArray; -// maprect_t rcMapBoundingBox; + GArray* pMapPointsArray; gchar* pszName; gint nAddressLeftStart; @@ -35,11 +34,6 @@ typedef struct { gint nAddressRightEnd; } road_t; -void road_init(void); -gboolean road_alloc(road_t** ppReturnRoad); -void road_free(road_t* pRoad); - - // ESuffixLength typedef enum { ROAD_SUFFIX_LENGTH_SHORT, diff --git a/src/search_road.c b/src/search_road.c index e69d5a2..50f58f2 100644 --- a/src/search_road.c +++ b/src/search_road.c @@ -84,7 +84,7 @@ gboolean search_address_match_zipcode(const gchar* pszWord) void search_road_on_words(gchar** aWords, gint nWordCount); void search_road_on_roadsearch_struct(const roadsearch_t* pRoadSearch); -void search_road_filter_result(const gchar* pszRoadName, gint nRoadNumber, gint nRoadSuffixID, gint nAddressLeftStart, gint nAddressLeftEnd, gint nAddressRightStart, gint nAddressRightEnd, const gchar* pszCityNameLeft, const gchar* pszCityNameRight, const gchar* pszStateNameLeft, const gchar* pszStateNameRight, const gchar* pszZIPLeft, const gchar* pszZIPRight, pointstring_t* pPointString); +void search_road_filter_result(const gchar* pszRoadName, gint nRoadNumber, gint nRoadSuffixID, gint nAddressLeftStart, gint nAddressLeftEnd, gint nAddressRightStart, gint nAddressRightEnd, const gchar* pszCityNameLeft, const gchar* pszCityNameRight, const gchar* pszStateNameLeft, const gchar* pszStateNameRight, const gchar* pszZIPLeft, const gchar* pszZIPRight, GArray* pMapPointsArray); // functions @@ -349,14 +349,13 @@ void search_road_on_roadsearch_struct(const roadsearch_t* pRoadSearch) nCount++; if(nCount <= SEARCH_RESULT_COUNT_LIMIT) { - pointstring_t* pPointString = NULL; - pointstring_alloc(&pPointString); - db_parse_wkb_linestring(aRow[3], pPointString->pPointsArray, point_alloc); - - 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], pPointString); + GArray* pMapPointsArray = g_array_new(FALSE, FALSE, sizeof(mappoint_t)); + db_parse_wkb_linestring(aRow[3], pMapPointsArray); + 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]); - pointstring_free(pPointString); + + g_array_free(pMapPointsArray, TRUE); } } db_free_result(pResultSet); @@ -383,10 +382,10 @@ typedef enum { #define HIGHLIGHT_DISTANCE_FROM_ROAD (0.00012) // this seems like a good amount... -static void pointstring_walk_percentage(pointstring_t* pPointString, gdouble fPercent, ERoadSide eRoadSide, mappoint_t* pReturnPoint) +static void mappoint_array_walk_percentage(GArray* pMapPointsArray, gdouble fPercent, ERoadSide eRoadSide, mappoint_t* pReturnPoint) { gint i; - if(pPointString->pPointsArray->len < 2) { + if(pMapPointsArray->len < 2) { g_assert_not_reached(); } @@ -394,25 +393,25 @@ static void pointstring_walk_percentage(pointstring_t* pPointString, gdouble fPe // count total distance // gfloat fTotalDistance = 0.0; - mappoint_t* pPointA = g_ptr_array_index(pPointString->pPointsArray, 0); + mappoint_t* pPointA = &g_array_index(pMapPointsArray, mappoint_t, 0); mappoint_t* pPointB; - for(i=1 ; i<pPointString->pPointsArray->len ; i++) { - pPointB = g_ptr_array_index(pPointString->pPointsArray, 1); + for(i=1 ; i<pMapPointsArray->len ; i++) { + pPointB = &g_array_index(pMapPointsArray, mappoint_t, 1); fTotalDistance += point_calc_distance(pPointA, pPointB); - + pPointA = pPointB; } gfloat fTargetDistance = (fTotalDistance * fPercent); gfloat fRemainingDistance = fTargetDistance; - pPointA = g_ptr_array_index(pPointString->pPointsArray, 0); - for(i=1 ; i<pPointString->pPointsArray->len ; i++) { - pPointB = g_ptr_array_index(pPointString->pPointsArray, 1); + pPointA = &g_array_index(pMapPointsArray, mappoint_t, 0); + for(i=1 ; i<pMapPointsArray->len ; i++) { + pPointB = &g_array_index(pMapPointsArray, mappoint_t, 1); gfloat fLineSegmentDistance = point_calc_distance(pPointA, pPointB); - if(fRemainingDistance <= fLineSegmentDistance || (i == pPointString->pPointsArray->len-1)) { + if(fRemainingDistance <= fLineSegmentDistance || (i == pMapPointsArray->len-1)) { // this is the line segment we are looking for. gfloat fPercentOfLine = (fRemainingDistance / fLineSegmentDistance); @@ -478,8 +477,7 @@ void search_road_filter_result( const gchar* pszCityNameLeft, const gchar* pszCityNameRight, const gchar* pszStateNameLeft, const gchar* pszStateNameRight, const gchar* pszZIPLeft, const gchar* pszZIPRight, - - pointstring_t* pPointString) + GArray* pMapPointsArray) { gint nRoadID = 0; gchar azBuffer[BUFFER_SIZE]; @@ -508,7 +506,7 @@ void search_road_filter_result( if(nRoadNumber == ROADSEARCH_NUMBER_NONE) { // Right in the center - pointstring_walk_percentage(pPointString, 0.5, ROADSIDE_CENTER, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, 0.5, ROADSIDE_CENTER, &ptAddress); // gint nStart = min4(nAddressLeftStart, nAddressLeftEnd, nAddressRightStart, nAddressRigtEnd); // gint nEnd = min4(nAddressLeftStart, nAddressLeftEnd, nAddressRightStart, nAddressRigtEnd); @@ -561,11 +559,11 @@ void search_road_filter_result( gint nRange = (nAddressLeftEnd - nAddressLeftStart); if(nRange == 0) { // just use road center...? - pointstring_walk_percentage(pPointString, 0.5, ROADSIDE_LEFT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, 0.5, ROADSIDE_LEFT, &ptAddress); } else { gfloat fPercent = (gfloat)(nRoadNumber - nAddressLeftStart) / (gfloat)nRange; - pointstring_walk_percentage(pPointString, fPercent, ROADSIDE_LEFT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, fPercent, ROADSIDE_LEFT, &ptAddress); } g_snprintf(azBuffer, BUFFER_SIZE, FORMAT_ROAD_RESULT_WITH_NUMBER, nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZLeft); searchwindow_add_result(SEARCH_RESULT_TYPE_ROAD, azBuffer, g_SearchResultTypeRoadGlyph, &ptAddress, ROAD_RESULT_SUGGESTED_ZOOMLEVEL); @@ -575,13 +573,13 @@ void search_road_filter_result( gint nRange = (nAddressLeftStart - nAddressLeftEnd); if(nRange == 0) { // just use road center...? - pointstring_walk_percentage(pPointString, 0.5, ROADSIDE_RIGHT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, 0.5, ROADSIDE_RIGHT, &ptAddress); } else { gfloat fPercent = (gfloat)(nRoadNumber - nAddressLeftEnd) / (gfloat)nRange; // flip percent (23 becomes 77, etc.) - pointstring_walk_percentage(pPointString, (100.0 - fPercent), ROADSIDE_RIGHT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, (100.0 - fPercent), ROADSIDE_RIGHT, &ptAddress); } g_snprintf(azBuffer, BUFFER_SIZE, FORMAT_ROAD_RESULT_WITH_NUMBER, nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZLeft); searchwindow_add_result(SEARCH_RESULT_TYPE_ROAD, azBuffer, g_SearchResultTypeRoadGlyph, &ptAddress, ROAD_RESULT_SUGGESTED_ZOOMLEVEL); @@ -598,11 +596,11 @@ void search_road_filter_result( gint nRange = (nAddressRightEnd - nAddressRightStart); if(nRange == 0) { // just use road center...? - pointstring_walk_percentage(pPointString, 0.5, ROADSIDE_RIGHT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, 0.5, ROADSIDE_RIGHT, &ptAddress); } else { gfloat fPercent = (gfloat)(nRoadNumber - nAddressRightStart) / (gfloat)nRange; - pointstring_walk_percentage(pPointString, fPercent, ROADSIDE_RIGHT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, fPercent, ROADSIDE_RIGHT, &ptAddress); } g_snprintf(azBuffer, BUFFER_SIZE, FORMAT_ROAD_RESULT_WITH_NUMBER, nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZRight); searchwindow_add_result(SEARCH_RESULT_TYPE_ROAD, azBuffer, g_SearchResultTypeRoadGlyph, &ptAddress, ROAD_RESULT_SUGGESTED_ZOOMLEVEL); @@ -612,13 +610,13 @@ void search_road_filter_result( gint nRange = (nAddressRightStart - nAddressRightEnd); if(nRange == 0) { // just use road center...? - pointstring_walk_percentage(pPointString, 0.5, ROADSIDE_LEFT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, 0.5, ROADSIDE_LEFT, &ptAddress); } else { gfloat fPercent = (gfloat)(nRoadNumber - nAddressRightEnd) / (gfloat)nRange; // flip percent (23 becomes 77, etc.) - pointstring_walk_percentage(pPointString, (100.0 - fPercent), ROADSIDE_LEFT, &ptAddress); + mappoint_array_walk_percentage(pMapPointsArray, (100.0 - fPercent), ROADSIDE_LEFT, &ptAddress); } g_snprintf(azBuffer, BUFFER_SIZE, FORMAT_ROAD_RESULT_WITH_NUMBER, nRoadNumber, pszRoadName, road_suffix_itoa(nRoadSuffixID, ROAD_SUFFIX_LENGTH_LONG), pszCSZRight); searchwindow_add_result(SEARCH_RESULT_TYPE_ROAD, azBuffer, g_SearchResultTypeRoadGlyph, &ptAddress, ROAD_RESULT_SUGGESTED_ZOOMLEVEL); |