You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(92) |
Dec
(141) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(126) |
Feb
(72) |
Mar
(31) |
Apr
(200) |
May
(81) |
Jun
(130) |
Jul
(112) |
Aug
(134) |
Sep
(76) |
Oct
(89) |
Nov
(153) |
Dec
(9) |
2007 |
Jan
(59) |
Feb
(82) |
Mar
(50) |
Apr
(20) |
May
(9) |
Jun
(81) |
Jul
(41) |
Aug
(109) |
Sep
(91) |
Oct
(87) |
Nov
(33) |
Dec
(60) |
2008 |
Jan
(21) |
Feb
(15) |
Mar
(38) |
Apr
(75) |
May
(59) |
Jun
(46) |
Jul
(30) |
Aug
(20) |
Sep
(35) |
Oct
(32) |
Nov
(34) |
Dec
(19) |
2009 |
Jan
(29) |
Feb
(71) |
Mar
(54) |
Apr
(17) |
May
(4) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(58) |
Sep
(7) |
Oct
(7) |
Nov
(12) |
Dec
(18) |
2011 |
Jan
(17) |
Feb
(29) |
Mar
(11) |
Apr
(5) |
May
(1) |
Jun
|
Jul
|
Aug
(11) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(87) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(44) |
Jun
(79) |
Jul
(16) |
Aug
(31) |
Sep
|
Oct
(51) |
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <dan...@us...> - 2011-04-21 06:35:27
|
Revision: 2683 http://roadmap.svn.sourceforge.net/roadmap/?rev=2683&view=rev Author: dannybackx Date: 2011-04-21 06:35:19 +0000 (Thu, 21 Apr 2011) Log Message: ----------- Expand on the navigation work. Not ready yet ! Plugins : add a function called after all initialisations ("start_work"), need this to restart routing calculation and be sure that the rest of roadmap is fully initialized. Trip : clean up the separation between roadmap_trip and roadmap_tripdb more. Modified Paths: -------------- trunk/roadmap/src/navigate/navigate.c trunk/roadmap/src/navigate/navigate.h trunk/roadmap/src/navigate/navigate_plugin.c trunk/roadmap/src/navigate/navigate_route.c trunk/roadmap/src/navigate/navigate_simple.c trunk/roadmap/src/roadmap_navigate.c trunk/roadmap/src/roadmap_plugin.c trunk/roadmap/src/roadmap_plugin.h trunk/roadmap/src/roadmap_track.c trunk/roadmap/src/roadmap_trip.c trunk/roadmap/src/roadmap_trip.h trunk/roadmap/src/roadmap_tripdb.c trunk/roadmap/src/roadmap_tripdb.h Modified: trunk/roadmap/src/navigate/navigate.c =================================================================== --- trunk/roadmap/src/navigate/navigate.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/navigate/navigate.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -119,6 +119,7 @@ */ NavigateStatus status; +#if 0 /** * @brief recalculate the route (implemented in navigate_route.c) * @return status @@ -178,6 +179,7 @@ #endif return 0; } +#endif /****** Route calculation progress dialog ******/ /** @@ -215,6 +217,7 @@ */ static void navigate_update (RoadMapPosition *position, PluginLine *current) { + roadmap_log (ROADMAP_WARNING, "navigate_update(%d %d, %d)", position ? position->longitude : 0, position ? position->latitude : 0, current ? current->line_id : 0); #if 0 int announce = 0; const NavigateSegment *segment = NavigateSegments + NavigateCurrentSegment; @@ -427,6 +430,9 @@ #endif } +// #define MAXCOUNTER 10 +#define MAXCOUNTER 3 + /** * @brief gets called after every GPS input, choose when to do something */ @@ -437,16 +443,15 @@ counter++; /* Don't call this so often */ - if (counter < 10) + if (counter < MAXCOUNTER) return; counter = 0; -// roadmap_log (ROADMAP_WARNING, "navigate_format_messages -> navigate_update(NULL, NULL);"); navigate_update(NULL, NULL); } /** - * @brief gets a GPS position update + * @brief gets a GPS position update, trigger route recalculation if necessary * @param position * @param line * @param street @@ -457,71 +462,84 @@ const PluginLine *line, const PluginStreet *street, const int street_has_changed) { - static RoadMapPosition oldpos; - static RoadMapPosition old, cur; - int x, y; - static int firsttime = 1; - int need_recalc = 0, r; - static int skip = 0; /**< count #times < HYST */ + static RoadMapPosition oldpos; + static RoadMapPosition old, cur; + int x, y; + static int firsttime = 1; + int need_recalc = 0, r; + static int skip = 0; /**< count #times < HYST */ + int ix; - if (position == 0) - return; + if (position == 0) { + roadmap_log (ROADMAP_WARNING, "navigate_update_position 0"); + return; + } - if (firsttime) { - roadmap_log (ROADMAP_WARNING, "navigate_update_position(%d %d) initial", - position->longitude, position->latitude); - need_recalc = 1; - } - firsttime = 0; + if (firsttime) { + roadmap_log (ROADMAP_WARNING, "navigate_update_position(%d %d) initial", + position->longitude, position->latitude); + need_recalc = 1; + } + firsttime = 0; - if (position->longitude == oldpos.longitude && position->latitude == oldpos.latitude) { - roadmap_log (ROADMAP_WARNING, "navigate_update_position return samepos"); - return; - } + if (position->longitude == oldpos.longitude && position->latitude == oldpos.latitude) { + roadmap_log (ROADMAP_WARNING, "navigate_update_position return samepos"); + return; + } - cur = *position; + cur = *position; #if 0 - if (roadmap_math_distance(&cur, &old) < HYST) { - firsttime = 0; - skip++; - return; - } + if (roadmap_math_distance(&cur, &old) < HYST) { + firsttime = 0; + skip++; + return; + } - roadmap_log (ROADMAP_WARNING, - "navigate_update_position(%d %d), line %d, street %d, changed %d, skip %d", - position->longitude, position->latitude, - line ? line->line_id : 0, - street ? street->street_id : 0, - street_has_changed, skip); - skip = 0; + roadmap_log (ROADMAP_WARNING, + "navigate_update_position(%d %d), line %d, street %d, changed %d, skip %d", + position->longitude, position->latitude, + line ? line->line_id : 0, + street ? street->street_id : 0, + street_has_changed, skip); + skip = 0; #else - firsttime = 0; + firsttime = 0; - roadmap_log (ROADMAP_WARNING, - "navigate_update_position(%d %d), line %d, street %d, changed %d", - position->longitude, position->latitude, - line ? line->line_id : 0, - street ? street->street_id : 0, - street_has_changed); + roadmap_log (ROADMAP_WARNING, + "navigate_update_position(%d %d), line %d, street %d, changed %d", + position->longitude, position->latitude, + line ? line->line_id : 0, + street ? street->street_id : 0, + street_has_changed); #endif - /* If we find that we need to re-evaluate the route, set this to 1 */ - if (street_has_changed) - need_recalc = 1; - /* If the current line is outside the current route ... */ - if (line && ! navigate_line_in_route (&status, line->line_id)) - need_recalc = 1; + /* If the current line is outside the current route ... */ + ix = 0; + if (line && ! (ix = navigate_line_in_route (&status, line->line_id))) + need_recalc = 1; - /* Recalculate the route under conditions determined above */ - roadmap_log (ROADMAP_WARNING, "navigate_update_position recalc %d", need_recalc); - if (need_recalc) { - r = navigate_recalc_route(); - } + /* Now ix is the index of the line in this route */ + if (ix) { + navigate_line_skip (&status, line->line_id, ix); + } else { + /* If we find that we need to re-evaluate the route, set this to 1 */ + if (street_has_changed) + need_recalc = 1; - oldpos = *position; - old = cur; + /* FIX ME */ + status.first->segment->from_pos = *position; + + /* Recalculate the route under conditions determined above */ + roadmap_log (ROADMAP_WARNING, "navigate_update_position recalc %d", need_recalc); + if (need_recalc) { + r = navigate_route_recalc(&status); + } + } + + oldpos = *position; + old = cur; } #if 0 @@ -650,15 +668,7 @@ /** * @brief - * @return */ -int navigate_is_enabled (void) { - return NavigateEnabled; -} - -/** - * @brief - */ static void navigate_init_pens (void) { RoadMapPen pen; @@ -691,22 +701,38 @@ */ void navigate_shutdown (void) { - roadmap_config_set_integer (&NavigateConfigNavigating, 0); + roadmap_config_set_integer (&NavigateConfigNavigating, 0); } /** + * @brief initialize the status structure + */ +void navigate_status_initialize (void) +{ + status.first = status.last = (NavigateIteration *)0; + status.current = (NavigateIteration *)0; + status.iteration = 0; + status.maxdist = 0; +} + +/** * @brief */ void navigate_initialize (void) { - roadmap_log (ROADMAP_DEBUG, "navigate_initialize"); - roadmap_config_declare ("preferences", &NavigateConfigRouteColor, "#00ff00a0"); - roadmap_config_declare ("preferences", &NavigateConfigPossibleRouteColor, "#ff0000a0"); + roadmap_log (ROADMAP_WARNING, "navigate_initialize"); + roadmap_config_declare + ("preferences", &NavigateConfigRouteColor, "#00ff00a0"); + roadmap_config_declare + ("preferences", &NavigateConfigPossibleRouteColor, "#ff0000a0"); roadmap_config_declare_enumeration ("preferences", &NavigateConfigAutoZoom, "no", "yes", NULL); - roadmap_config_declare ("session", &NavigateConfigLastPos, "0, 0"); - roadmap_config_declare ("session", &NavigateConfigNavigating, "0"); + roadmap_config_declare + ("session", &NavigateConfigLastPos, "0, 0"); + roadmap_config_declare + ("session", &NavigateConfigNavigating, "0"); + navigate_status_initialize (); navigate_init_pens (); navigate_cost_initialize (); navigate_bar_initialize (); @@ -718,37 +744,23 @@ navigate_shst_initialize (); #endif - navigate_set (1); + roadmap_navigate_enable (); /* FIX ME probably not right */ // roadmap_address_register_nav (navigate_address_cb); roadmap_skin_register (navigate_init_pens); - -#if 0 - /* FIX ME need to figure out why this causes roadmap to stop */ - if (roadmap_config_get_integer (&NavigateConfigNavigating)) { - RoadMapPosition pos; - roadmap_config_get_position (&NavigateConfigLastPos, &pos); - roadmap_trip_set_focus ("GPS"); - roadmap_trip_set_point ("Destination", &pos); - - navigate_calc_route (); - } -#endif } -/** - * @brief enable or disable navigation - * @param status whether to set NavigateEnabled - */ -void navigate_set (int status) +void navigate_start_work (void) { - if (status && NavigateEnabled) { - return; - } else if (!status && !NavigateEnabled) { - return; - } + roadmap_log (ROADMAP_WARNING, "navigate_start_work"); + if (roadmap_config_get_integer (&NavigateConfigNavigating)) { + RoadMapPosition pos; + roadmap_config_get_position (&NavigateConfigLastPos, &pos); + roadmap_trip_set_focus ("GPS"); + roadmap_trip_set_point ("Destination", &pos); - NavigateEnabled = status; + navigate_calc_route (); + } } /** @@ -808,9 +820,6 @@ int i; int length = 0; - length = status.current->cost.distance; - track_time = status.current->cost.time; - roadmap_dialog_hide ("Route calc"); NavigateFlags = flags; @@ -819,6 +828,9 @@ roadmap_lang_get ("The calculated route may have incorrect turn instructions.")); } + length = status.current->cost.distance; + track_time = status.current->cost.time; + snprintf(msg + strlen(msg), sizeof(msg) - strlen(msg), "%s: %.1f %s,\n%s: %.1f %s", roadmap_lang_get ("Length"), @@ -855,7 +867,7 @@ TRIP_PLACE_ROUTE_MARK_START); for (i=0, p=status.first; p; p = p->next, i++) { - roadmap_trip_add_point_way( + roadmap_tripdb_add_point_way( p->segment->from_point, p->segment->to_point, p->segment->line, @@ -982,16 +994,34 @@ * @brief figure out whether the line passed is on the route * @param stp current navigation status (= list of lines) * @param line a line identifier - * @return 1 if the line is on this route, 0 if not + * @return the position of the line on this route, 0 if not on the route */ int navigate_line_in_route (NavigateStatus *stp, int line) { - NavigateIteration *p; + NavigateIteration *p; + int i; - for (p=stp->first; p; p = p->next) { - if (line == p->segment->line.line_id) - return 1; - } + for (i=1, p=stp->first; p; p = p->next) { + if (line == p->segment->line.line_id) + return i; + i++; + } - return 0; + return 0; } + +/** + * @brief skip ix segments, we know we're that far on the route + * @param stp pointer to status (to be changed) + * @param line line we're currently on + * @param ix index of the line in this route + */ +void navigate_line_skip (NavigateStatus *stp, int line, int ix) +{ + NavigateIteration *p; + + roadmap_log (ROADMAP_WARNING, "navigate_line_skip(%d,%d)", line, ix); + for (p = stp->first; p; p = p->next) + if (line == p->segment->line.line_id) + stp->current = p; +} Modified: trunk/roadmap/src/navigate/navigate.h =================================================================== --- trunk/roadmap/src/navigate/navigate.h 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/navigate/navigate.h 2011-04-21 06:35:19 UTC (rev 2683) @@ -84,9 +84,9 @@ * The code should maintain a doubly linked list of these */ typedef struct NavigateIteration { - struct NavigateIteration *prev, *next; - struct NavigateSegment *segment; - struct NavigateCost cost; + struct NavigateIteration *prev, *next; + struct NavigateSegment *segment; + struct NavigateCost cost; } NavigateIteration; /** @@ -96,10 +96,10 @@ * may be extended by a navigation algorithm */ typedef struct { - NavigateIteration *first, *last; - NavigateIteration *current; - int iteration; - int maxdist; + NavigateIteration *first, *last; /**< */ + NavigateIteration *current; /**< */ + int iteration; /**< */ + int maxdist; /**< */ } NavigateStatus; /* @@ -129,6 +129,7 @@ int navigate_is_enabled (void); void navigate_shutdown (void); void navigate_initialize (void); +void navigate_start_work (void); int navigate_reload_data (void); void navigate_set (int status); int navigate_calc_route (void); @@ -147,5 +148,6 @@ const PluginLine *, const PluginStreet *, const int); // plugin_update_position navigate_update_position; int navigate_line_in_route (NavigateStatus *stp, int line); +void navigate_line_skip (NavigateStatus *stp, int line, int ix); #endif /* INCLUDE__NAVIGATE_H */ Modified: trunk/roadmap/src/navigate/navigate_plugin.c =================================================================== --- trunk/roadmap/src/navigate/navigate_plugin.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/navigate/navigate_plugin.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2005 Ehud Shabtai - * Copyright (c) 2008, Danny Backx. + * Copyright (c) 2008, 2009, 2011, Danny Backx. * * This file is part of RoadMap. * @@ -125,7 +125,7 @@ "Set the selected street block as the trip's destination", NULL, roadmap_start_set_destination}, - {"navigate", "Navigate", NULL, NULL, + {"navigate", "Navigate to dest", NULL, NULL, "Calculate route", NULL, navigate_start_navigate}, {"setasdeparture", "Set as Departure", NULL, NULL, @@ -155,6 +155,9 @@ {"navigate-disable", "Disable navigation", NULL, NULL, "Disable navigation", NULL, roadmap_navigate_disable}, +// {"navigate-to", "Navigate to destination", NULL, NULL, +// "Navigate to destination", NULL, navigate_to_destination}, + {"navigate-shutdown", "Stop navigation", NULL, NULL, "Stop navigation", NULL, navigate_shutdown}, @@ -173,6 +176,7 @@ "navigate-be-debug", "navigate-sf-debug", "navigate", +// "navigate-to", RoadMapFactorySeparator, "traffic", "navigate-enable", @@ -217,7 +221,8 @@ /* format messages */ &navigate_format_messages, /* route_clear */ navigate_visual_route_clear, /* route_add */ navigate_visual_route_add, - /* update_position */ navigate_update_position + /* update_position */ navigate_update_position, + /* start_work */ navigate_start_work }; /** Modified: trunk/roadmap/src/navigate/navigate_route.c =================================================================== --- trunk/roadmap/src/navigate/navigate_route.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/navigate/navigate_route.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -49,13 +49,13 @@ */ void navigate_algorithm_register(NavigateAlgorithm *algo) { - if (nAlgorithms == alloc) { - alloc += 4; - Algo = (NavigateAlgorithm *)realloc((void *)Algo, - sizeof(NavigateAlgorithm) * alloc); - } - Algo[nAlgorithms] = *algo; - nAlgorithms++; + if (nAlgorithms == alloc) { + alloc += 4; + Algo = (NavigateAlgorithm *)realloc((void *)Algo, + sizeof(NavigateAlgorithm) * alloc); + } + Algo[nAlgorithms] = *algo; + nAlgorithms++; } /** @@ -65,10 +65,110 @@ */ int navigate_route_recalc (NavigateStatus *stp) { - roadmap_log (ROADMAP_WARNING, "navigate_route_recalc"); + int i, ok; + NavigateIteration *p, *q; + NavigateStatus rev; + + if (! Algo) { + roadmap_log (ROADMAP_WARNING, "navigate_route_recalc -> no algorithm"); + return -1; + } + + /* Has the navigation algorithm run on this status yet ? */ + if (stp->first == NULL) { + roadmap_log (ROADMAP_WARNING, "navigate_route_recalc -> no previous route"); + return -1; + } + + // roadmap_log (ROADMAP_WARNING, "navigate_route_recalc"); + roadmap_log (ROADMAP_WARNING, "navigate_route_recalc from %d (%d %d) to %d (%d %d)", stp->first->segment->line.line_id, stp->first->segment->from_pos.longitude, stp->first->segment->from_pos.latitude, stp->last->segment->line.line_id, stp->last->segment->to_pos.longitude, stp->last->segment->to_pos.latitude); + + + /* Delete nodes in the old route */ + p = stp->first; + if (p->next) + for (p = p->next; p; p = q) { + q = p->next; + if (p != stp->last) + free(p); + } + + stp->first->next = stp->first->prev = NULL; + stp->last->next = stp->last->prev = NULL; + stp->current = stp->first; + + stp->first->cost.distance = 0; + stp->last->cost.distance = 0; + stp->first->cost.time = 0; + stp->last->cost.time = 0; + + + /* Prepare for running the algorithm from both directions */ + rev.first = stp->last; + rev.last = stp->first; + + stp->iteration = 1; + ok = 0; + while (stp->iteration <= Algo->max_iterations) { + Algo->step_fn(Algo, stp); + if (Algo->end_fn(stp)) { + ok = 1; + break; + } + if (Algo->both_ways) { + Algo->step_fn(Algo, &rev); + if (Algo->end_fn(stp)) { + ok = 1; + break; + } + } + stp->iteration++; + } + + /* Hook up the last entry */ + stp->current->next = stp->last; + stp->last->prev = stp->current; + + if (! ok) + roadmap_log (ROADMAP_WARNING, "navigate_route_recalc : max #iterations reached (%d).", + Algo->max_iterations); + else { + roadmap_log (ROADMAP_WARNING, + "navigate_route_recalc, %d iterations, %d hops\n\t%s: %.1f %s, %s: %.1f %s", + stp->iteration, navigate_route_numhops(stp), + roadmap_lang_get ("Length"), + stp->current->cost.distance / 1000.0, + roadmap_lang_get ("Km"), + roadmap_lang_get ("Time"), + stp->current->cost.time / 60.0, + roadmap_lang_get ("minutes")); + int i; + NavigateIteration *p; + for (i=0, p=stp->first; p; p=p->next, i++) + fprintf(stderr, "\t[%d] %d (%d %d -> %d %d) %.1f %.1f {%d} %p\n", + i, p->segment->line.line_id, + p->segment->from_pos.longitude, p->segment->from_pos.latitude, + p->segment->to_pos.longitude, p->segment->to_pos.latitude, + p->cost.distance / 1000.0, p->cost.time / 60.0, + roadmap_math_distance(&p->segment->from_pos, &stp->last->segment->to_pos), + p); + fprintf(stderr, "First %p Last %p Current %p Last->Prev %p\n", + stp->first, stp->last, stp->current, stp->last->prev); + } + return 0; } +int navigate_route_numhops(NavigateStatus *stp) +{ + NavigateIteration *p; + int i; + + for (i=0, p=stp->first; p; p = p->next) + i++; + return i; +} + /** * @brief calculate the basic route. * @@ -86,76 +186,78 @@ PluginLine *to_line, RoadMapPosition to_pos) { - int i, ok; - NavigateIteration *p; - NavigateStatus status, rev; + int i, ok; + NavigateIteration *p; + NavigateStatus status, *stp = &status, rev; - roadmap_log (ROADMAP_WARNING, "navigate_route_get_initial"); + roadmap_log (ROADMAP_WARNING, "navigate_route_get_initial from %d (%d %d) to %d (%d %d)", from_line->line_id, from_pos.longitude, from_pos.latitude, to_line->line_id, to_pos.longitude, to_pos.latitude); - if (! Algo) - return (NavigateStatus) {NULL, NULL, NULL, 0, 0}; + if (! Algo) + return (NavigateStatus) {NULL, NULL, NULL, 0, 0}; - /* navigate_route_setup(); */ + /* navigate_route_setup(); */ - /* Set up the start info */ - status.first = calloc(1, sizeof(struct NavigateIteration)); - status.last = calloc(1, sizeof(struct NavigateIteration)); + /* Set up the start info */ + stp->first = calloc(1, sizeof(struct NavigateIteration)); + stp->last = calloc(1, sizeof(struct NavigateIteration)); - status.first->prev = status.first->next = NULL; - status.last->prev = status.last->next = NULL; - status.first->segment = calloc(1, sizeof(struct NavigateSegment)); - status.last->segment = calloc(1, sizeof(struct NavigateSegment)); + stp->first->prev = status.first->next = NULL; + stp->last->prev = status.last->next = NULL; + stp->first->segment = calloc(1, sizeof(struct NavigateSegment)); + stp->last->segment = calloc(1, sizeof(struct NavigateSegment)); - status.first->segment->line = *from_line; - status.first->segment->from_pos = from_pos; - status.first->segment->to_pos = from_pos; + stp->first->segment->line = *from_line; + stp->first->segment->from_pos = from_pos; + stp->first->segment->to_pos = from_pos; - status.last->segment->line = *to_line; - status.last->segment->from_pos = to_pos; - status.last->segment->to_pos = to_pos; + stp->last->segment->line = *to_line; + stp->last->segment->from_pos = to_pos; + stp->last->segment->to_pos = to_pos; - status.first->cost.distance = 0; - status.last->cost.distance = 0; - status.first->cost.time = 0; - status.last->cost.time = 0; + stp->first->cost.distance = 0; + stp->last->cost.distance = 0; + stp->first->cost.time = 0; + stp->last->cost.time = 0; - status.first->cost.distance = 0; - status.first->cost.time = 0; + stp->maxdist = roadmap_math_distance(&from_pos, &to_pos); - status.maxdist = roadmap_math_distance(&from_pos, &to_pos); + stp->current = status.first; - status.current = status.first; + /* + * Prepare for running the algorithm from both directions + */ + rev.first = stp->last; + rev.last = stp->first; - /* - * Prepare for running the algorithm from both directions - */ - rev.first = status.last; - rev.last = status.first; + stp->iteration = 1; + ok = 0; + while (stp->iteration <= Algo->max_iterations) { + Algo->step_fn(Algo, stp); + if (Algo->end_fn(stp)) { + ok = 1; + break; + } + if (Algo->both_ways) { + Algo->step_fn(Algo, &rev); + if (Algo->end_fn(stp)) { + ok = 1; + break; + } + } + stp->iteration++; + } - status.iteration = 1; - ok = 0; - while (status.iteration <= Algo->max_iterations) { - Algo->step_fn(Algo, &status); - if (Algo->end_fn(&status)) { - ok = 1; - break; - } - if (Algo->both_ways) { - Algo->step_fn(Algo, &rev); - if (Algo->end_fn(&status)) { - ok = 1; - break; - } - } - status.iteration++; - } - if (! ok) - roadmap_log (ROADMAP_WARNING, "Max #iterations reached (%d).", - Algo->max_iterations); - else - roadmap_log (ROADMAP_WARNING, "navigate_route_get_initial, %d iterations", status.iteration); + if (ok) { + roadmap_log (ROADMAP_WARNING, "navigate_route_get_initial, %d iterations", stp->iteration); - return status; + /* Hook up the last entry */ + stp->current->next = stp->last; + stp->last->prev = stp->current; + } else { + roadmap_log (ROADMAP_WARNING, "Max #iterations reached (%d).", Algo->max_iterations); + } + + return status; } /** @@ -164,7 +266,7 @@ */ int navigate_route_reload_data (void) { - return 0; + return 0; } /** Modified: trunk/roadmap/src/navigate/navigate_simple.c =================================================================== --- trunk/roadmap/src/navigate/navigate_simple.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/navigate/navigate_simple.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -1,6 +1,6 @@ /* * LICENSE: - * Copyright (c) 2008, 2009 by Danny Backx. + * Copyright (c) 2008, 2009, 2011 by Danny Backx. * * This file is part of RoadMap. * @@ -152,6 +152,9 @@ /** * @brief move one step forward from the current position + * Assumptions : + * stp->current is allocated, this is where we've gone until now + * stp->last->segment->to_pos is where we're going * @param algo the algorithm pointer * @param stp pointer to the navigation status to work on * @return success (-1 is failure, 0 is backtrack, 1 is success) @@ -167,13 +170,15 @@ NavigateIteration *p; RoadMapPosition newpos, newpos2, bestnewpos; - NavigateSegment *s = stp->current->segment; NavigateSegment bestseg; + + /* Ignore NULL pointer risks here, see assumptions */ RoadMapPosition to_pos = stp->last->segment->to_pos; + NavigateSegment *s = stp->current->segment; /* Figure out where to start */ nlines = 0; - if (s->from_point) { + if (s && s->from_point) { point = s->from_point; nlines = navigate_simple_lines_closeby(s->from_point, lines, maxlines); } @@ -193,7 +198,7 @@ if (nlines == 0) { /* This is too simplistic, maybe backtrack from here too ? */ - return -1; + return -1; /* Failure */ } /* Allocate the next entry */ @@ -328,7 +333,7 @@ if (best < 0) { if (stp->iteration < 2) { roadmap_log (ROADMAP_WARNING, "On an island ?"); - return -1; + return -1; /* Failure */ } roadmap_log (ROADMAP_DEBUG, "Backtrack .."); @@ -338,7 +343,7 @@ stp->current = stp->current->prev; if (stp->current == 0) stp->current = stp->first; - return 0; + return 0; /* Backtrack */ } /* Put the data for the "best" selection back */ @@ -361,8 +366,8 @@ bestnewpt, stp->current->segment->distance, stp->current->segment->time); - /* return */ - return 1; + + return 1; /* Success */ } /** @@ -389,7 +394,8 @@ roadmap_log (ROADMAP_DEBUG, "Distance is now %d", dist); if (dist < NavigateEndAtThisDistance) - return 1; + return 1; /* Stop */ + return 0; /* Keep going */ #if 0 if (!stop && to_line && to_line->line_id == lines[best].line_id) Modified: trunk/roadmap/src/roadmap_navigate.c =================================================================== --- trunk/roadmap/src/roadmap_navigate.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_navigate.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -94,6 +94,11 @@ return RoadMapNavigateMode; } +/** + * @brief announce to the user that we're on another street (well, .., line actually) + * @param format the string to show (with formatting) + * @param line the new line we're on + */ static void roadmap_navigate_trace (const char *format, PluginLine *line) { char text[1024]; @@ -157,7 +162,7 @@ } /** - * @brief + * @brief disable navigation */ void roadmap_navigate_disable (void) { @@ -169,9 +174,9 @@ } /** - * @brief + * @brief enable navigation */ -void roadmap_navigate_enable (void) +void roadmap_navigate_enable (void) { RoadMapNavigateEnabled = 1; @@ -588,6 +593,12 @@ if (! roadmap_plugin_same_line (&RoadMapConfirmedLine.line, &RoadMapNeighbourhood[found].line)) { + /* We're on another line than before + * + * Note: as two lines may be part of the same street, + * we're not with certainty on another street. + */ + if (PLUGIN_VALID(RoadMapConfirmedLine.line)) { roadmap_navigate_trace ("Quit street %N", &RoadMapConfirmedLine.line); } @@ -604,8 +615,19 @@ RoadMapConfirmedStreet.fuzzyfied = best; INVALIDATE_PLUGIN(RoadMapConfirmedStreet.intersection); + /* ?? */ +#if 0 roadmap_display_activate ("Current Street", &RoadMapConfirmedLine.line, NULL, &RoadMapConfirmedStreet.street); +#else /* Danny hack FIX ME */ + { + RoadMapPosition p; + p.longitude = gps_position->longitude; + p.latitude = gps_position->latitude; + roadmap_display_activate ("Current Street", &RoadMapConfirmedLine.line, + &p, &RoadMapConfirmedStreet.street); + } +#endif if (gps_position->speed > roadmap_gps_speed_accuracy()) { PluginLine p_line; @@ -635,6 +657,7 @@ { int RoadMapNavigationClasses; + roadmap_log (ROADMAP_WARNING, "roadmap_navigate_initialize"); RoadMapNavigationClasses = roadmap_layer_declare_navigation_mode ("Classes"); roadmap_config_declare_enumeration ("session", &RoadMapNavigateFlag, "yes", "no", NULL); } Modified: trunk/roadmap/src/roadmap_plugin.c =================================================================== --- trunk/roadmap/src/roadmap_plugin.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_plugin.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -647,6 +647,18 @@ } } +/** + * @brief + */ +void roadmap_plugin_start_work (void) +{ + int i; + for (i=1; i<=PluginCount; i++) { + RoadMapPluginHooks *hp = get_hooks (i); + if (hp && hp->start_work) + hp->start_work (); + } +} int roadmap_plugin_get_closest (const RoadMapPosition *position, Modified: trunk/roadmap/src/roadmap_plugin.h =================================================================== --- trunk/roadmap/src/roadmap_plugin.h 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_plugin.h 2011-04-21 06:35:19 UTC (rev 2683) @@ -206,6 +206,7 @@ typedef void (*plugin_route_add)(int, int, int); typedef void (*plugin_update_position)(const RoadMapPosition *, const PluginLine *, const PluginStreet *, const int); +typedef void (*plugin_start_work) (void); /** * @brief definition of a plugin @@ -236,6 +237,7 @@ plugin_route_clear route_clear; /**< clear the route */ plugin_route_add route_add; /**< add a hop to the route */ plugin_update_position update_position; /**< GPS position info update */ + plugin_start_work start_work; /**< kick off the plugin after initialize */ } RoadMapPluginHooks; #define ROADMAP_PLUGIN_ID 0 @@ -295,6 +297,7 @@ char *roadmap_plugin_list_all_plugins(void); void roadmap_plugin_after_refresh(); void roadmap_plugin_format_messages(); +void roadmap_plugin_start_work(); #ifdef HAVE_NAVIGATE_PLUGIN void roadmap_plugin_get_line_points (const PluginLine *line, Modified: trunk/roadmap/src/roadmap_track.c =================================================================== --- trunk/roadmap/src/roadmap_track.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_track.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -36,10 +36,10 @@ * of the list to an archive file, and save the rest to the * currenttrack file. * - * To protect against trackpoint loss from a crash that migh + * To protect against trackpoint loss from a crash that might * occur in between the periodic saves, we write individual * trackpoints to a small CSV file. On startup, if this file - * exists, we appendit to what we got from teh currenttrack file. + * exists, we append it to what we got from the currenttrack file. */ Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_trip.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -630,6 +630,9 @@ roadmap_screen_hold(); } +/** + * @brief + */ void roadmap_trip_restore_focus (void) { RoadMapTripFocal *focal, *fallback = NULL; @@ -650,6 +653,7 @@ } + roadmap_log (ROADMAP_WARNING, "roadmap_trip_restore_focus(%s) {%d,%d}", focal->id, focal->map.latitude, focal->map.longitude); if (focal->mobile) { /* This is a mobile point: what was recorded was the GPS Modified: trunk/roadmap/src/roadmap_trip.h =================================================================== --- trunk/roadmap/src/roadmap_trip.h 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_trip.h 2011-04-21 06:35:19 UTC (rev 2683) @@ -118,6 +118,7 @@ void roadmap_trip_move_last_place(void); void roadmap_trip_move_routepoint_ahead (void); void roadmap_trip_move_routepoint_back (void); +void roadmap_trip_complete (void); int roadmap_trip_move_last_place_callback (int action, const RoadMapGuiPoint *point); Modified: trunk/roadmap/src/roadmap_tripdb.c =================================================================== --- trunk/roadmap/src/roadmap_tripdb.c 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_tripdb.c 2011-04-21 06:35:19 UTC (rev 2683) @@ -1,7 +1,7 @@ /* * LICENSE: * - * Copyright (c) 2008, 2009 Danny Backx + * Copyright (c) 2008, 2009, 2011 Danny Backx * * This file is part of RoadMap. * @@ -86,7 +86,7 @@ * @brief * @param pos */ -void roadmap_trip_add_waypoint_iter (RoadMapPosition pos) +void roadmap_tripdb_add_waypoint_iter (RoadMapPosition pos) { waypoint *wpt = waypt_new(); wpt->pos = pos; @@ -118,13 +118,13 @@ */ #define TRIP_MAX_NEIGHBOURS 200 #define MAX_CAT 10 -void roadmap_trip_add_way(RoadMapPosition from, RoadMapPosition to, enum RoadMapTurningInstruction instr) +void roadmap_tripdb_add_way(RoadMapPosition from, RoadMapPosition to, enum RoadMapTurningInstruction instr) { int num, ncategories, maxneighbours, i; int categories[MAX_CAT]; RoadMapNeighbour neighbours[TRIP_MAX_NEIGHBOURS]; - roadmap_log (ROADMAP_DEBUG, "trip_add_way %d", RoadMapTripNumSegments); + roadmap_log (ROADMAP_DEBUG, "tripdb_add_way %d", RoadMapTripNumSegments); RoadMapTripSegments[RoadMapTripNumSegments].instruction = instr; RoadMapTripSegments[RoadMapTripNumSegments].from_pos = from; @@ -137,7 +137,7 @@ num = roadmap_street_get_closest(&from, categories, ncategories, neighbours, maxneighbours); if (num == TRIP_MAX_NEIGHBOURS) { - roadmap_log (ROADMAP_WARNING, "trip_add_way: sizing %d insufficient", + roadmap_log (ROADMAP_WARNING, "tripdb_add_way: sizing %d insufficient", TRIP_MAX_NEIGHBOURS); } @@ -163,10 +163,9 @@ */ #define TRIP_MAX_NEIGHBOURS 200 #define MAX_CAT 10 -void roadmap_trip_add_point_way(int from_point, int to_point, PluginLine line, enum RoadMapTurningInstruction instr) +void roadmap_tripdb_add_point_way(int from_point, int to_point, PluginLine line, enum RoadMapTurningInstruction instr) { - roadmap_log (ROADMAP_DEBUG, "trip_add_way2 %d, line %d", - RoadMapTripNumSegments, line.line_id); + roadmap_log (ROADMAP_WARNING, "roadmap_tripdb_add_point_way %d, line %d", RoadMapTripNumSegments, line.line_id); RoadMapTripSegments[RoadMapTripNumSegments].instruction = instr; roadmap_point_position(from_point, &RoadMapTripSegments[RoadMapTripNumSegments].from_pos); @@ -188,7 +187,7 @@ return; } - roadmap_trip_add_way(RoadMapTripLastPos, + roadmap_tripdb_add_way(RoadMapTripLastPos, waypointp->pos, (waypointp == RoadMapTripDest) ? TRIP_APPROACHING_DESTINATION : TRIP_CONTINUE); @@ -211,7 +210,7 @@ */ void roadmap_tripdb_remove_point (const char *name) { -#warning reimplement roadmap_trip_remove_point +#warning reimplement roadmap_tripdb_remove_point #if 0 RoadMapTripPoint *result; if (name == NULL) { Modified: trunk/roadmap/src/roadmap_tripdb.h =================================================================== --- trunk/roadmap/src/roadmap_tripdb.h 2011-04-07 18:13:02 UTC (rev 2682) +++ trunk/roadmap/src/roadmap_tripdb.h 2011-04-21 06:35:19 UTC (rev 2683) @@ -71,8 +71,8 @@ void roadmap_tripdb_empty_list (void); void roadmap_tripdb_add_waypoint_iter (RoadMapPosition pos); void roadmap_trip_complete (void); -void roadmap_trip_add_way(RoadMapPosition from, RoadMapPosition to, enum RoadMapTurningInstruction instr); -void roadmap_trip_add_point_way(int from_point, int to_point, PluginLine line, enum RoadMapTurningInstruction instr); +void roadmap_tripdb_add_way(RoadMapPosition from, RoadMapPosition to, enum RoadMapTurningInstruction instr); +void roadmap_tripdb_add_point_way(int from_point, int to_point, PluginLine line, enum RoadMapTurningInstruction instr); void roadmap_tripdb_waypoint_iter (const waypoint *waypointp); void roadmap_tripdb_initialize (void); void roadmap_tripdb_remove_point (const char *name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-04-07 18:13:09
|
Revision: 2682 http://roadmap.svn.sourceforge.net/roadmap/?rev=2682&view=rev Author: dannybackx Date: 2011-04-07 18:13:02 +0000 (Thu, 07 Apr 2011) Log Message: ----------- roadmap_gps.c : copy values 2 or 3 (MODE_2D, MODE_3D) for GPS reception immediately roadmap_gpsd3.c : pass on dilution info too Modified Paths: -------------- trunk/roadmap/src/roadmap_gps.c trunk/roadmap/src/roadmap_gpsd3.c Modified: trunk/roadmap/src/roadmap_gps.c =================================================================== --- trunk/roadmap/src/roadmap_gps.c 2011-04-03 12:36:18 UTC (rev 2681) +++ trunk/roadmap/src/roadmap_gps.c 2011-04-07 18:13:02 UTC (rev 2682) @@ -155,7 +155,9 @@ } /** - * @brief + * @brief call listeners if we get a new state. + * State is derived from a few inputs, one of which is a heuristic about good reception. + * Currently this is the only place in RoadMap where a dilution value is used. */ static void roadmap_gps_update_reception (void) { @@ -165,6 +167,10 @@ RoadMapGpsLatestData == 0) { new_state = GPS_RECEPTION_NA; + } else if (RoadMapGpsQuality.dimension == 2) { + new_state = GPS_RECEPTION_POOR; + } else if (RoadMapGpsQuality.dimension >= 3) { + new_state = GPS_RECEPTION_GOOD; } else if (RoadMapLastKnownStatus != 'A') { new_state = GPS_RECEPTION_NONE; @@ -724,7 +730,13 @@ RoadMapGpsSatelliteCount = sequence; } - +/** + * @brief called with GPS dilution data + * @param dimension Indicates the quality of the GPS data. Encoding appears to be derived from gps.h (from gpsd) : 0 = MODE_NOT_SEEN, 1 = MODE_NO_FIX, 2 = MODE_2D, 3 = MODE_3D. + * @param position Longitude position uncertainty, meters + * @param horizontal Latitude position uncertainty, meters + * @param vertical Vertical position uncertainty, meters + */ static void roadmap_gps_dilution (int dimension, double position, double horizontal, Modified: trunk/roadmap/src/roadmap_gpsd3.c =================================================================== --- trunk/roadmap/src/roadmap_gpsd3.c 2011-04-03 12:36:18 UTC (rev 2681) +++ trunk/roadmap/src/roadmap_gpsd3.c 2011-04-07 18:13:02 UTC (rev 2682) @@ -159,6 +159,13 @@ } } (*RoadmapGpsd2SatelliteListener) (0, 0, 0, 0, 0, 0); + + /* Provide dilution */ + if (gpsdp->fix.mode >= MODE_NO_FIX) { + /* No conversion required */ + RoadmapGpsd2DilutionListener(gpsdp->fix.mode, gpsdp->fix.epx, gpsdp->fix.epy, gpsdp->fix.epv); + } + return 1; #else return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-04-03 12:36:24
|
Revision: 2681 http://roadmap.svn.sourceforge.net/roadmap/?rev=2681&view=rev Author: dannybackx Date: 2011-04-03 12:36:18 +0000 (Sun, 03 Apr 2011) Log Message: ----------- Tweaks to graphics and socket I/O handling. Modified Paths: -------------- trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/Panel.java trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java Modified: trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/Panel.java =================================================================== --- trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/Panel.java 2011-04-02 08:07:59 UTC (rev 2680) +++ trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/Panel.java 2011-04-03 12:36:18 UTC (rev 2681) @@ -1,7 +1,7 @@ /* * LICENSE: * - * Copyright 2010 Danny Backx + * Copyright (c) 2010, 2011, Danny Backx * * This file is part of RoadMap. * @@ -199,7 +199,10 @@ paint = pen.GetPaint(); - paint.setTextSize(size); + if (size != 0) + paint.setTextSize(size); + else + paint.setTextSize(12); paint.setTypeface(face); // Copy from gtk2/roadmap_canvas.c:roadmap_canvas_draw_string() @@ -218,7 +221,7 @@ if ((corner & ROADMAP_CANVAS_BOTTOM) != 0) y -= descent; else if ((corner & ROADMAP_CANVAS_CENTER_Y) != 0) - y -= descent + height / 2; + y = y - descent + height / 2; else /* TOP */ y += ascent; Modified: trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java =================================================================== --- trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java 2011-04-02 08:07:59 UTC (rev 2680) +++ trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java 2011-04-03 12:36:18 UTC (rev 2681) @@ -1,7 +1,7 @@ /* * LICENSE: * - * Copyright (c) 2010, 2011 Danny Backx + * Copyright (c) 2010, 2011, Danny Backx * * This file is part of RoadMap. * @@ -279,7 +279,6 @@ public void MainSetInputAndroid(int id) { InputHandler = id; - // Log.e("RoadMap", "MainSetInput("+id+")"); try { mgr.addNmeaListener(onNmea); } catch (Exception e) { @@ -312,7 +311,11 @@ } try { - Thread.sleep(1000); + /* + * There's very little reason to do this much faster... + * a sub-second wait (e.g. 200) appears to make things worse. + */ + Thread.sleep(5000); } catch (Exception e) { }; } @@ -334,7 +337,6 @@ NmeaListener onNmea = new NmeaListener() { public void onNmeaReceived(long ts, String nmea) { - // Log.e("RoadMap", "onNmeaReceived("+ts+","+nmea+")"); NMEALogger(InputHandler, nmea); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-04-02 08:08:05
|
Revision: 2680 http://roadmap.svn.sourceforge.net/roadmap/?rev=2680&view=rev Author: dannybackx Date: 2011-04-02 08:07:59 +0000 (Sat, 02 Apr 2011) Log Message: ----------- Add documentation, no functional change. Modified Paths: -------------- trunk/roadmap/src/roadmap_track.c Modified: trunk/roadmap/src/roadmap_track.c =================================================================== --- trunk/roadmap/src/roadmap_track.c 2011-03-31 15:51:09 UTC (rev 2679) +++ trunk/roadmap/src/roadmap_track.c 2011-04-02 08:07:59 UTC (rev 2680) @@ -25,6 +25,8 @@ * @file * @brief roadmap_track.c - Keep track of where we've been. * + * Note speed is in centimeters per second. + * * The trackpoints are stored in a list, like all other * waypoints. We save the list to the "currenttrack" file on * exit, and read an initial list from it on startup. @@ -89,8 +91,8 @@ FILE *RoadMapTrackRecentCSV; /** - * @brief - * @param w + * @brief add a waypoint to the temp file + * @param w pointer to a waypoint */ void roadmap_track_add_recent (waypoint *w) { @@ -110,9 +112,9 @@ } /** - * @brief - * @param path - * @param name + * @brief Read the temp file, move its contents into the normal track file + * @param path Directory holding both files + * @param name Name of the normal track file */ void roadmap_track_fetch_recent(const char *path, char *name) { @@ -149,7 +151,11 @@ } } - +/** + * @brief Use the info from the parameters to add a track point if appropriate according to config + * @param gps_time the current time + * @param gps_position the current position + */ static void roadmap_track_add_trackpoint ( int gps_time, const RoadMapGpsPosition *gps_position) { @@ -195,6 +201,10 @@ } +/** + * @brief look up the current track policy from the configuration database + * @return the track policy + */ static RoadMapTrackPolicy roadmap_track_policy(void) { const char *policy = roadmap_config_get (&RoadMapConfigPolicyString); @@ -382,6 +392,10 @@ return 0; } +/** + * @brief get the filename to save track into + * @return the filename + */ static const char *roadmap_track_filename(int *defaulted) { const char *name; name = roadmap_config_get (&RoadMapConfigTrackName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-31 15:51:15
|
Revision: 2679 http://roadmap.svn.sourceforge.net/roadmap/?rev=2679&view=rev Author: dannybackx Date: 2011-03-31 15:51:09 +0000 (Thu, 31 Mar 2011) Log Message: ----------- Must have had an editing accident. Modified Paths: -------------- trunk/roadmap/src/android/roadmap_canvas.c Modified: trunk/roadmap/src/android/roadmap_canvas.c =================================================================== --- trunk/roadmap/src/android/roadmap_canvas.c 2011-03-30 18:36:05 UTC (rev 2678) +++ trunk/roadmap/src/android/roadmap_canvas.c 2011-03-31 15:51:09 UTC (rev 2679) @@ -232,6 +232,7 @@ jstring js; jclass cls = TheClass(); jmethodID mid = TheMethod(cls, "SetForeground", "(Ljava/lang/String;)I"); + int r; // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "set_foreground(%d,%s) - %s", (int)CurrentPen, PenName[(int)CurrentPen].name, color); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-30 18:36:11
|
Revision: 2678 http://roadmap.svn.sourceforge.net/roadmap/?rev=2678&view=rev Author: dannybackx Date: 2011-03-30 18:36:05 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Comment edited Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_text.c Modified: trunk/roadmap/src/buildmap_osm_text.c =================================================================== --- trunk/roadmap/src/buildmap_osm_text.c 2011-03-30 18:33:08 UTC (rev 2677) +++ trunk/roadmap/src/buildmap_osm_text.c 2011-03-30 18:36:05 UTC (rev 2678) @@ -495,8 +495,7 @@ return 0; } -/**< @brief count polygon lines early */ -static int EarlyPolygonCount = 0; +static int EarlyPolygonCount = 0; /**< @brief count polygon lines early */ static int EarlyPolygonNodeCounter = 0; static void This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-30 18:33:15
|
Revision: 2677 http://roadmap.svn.sourceforge.net/roadmap/?rev=2677&view=rev Author: dannybackx Date: 2011-03-30 18:33:08 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Make the dialogs on Android work better. Add support for retrieving GPS info over socket connections (Android devices that listen to e.g. gpsd over the network). Modified Paths: -------------- trunk/roadmap/src/android/roadmap_androidgps.c trunk/roadmap/src/android/roadmap_dialog.c trunk/roadmap/src/android/roadmap_main.c Modified: trunk/roadmap/src/android/roadmap_androidgps.c =================================================================== --- trunk/roadmap/src/android/roadmap_androidgps.c 2011-03-30 18:29:36 UTC (rev 2676) +++ trunk/roadmap/src/android/roadmap_androidgps.c 2011-03-30 18:33:08 UTC (rev 2677) @@ -79,6 +79,7 @@ dilutionListener = dilution; } +#if 0 /** * @brief On Android, we don't need this function : no need to decode ASCII streams * from the GPS device in RoadMap. Android already does that for us. @@ -86,7 +87,6 @@ * @param decoder_context * @param sentence */ -#if 0 int roadmap_androidgps_decode (void *user_context, void *decoder_context, char *sentence) { __android_log_print (ANDROID_LOG_ERROR, "RoadMap", "roadmap_androidgps_decode()"); Modified: trunk/roadmap/src/android/roadmap_dialog.c =================================================================== --- trunk/roadmap/src/android/roadmap_dialog.c 2011-03-30 18:29:36 UTC (rev 2676) +++ trunk/roadmap/src/android/roadmap_dialog.c 2011-03-30 18:33:08 UTC (rev 2677) @@ -171,6 +171,7 @@ child = (RoadMapDialogItem) malloc (sizeof (*child)); roadmap_check_allocated(child); + roadmap_log (ROADMAP_WARNING, "roadmap_dialog_get(%s) -> new %p, parent %p (%s)", name, child, parent, parent ? parent->name : ""); child->typeid = "RoadMapDialogItem"; @@ -216,12 +217,13 @@ /** * @brief lookup by number, don't create a new one if not found + * Note this searches recursively, unlike its sister function(s). * @param parent look in the hierarchy under this * @param id look for this dialog * @return the dialog pointer */ static RoadMapDialogItem roadmap_dialog_get_nr (RoadMapDialogItem parent, const int id) { -// __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr(%d)", id); + // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr(%d)", id); RoadMapDialogItem child; if (parent == NULL) { @@ -230,15 +232,37 @@ child = parent->children; } + /* breadth-first lookup */ while (child != NULL) { if (child->w == id) { -// __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr -> %p", child); + // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr -> %p", child); return child; } -// __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr found %d", child->w); + // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr found %d", child->w); child = child->next; } + /* lookup in depth now */ + if (parent == NULL) { + child = RoadMapDialogWindows; + } else { + child = parent->children; + } + while (child != NULL) { + if (child->children != NULL) { + // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr -> %p", child); + RoadMapDialogItem p = child->children; + while (p) { + RoadMapDialogItem r = roadmap_dialog_get_nr(p, id); + if (r) + return r; + p = p->next; + } + } + // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_get_nr found %d", child->w); + child = child->next; + } + return NULL; } @@ -372,22 +396,15 @@ jstring js = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, name); RoadMapDialogItem parent, child; -#if 0 + child = roadmap_dialog_new_item (frame, name); - int w = (*RoadMapJniEnv)->CallIntMethod(RoadMapJniEnv, RoadMapThiz, mid, child->w, js); - /* Return value is the index of the text field in the container widget */ - child->w = w; -#else - child = roadmap_dialog_new_item (frame, name); parent = roadmap_dialog_get (RoadMapDialogCurrent, frame); child = roadmap_dialog_get (parent, name); int w = (*RoadMapJniEnv)->CallIntMethod(RoadMapJniEnv, RoadMapThiz, mid, parent->w, js); /* Return value is the index of the text field in the container widget */ child->w = w; -#endif child->widget_type = ROADMAP_WIDGET_ENTRY; -// roadmap_log(ROADMAP_WARNING, "roadmap_dialog_new_entry(%s,%s) child->w %d w %d", frame, name, child->w, w); } /** @@ -431,16 +448,27 @@ #endif } +/* + * This used to be a local variable in roadmap_dialog_show_list but then roadmap_dialog_chosen + * can't use it, and the Android NDK/SDK pair aren't good at passing this type of info along. + */ +RoadMapDialogSelection *choice; + /** * @brief Add one choice item (a selection box or menu). * The optional callback is called each time a new selection is being made, * not when the OK button is called--that is the job of the OK button callback. + * + * Note there's a rather strange difference in types between values (as passed here as a parameter) + * and the thing we need inside the function. Casting this via the "vals" local variable is + * copied from the gtk2 implementation because it works. + * * @param frame * @param name * @param count - * @param current + * @param current specifies the initial value to be shown in the UI * @param labels - * @param values + * @param values note strange type, probably requires FIX ME in all platform dependent sources * @param callback */ void roadmap_dialog_new_choice (const char *frame, @@ -450,7 +478,47 @@ char **labels, void *values, RoadMapDialogCallback callback) { -// __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_dialog_new_choice(%s,%s) -> count %d", frame, name, count); + + jclass cls = TheRoadMapClass(); + jmethodID mid = TheMethod(cls, "DialogCreateDropDown", "(ILjava/lang/String;[Ljava/lang/String;)I"); + jstring js = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, name); + jobjectArray joa; + int i; + RoadMapDialogItem parent, child; + char **vals = (char **)values; + + // roadmap_log (ROADMAP_WARNING, "roadmap_dialog_new_choice(%s,%s,%d,%d)", frame, name, count, current); + + child = roadmap_dialog_new_item (frame, name); + parent = roadmap_dialog_get (RoadMapDialogCurrent, frame); + child = roadmap_dialog_get (parent, name); + + choice = (RoadMapDialogSelection *) calloc (count, sizeof(*choice)); + roadmap_check_allocated(choice); + + /* + * Create list + */ + joa = (*RoadMapJniEnv)->NewObjectArray(RoadMapJniEnv, count, cls, NULL); + + for (i = 0; i < count; ++i) { + choice[i].typeid = "RoadMapDialogSelection"; + choice[i].item = child; + choice[i].callback = callback; + choice[i].value = vals[i]; + + js = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, labels[i]); + (*RoadMapJniEnv)->SetObjectArrayElement(RoadMapJniEnv, joa, i, js); + } + child->choice = choice; + child->value = choice[0].value; + /** End list creation */ + + /* Return value is the index of the text field in the container widget */ + child->w = (*RoadMapJniEnv)->CallIntMethod(RoadMapJniEnv, RoadMapThiz, mid, parent->w, js, joa); + child->widget_type = ROADMAP_WIDGET_CHOICE; + + // roadmap_log (ROADMAP_WARNING, "roadmap_dialog_new_choice(%s,%s,%d,%d) -> w %d, child %p, choice %p", frame, name, count, current, child->w, child, choice); } /** @@ -478,18 +546,32 @@ } -/* - * This used to be a local variable in roadmap_dialog_show_list but then roadmap_dialog_chosen - * can't use it, and the Android NDK/SDK pair aren't good at passing this type of info along. +/** + * @brief Find the "choice" for more than one case (list, drop down menu). + * @param id the dialog wiget + * @return choice */ -RoadMapDialogSelection *choice; +static RoadMapDialogSelection *GetChoice(int id) +{ + RoadMapDialogItem dlgp = roadmap_dialog_get_nr(NULL, id); + return dlgp->choice; +} -void roadmap_dialog_chosen (int position, long id) { +void roadmap_dialog_chosen (int dlg, int position, long id) { + // RoadMapDialogSelection *selection = &choice[position]; + + RoadMapDialogSelection *choice = GetChoice(dlg); RoadMapDialogSelection *selection = &choice[position]; + roadmap_log (ROADMAP_WARNING, "roadmap_dialog_chosen --> value old %s new %s, callback %p", selection->item->value, selection->value, selection->callback); + if (selection != NULL) { + RoadMapDialogItem item = selection->item; + if (item->w == 0) + return; + selection->item->value = selection->value; if (selection->callback != NULL) { @@ -506,9 +588,10 @@ } } -void Java_net_sourceforge_projects_roadmap_RoadMap_RoadMapDialogChosen(JNIEnv* env, jobject thiz, int position, long id) +void Java_net_sourceforge_projects_roadmap_RoadMap_RoadMapDialogChosen(JNIEnv* env, jobject thiz, int dlg, int position, long id) { - roadmap_dialog_chosen(position, id); + roadmap_log(ROADMAP_WARNING, "RoadMapDialogChosen(%d,%d,%d)", dlg, position, id); + roadmap_dialog_chosen(dlg, position, id); } /** @@ -691,7 +774,7 @@ if (this_item->widget_type == ROADMAP_WIDGET_ENTRY) { if (RoadMapDialogCurrent->w == 0 && this_item->w == 0) { - roadmap_log(ROADMAP_WARNING, "roadmap_dialog_get_data(%s,%s) null", frame, name); + // roadmap_log(ROADMAP_WARNING, "roadmap_dialog_get_data(%s,%s) null", frame, name); return NULL; } @@ -705,7 +788,7 @@ this_item->value = ReturnStringDataHack; } - roadmap_log(ROADMAP_WARNING, "roadmap_dialog_get_data(%s,%s) -> {%p,%s}", frame, name, this_item->value, this_item->value); + // roadmap_log(ROADMAP_WARNING, "roadmap_dialog_get_data(%s,%s) -> {%p,%s}", frame, name, this_item->value, this_item->value); return (void *)this_item->value; } @@ -722,6 +805,9 @@ * * In other cases, we just pass pointers along from memory, and we're not sure about the data * type (they're sometimes pointers to structures). + * + * Note that some initialisation happens in roadmap_dialog_new_choice, through the "current" + * parameter. */ void roadmap_dialog_set_data (const char *frame, const char *name, const void *data) { @@ -730,7 +816,7 @@ this_frame = roadmap_dialog_get (RoadMapDialogCurrent, frame); this_item = roadmap_dialog_get (this_frame, name); - // roadmap_log(ROADMAP_WARNING, "roadmap_dialog_set_data(%s,%s) cur %d fr %d it %d", frame, name, RoadMapDialogCurrent->w, this_frame->w, this_item->w); + roadmap_log(ROADMAP_WARNING, "roadmap_dialog_set_data(%s,%s) cur %d fr %d it %d", frame, name, RoadMapDialogCurrent->w, this_frame->w, this_item->w); switch (this_item->widget_type) { Modified: trunk/roadmap/src/android/roadmap_main.c =================================================================== --- trunk/roadmap/src/android/roadmap_main.c 2011-03-30 18:29:36 UTC (rev 2676) +++ trunk/roadmap/src/android/roadmap_main.c 2011-03-30 18:33:08 UTC (rev 2677) @@ -50,6 +50,8 @@ #include <android/log.h> #include "roadmap_jni.h" +#include <sys/select.h> + struct roadmap_main_io { int id; RoadMapIO io; @@ -376,9 +378,11 @@ /** * @brief Organize a system dependent way to handle input from this source, * and call the callback when something happens on it. - * On Android, just make a registry in the table. - * The only call we're currently getting is from the GPS, handled in Java code. * + * For the builtin Android Location services, just make a call to Java to start listening. + * For other (socket based) location feeds (RoadMap stuff), set up stuff to listen on the + * sockets created, and call the right callbacks for it. + * * @param io description of the input * @param callback call this function when awakened */ @@ -387,16 +391,25 @@ int i; for (i = 0; i < ROADMAP_MAX_IO; ++i) { + // roadmap_log (ROADMAP_WARNING, "roadmap_main_set_input(%d,%d)", i, RoadMapMainIo[i].io.subsystem); if (RoadMapMainIo[i].io.subsystem == ROADMAP_IO_INVALID) { RoadMapMainIo[i].io = *io; RoadMapMainIo[i].callback = callback; RoadMapMainIo[i].id = 0; - jclass cls = TheRoadMapClass(); - jmethodID mid = TheMethod(cls, "MainSetInput", "(I)V"); + if (RoadMapMainIo[i].io.subsystem == ROADMAP_IO_MEMORY) { + /* and we're on Android */ + jclass cls = TheRoadMapClass(); + jmethodID mid = TheMethod(cls, "MainSetInputAndroid", "(I)V"); - (*RoadMapJniEnv)->CallVoidMethod(RoadMapJniEnv, RoadMapThiz, mid, i); + (*RoadMapJniEnv)->CallVoidMethod(RoadMapJniEnv, RoadMapThiz, mid, i); + } else { + jclass cls = TheRoadMapClass(); + jmethodID mid = TheMethod(cls, "MainSetInput", "(I)V"); + (*RoadMapJniEnv)->CallVoidMethod(RoadMapJniEnv, RoadMapThiz, mid, i); + } + return; } } @@ -406,6 +419,53 @@ } /** + * @brief Handler called from a separate thread to monitor socket I/O + * This function figures out each time again which sockets to listen to. + * The infinite loop around this is in Java so it can get interrupted nicely from there. + * The callback is called from there so it happens from the right thread (via socketHandler). + * @param env the JNI environment + * @param thiz the JNI object + */ +int +Java_net_sourceforge_projects_roadmap_RoadMap_MonitorSocketIO(JNIEnv* env, jobject thiz) +{ + int i, r; + fd_set fds; + + // roadmap_log(ROADMAP_WARNING, "MonitorSocketIO enter"); + /* Figure out which FDs to listen to */ + FD_ZERO(&fds); + + for (i = 0; i < ROADMAP_MAX_IO; ++i) { + if (RoadMapMainIo[i].io.subsystem != ROADMAP_IO_INVALID + && RoadMapMainIo[i].io.subsystem != ROADMAP_IO_MEMORY) { + FD_SET(RoadMapMainIo[i].io.os.file, &fds); + } + } + + r = select(FD_SETSIZE, &fds, NULL, NULL, NULL); + if (r > 0) + for (i=0; i < ROADMAP_MAX_IO; i++) + if (FD_ISSET(RoadMapMainIo[i].io.os.file, &fds)) { + // roadmap_log(ROADMAP_WARNING, "MonitorSocketIO return %d", i); + return i; + } + // roadmap_log(ROADMAP_WARNING, "MonitorSocketIO return -1"); + return -1; +} + +/** + * @brief Call the callback passed to us from RoadMap's C functions to handle data on the socket. + * @param env the JNI environment + * @param thiz the JNI object + */ +void +Java_net_sourceforge_projects_roadmap_RoadMap_HandleSocketIO(JNIEnv* env, jobject thiz, int ix) +{ + (RoadMapMainIo[ix].callback) (&RoadMapMainIo[ix].io); +} + +/** * @brief Remove an input handler * @param io description of this input handler */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-30 18:29:42
|
Revision: 2676 http://roadmap.svn.sourceforge.net/roadmap/?rev=2676&view=rev Author: dannybackx Date: 2011-03-30 18:29:36 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Add debugging function (#iffed away) for posterity Modified Paths: -------------- trunk/roadmap/src/android/roadmap_canvas.c Modified: trunk/roadmap/src/android/roadmap_canvas.c =================================================================== --- trunk/roadmap/src/android/roadmap_canvas.c 2011-03-30 18:22:16 UTC (rev 2675) +++ trunk/roadmap/src/android/roadmap_canvas.c 2011-03-30 18:29:36 UTC (rev 2676) @@ -232,7 +232,6 @@ jstring js; jclass cls = TheClass(); jmethodID mid = TheMethod(cls, "SetForeground", "(Ljava/lang/String;)I"); - int r; // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "set_foreground(%d,%s) - %s", (int)CurrentPen, PenName[(int)CurrentPen].name, color); @@ -724,3 +723,13 @@ } return NULL; } + +#if 0 +const char *roadmap_canvas_pen_name (RoadMapPen pen) +{ + int i = (int)pen; + if (i < 0 || i >= nPens) + return "(null pen)"; + return PenName[i].name; +} +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-30 18:22:22
|
Revision: 2675 http://roadmap.svn.sourceforge.net/roadmap/?rev=2675&view=rev Author: dannybackx Date: 2011-03-30 18:22:16 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Add doxygen stubs Modified Paths: -------------- trunk/roadmap/src/roadmap_gpx.c trunk/roadmap/src/roadmap_trip.c Modified: trunk/roadmap/src/roadmap_gpx.c =================================================================== --- trunk/roadmap/src/roadmap_gpx.c 2011-03-30 18:03:15 UTC (rev 2674) +++ trunk/roadmap/src/roadmap_gpx.c 2011-03-30 18:22:16 UTC (rev 2675) @@ -55,6 +55,16 @@ #ifdef ROADMAP_USES_EXPAT +/** + * @brief + * @param path + * @param name + * @param w + * @param wee + * @param r + * @param t + * @return + */ int roadmap_gpx_read_file(const char *path, const char *name, queue_head *w, int wee, queue_head *r, queue_head *t) @@ -81,7 +91,14 @@ return ret; } -/* read a list of waypoints (or optionally, weepoints) from a file */ +/** + * @brief read a list of waypoints (or optionally, weepoints) from a file + * @param path + * @param name + * @param waypoints + * @param wee + * @return + */ int roadmap_gpx_read_waypoints (const char *path, const char *name, queue_head *waypoints, int wee) @@ -94,6 +111,13 @@ } +/** + * @brief + * @param path + * @param name + * @param track + * @return + */ int roadmap_gpx_read_one_track( const char *path, const char *name, route_head **track) @@ -125,6 +149,13 @@ } +/** + * @brief + * @param path + * @param name + * @param route + * @return + */ int roadmap_gpx_read_one_route( const char *path, const char *name, route_head **route) @@ -153,6 +184,16 @@ return ret; } +/** + * @brief + * @param backup + * @param path + * @param name + * @param w + * @param r + * @param t + * @return + */ int roadmap_gpx_write_file(int backup, const char *path, const char *name, queue_head *w, queue_head *r, queue_head *t) @@ -176,7 +217,14 @@ return ret; } -/* write a file of waypoints. weepoints cannot be written */ +/** + * @brief write a file of waypoints. weepoints cannot be written + * @param backup + * @param path + * @param name + * @param waypoints + * @return + */ int roadmap_gpx_write_waypoints(int backup, const char *path, const char *name, queue_head *waypoints) { @@ -196,6 +244,14 @@ return ret; } +/** + * @brief + * @param backup + * @param path + * @param name + * @param route + * @return + */ int roadmap_gpx_write_route(int backup, const char *path, const char *name, route_head *route) { @@ -221,6 +277,14 @@ return ret; } +/** + * @brief + * @param backup + * @param path + * @param name + * @param track + * @return + */ int roadmap_gpx_write_track(int backup, const char *path, const char *name, route_head *track) { @@ -246,7 +310,9 @@ #else // ROADMAP_USES_EXPAT - +/** + * @brief + */ static void roadmap_gpx_tell_no_expat (void) { static int roadmap_gpx_told_no_expat = 0; Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2011-03-30 18:03:15 UTC (rev 2674) +++ trunk/roadmap/src/roadmap_trip.c 2011-03-30 18:22:16 UTC (rev 2675) @@ -2684,6 +2684,7 @@ /** * @brief create a file selection dialog + * @param title * @param mode */ static void roadmap_trip_file_dialog (const char *title, const char *mode) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-30 18:03:21
|
Revision: 2674 http://roadmap.svn.sourceforge.net/roadmap/?rev=2674&view=rev Author: dannybackx Date: 2011-03-30 18:03:15 +0000 (Wed, 30 Mar 2011) Log Message: ----------- No functional change, just comments added. Modified Paths: -------------- trunk/roadmap/src/roadmap_voice.c Modified: trunk/roadmap/src/roadmap_voice.c =================================================================== --- trunk/roadmap/src/roadmap_voice.c 2011-03-30 18:02:11 UTC (rev 2673) +++ trunk/roadmap/src/roadmap_voice.c 2011-03-30 18:03:15 UTC (rev 2674) @@ -1,5 +1,4 @@ -/* roadmap_voice.c - Manage voice announcements. - * +/* * LICENSE: * * Copyright 2002 Pascal F. Martin @@ -19,10 +18,15 @@ * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/** + * @file + * @brief Manage voice announcements for RoadMap + * This module starts a separate process for converting text into speech. * - * SYNOPSYS: - * - * See roadmap_voice.h. + * Not to be confused with the sound from the navigate plugin which just plays + * preprocessed sounds that happen to be texts. */ #include <stdio.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-30 18:02:17
|
Revision: 2673 http://roadmap.svn.sourceforge.net/roadmap/?rev=2673&view=rev Author: dannybackx Date: 2011-03-30 18:02:11 +0000 (Wed, 30 Mar 2011) Log Message: ----------- Change the way Android attaches to the GPS device from hardwired to the Android system to RoadMap's normal configuration. So from now GPS.Source: android: is needed. Modified Paths: -------------- trunk/roadmap/src/roadmap_gps.c Modified: trunk/roadmap/src/roadmap_gps.c =================================================================== --- trunk/roadmap/src/roadmap_gps.c 2011-03-30 17:58:16 UTC (rev 2672) +++ trunk/roadmap/src/roadmap_gps.c 2011-03-30 18:02:11 UTC (rev 2673) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin - * Copyright 2010 Danny Backx + * Copyright (c) 2010, 2011, Danny Backx * * This file is part of RoadMap. * @@ -883,7 +883,6 @@ RoadMapGpsLatestData = 0; roadmap_gps_update_reception (); -#ifndef ANDROID url = roadmap_gps_source (); if (url == NULL) { @@ -1056,6 +1055,9 @@ RoadMapGpsLink.subsystem = ROADMAP_IO_FILE; } + } else if (strncasecmp (url, "android:", 8) == 0) { + RoadMapGpsLink.subsystem = ROADMAP_IO_MEMORY; + RoadMapGpsProtocol = ROADMAP_GPS_ANDROID; } else { roadmap_log (ROADMAP_ERROR, "invalid protocol in url %s", url); return; @@ -1074,10 +1076,6 @@ (*RoadMapGpsPeriodicRemove) (roadmap_gps_open); RoadMapGpsRetryPending = 0; } -#else /* ANDROID */ - RoadMapGpsLink.subsystem = ROADMAP_IO_MEMORY; - RoadMapGpsProtocol = ROADMAP_GPS_ANDROID; -#endif /* Give time for the whole system to initialize itself. */ roadmap_gps_got_data(); @@ -1246,9 +1244,9 @@ roadmap_io_close (&context); /* Try to establish a new IO channel, but don't reread a file: */ -#ifndef ANDROID - (*RoadMapGpsPeriodicRemove) (roadmap_gps_keep_alive); -#endif + if (RoadMapGpsProtocol != ROADMAP_GPS_ANDROID) + (*RoadMapGpsPeriodicRemove) (roadmap_gps_keep_alive); + if (RoadMapGpsLink.subsystem != ROADMAP_IO_FILE) { roadmap_gps_open(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-30 17:58:22
|
Revision: 2672 http://roadmap.svn.sourceforge.net/roadmap/?rev=2672&view=rev Author: dannybackx Date: 2011-03-30 17:58:16 +0000 (Wed, 30 Mar 2011) Log Message: ----------- No functional change, just add some documentation/comments. Modified Paths: -------------- trunk/roadmap/src/roadmap_track.c Modified: trunk/roadmap/src/roadmap_track.c =================================================================== --- trunk/roadmap/src/roadmap_track.c 2011-03-27 15:51:14 UTC (rev 2671) +++ trunk/roadmap/src/roadmap_track.c 2011-03-30 17:58:16 UTC (rev 2672) @@ -1,5 +1,4 @@ -/* roadmap_track.c - Keep track of where we've been. - * +/* * LICENSE: * * Copyright 2005 Paul G. Fox @@ -22,7 +21,10 @@ */ -/* +/** + * @file + * @brief roadmap_track.c - Keep track of where we've been. + * * The trackpoints are stored in a list, like all other * waypoints. We save the list to the "currenttrack" file on * exit, and read an initial list from it on startup. @@ -86,6 +88,10 @@ FILE *RoadMapTrackRecentCSV; +/** + * @brief + * @param w + */ void roadmap_track_add_recent (waypoint *w) { if (!RoadMapTrackRecentCSV) { @@ -103,6 +109,11 @@ fflush(RoadMapTrackRecentCSV); } +/** + * @brief + * @param path + * @param name + */ void roadmap_track_fetch_recent(const char *path, char *name) { char trkpoint[128]; @@ -214,7 +225,13 @@ } - +/** + * @brief receive GPS updates in the roadmap_track module + * @param reception indication of reception quality + * @param gps_time timestamp of this update + * @param dilution + * @param gps_position the position + */ static void roadmap_track_gps_update (int reception, int gps_time, const RoadMapGpsPrecision *dilution, const RoadMapGpsPosition *gps_position) { @@ -307,7 +324,10 @@ } - +/** + * @brief draw this waypoint as part of the current track + * @param waypointp pointer to the waypoint + */ static void roadmap_track_waypoint_draw (const waypoint *waypointp) { RoadMapGuiPoint guipoint; @@ -328,7 +348,9 @@ } - +/** + * @brief display the current track + */ void roadmap_track_display (void) { if (RoadMapTrackDisplay) { @@ -337,6 +359,9 @@ } +/** + * @brief + */ void roadmap_track_toggle_display(void) { RoadMapTrackDisplay = ! RoadMapTrackDisplay; @@ -345,6 +370,9 @@ } +/** + * @brief + */ int roadmap_track_is_refresh_needed (void) { if (RoadMapTrackRefresh) { @@ -395,6 +423,9 @@ return ret; } +/** + * @brief + */ void roadmap_track_save(void) { if (RoadMapTrack == NULL || @@ -406,6 +437,11 @@ RoadMapTrackModified = 0; } +/** + * @brief autosave the track, and clean up the CSV file + * @param hiwater + * @param lowater + */ static void roadmap_track_autosave(int hiwater, int lowater) { const char *name; @@ -465,6 +501,9 @@ } +/** + * @brief + */ void roadmap_track_reset (void) { RoadMapTrackModified = 1; /* otherwise autosave does nothing */ @@ -473,13 +512,14 @@ roadmap_screen_refresh(); } - - +/** + * @brief + */ void roadmap_track_autowrite(void) { int nominal; - /* essentially, if we aquire 25% more points than we've been + /* essentially, if we acquire 25% more points than we've been * asked to save, we tell the autowriter to archive all but * that 75% of what we've been asked for, and continue from * there. @@ -489,6 +529,9 @@ } +/** + * @brief + */ void roadmap_track_autoload(void) { const char *name; @@ -518,6 +561,9 @@ } +/** + * @brief initialize roadmap_track + */ void roadmap_track_initialize(void) { @@ -551,6 +597,9 @@ roadmap_gps_register_listener(roadmap_track_gps_update); } +/** + * @brief activate roadmap_track + */ void roadmap_track_activate(void) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-27 15:51:21
|
Revision: 2671 http://roadmap.svn.sourceforge.net/roadmap/?rev=2671&view=rev Author: dannybackx Date: 2011-03-27 15:51:14 +0000 (Sun, 27 Mar 2011) Log Message: ----------- Add stuff to the build (Makefile,AndroidManifest.xml) to be able to use libgps. Add calls to the OpenIntents file manager if it's available. Modified Paths: -------------- trunk/roadmap/src/android/AndroidManifest.xml trunk/roadmap/src/android/Makefile trunk/roadmap/src/android/roadmap_fileselection.c Modified: trunk/roadmap/src/android/AndroidManifest.xml =================================================================== --- trunk/roadmap/src/android/AndroidManifest.xml 2011-03-24 17:25:44 UTC (rev 2670) +++ trunk/roadmap/src/android/AndroidManifest.xml 2011-03-27 15:51:14 UTC (rev 2671) @@ -6,8 +6,19 @@ android:theme="@style/RoadMapStyle" android:versionName="1.0"> <uses-sdk android:minSdkVersion="3" /> + /* + * Obviously we'd like permission to use the GPS + */ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> + /* + * RoadMap will try to keep the screen on. + */ <uses-permission android:name="android.permission.WAKE_LOCK"/> + /* + * Only require internet access if we're using e.g. gpsd3://.... for + * feeding us location info. + */ + <uses-permission android:name="android.permission.INTERNET"/> <application android:label="@string/app_name" android:debuggable="true" Modified: trunk/roadmap/src/android/Makefile =================================================================== --- trunk/roadmap/src/android/Makefile 2011-03-24 17:25:44 UTC (rev 2670) +++ trunk/roadmap/src/android/Makefile 2011-03-27 15:51:14 UTC (rev 2671) @@ -109,21 +109,18 @@ -mkdir -p gen ${AAPT} package -m -J gen -M AndroidManifest.xml -S res -I ${SDKPLAT}/android.jar +org/openintents/intents/FileManagerIntents.class: src/org/openintents/intents/FileManagerIntents.java + javac ${JAVAC_FLAGS} -d . src/org/openintents/intents/FileManagerIntents.java + ${DIRHIER}/RoadMap.class: src/${DIRHIER}/RoadMap.java gen/net/sourceforge/projects/roadmap/R.java javac ${JAVAC_FLAGS} -d . src/${DIRHIER}/RoadMap.java -${DIRHIER}/RoadMapCanvas.class: src/${DIRHIER}/RoadMapCanvas.java - javac ${JAVAC_FLAGS} -d . src/${DIRHIER}/RoadMapCanvas.java - ${DIRHIER}/Panel.class: src/${DIRHIER}/Panel.java javac ${JAVAC_FLAGS} -d . src/${DIRHIER}/Panel.java ${DIRHIER}/Pen.class: src/${DIRHIER}/Pen.java javac ${JAVAC_FLAGS} -d . src/${DIRHIER}/Pen.java -${DIRHIER}/TutorialThread.class: src/${DIRHIER}/TutorialThread.java - javac ${JAVAC_FLAGS} -d . src/${DIRHIER}/TutorialThread.java - RMLIBS= ../libguiroadmap.a ../libroadmap.a ../gpx/libgpx.a ../unix/libosroadmap.a \ -L/opt/android/lib -lexpat-1 RMDLIBS= ../libguiroadmap.a ../libroadmap.a ../gpx/libgpx.a ../unix/libosroadmap.a @@ -148,13 +145,14 @@ RMANDROID= ${RMASRC:.c=.o} -libs/armeabi/librmnative.so: ${RMANDROID} ${RMDLIBS} +libs/armeabi/librmnative.so: ${RMANDROID} ${RMDLIBS} /opt/android/lib/libgps.a -mkdir -p libs/armeabi arm-eabi-gcc --Wl,-soname,librmnative.so -o libs/armeabi/librmnative.so \ ${NDK_CFLAGS} ${NDK_LDFLAGS} \ ${RMANDROID} \ ${RMLIBS} \ -lgcc \ + -L/opt/android/lib -lgps \ -L${NDKHOME}/platforms/android-${NDK_LEVEL}/arch-${NDK_ARCH}/usr/lib -llog -lc -lm clean: Modified: trunk/roadmap/src/android/roadmap_fileselection.c =================================================================== --- trunk/roadmap/src/android/roadmap_fileselection.c 2011-03-24 17:25:44 UTC (rev 2670) +++ trunk/roadmap/src/android/roadmap_fileselection.c 2011-03-27 15:51:14 UTC (rev 2671) @@ -71,37 +71,37 @@ /* * JNI */ -#define MYCLS2 "net/sourceforge/projects/roadmap/RoadMap" -static jclass myRmClassCache = (jclass) 0; +#define MYCLS2 "net/sourceforge/projects/roadmap/RoadMap" +static jclass myRmClassCache = (jclass) 0; static jclass TheRoadMapClass() { - if (myRmClassCache == 0) { - myRmClassCache = (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, MYCLS2); - myRmClassCache = (*RoadMapJniEnv)->NewGlobalRef(RoadMapJniEnv, myRmClassCache); - } - if (myRmClassCache == 0) { - __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "Class not found"); - // throw - (*RoadMapJniEnv)->ThrowNew(RoadMapJniEnv, - (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, "java/io/IOException"), - "A JNI Exception occurred"); - } + if (myRmClassCache == 0) { + myRmClassCache = (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, MYCLS2); + myRmClassCache = (*RoadMapJniEnv)->NewGlobalRef(RoadMapJniEnv, myRmClassCache); + } + if (myRmClassCache == 0) { + __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "Class not found"); + // throw + (*RoadMapJniEnv)->ThrowNew(RoadMapJniEnv, + (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, "java/io/IOException"), + "A JNI Exception occurred"); + } - return myRmClassCache; + return myRmClassCache; } static jmethodID TheMethod(const jclass cls, const char *name, const char *signature) { - jmethodID mid; + jmethodID mid; - mid = (*RoadMapJniEnv)->GetMethodID(RoadMapJniEnv, cls, name, signature); - if (mid == 0) { - (*RoadMapJniEnv)->ThrowNew(RoadMapJniEnv, - (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, "java/io/IOException"), - "A JNI Exception occurred"); - } - return mid; + mid = (*RoadMapJniEnv)->GetMethodID(RoadMapJniEnv, cls, name, signature); + if (mid == 0) { + (*RoadMapJniEnv)->ThrowNew(RoadMapJniEnv, + (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, "java/io/IOException"), + "A JNI Exception occurred"); + } + return mid; } @@ -123,17 +123,8 @@ return item; } -#if 0 -static void roadmap_fileselection_ok (GtkFileSelection *selector, gpointer user_data) -{ - RoadMapFileSelection *item = (RoadMapFileSelection *)user_data; - - if (item->callback != NULL) { - item->callback (gtk_file_selection_get_filename (GTK_FILE_SELECTION(item->dialog)), - item->mode); - } -} -#endif +RoadMapFileCallback global_cb; +char *global_mode = NULL; /** * @brief open a file selection dialog @@ -148,79 +139,43 @@ const char *path, const char *mode, RoadMapFileCallback callback) { - roadmap_log(ROADMAP_WARNING, "roadmap_fileselection_new(%s,%s,%s,%s)", title, filter, path, mode); + // roadmap_log(ROADMAP_WARNING, "roadmap_fileselection_new(%s,%s,%s,%s)", title, filter, path, mode); - callback("/sdcard/roadmap/yow.gpx", mode); -#if 0 - RoadMapFileSelection *item = roadmap_fileselection_search (title); - - if (item == NULL) { - - char current_directory[PATH_MAX]; - - if (path == NULL) { - - current_directory[0] = 0; - - } else if (getcwd (current_directory, sizeof(current_directory)) == NULL) { - - roadmap_log (ROADMAP_ERROR, "getcwd failed"); - current_directory[0] = 0; - - } else { - - chdir (path); - } - - item = (RoadMapFileSelection *) malloc (sizeof (*item)); - roadmap_check_allocated(item); + global_cb = callback; + if (global_mode) + free(global_mode); + global_mode = strdup(mode); - item->title = strdup(title); - item->dialog = gtk_file_selection_new (item->title); - - g_signal_connect (GTK_FILE_SELECTION(item->dialog)->ok_button, - "clicked", - (GCallback) roadmap_fileselection_ok, - item); - - /* Ensure that the dialog box is hidden when the user clicks a button. */ - - g_signal_connect_swapped (GTK_FILE_SELECTION(item->dialog)->ok_button, - "clicked", - (GCallback) gtk_widget_hide_all, - (gpointer) item->dialog); - g_signal_connect_swapped (GTK_FILE_SELECTION(item->dialog)->cancel_button, - "clicked", - (GCallback) gtk_widget_hide_all, - (gpointer) item->dialog); - - /* Restore the original directory path.. */ - if (current_directory[0] != 0) { - chdir (current_directory); - } - } - - item->mode = mode; - item->callback = callback; - - if (filter != NULL) { - gtk_file_selection_complete (GTK_FILE_SELECTION(item->dialog), filter); - } - - if (item->dialog->window != NULL) { - gdk_window_show (item->dialog->window); - gdk_window_raise (item->dialog->window); - } - gtk_widget_show_all (GTK_WIDGET(item->dialog)); -#endif -} + jclass cls = TheRoadMapClass(); + jmethodID mid = TheMethod(cls, "FileSelection", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)I"); -#if 0 - jclass cls = TheRoadMapClass(); - jmethodID mid = TheMethod(cls, "CreateHeading", "(Ljava/lang/String;I)I"); - jstring js = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, frame); + jstring jst = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, title); + jstring jsf = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, filter); + jstring jsp = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, path); + int r, imode; - (*RoadMapJniEnv)->CallIntMethod(RoadMapJniEnv, RoadMapThiz, mid, js, - parent->w); -#endif + imode = 0; + if (mode) { + if (mode[0] == 'r') imode = 0; + if (mode[0] == 'w') imode = 1; + } + r = (*RoadMapJniEnv)->CallIntMethod(RoadMapJniEnv, RoadMapThiz, mid, jst, jsf, jsp, imode); + + if (r < 0) { /* No suitable method for selecting a file */ + callback("/sdcard/roadmap/logfile.txt", mode); + } +} + +/** + * @brief function to return string data + * @param env JNI standard environment pointer + * @param thiz JNI standard object from which we're being called + * @param js the string we're getting from Java + */ +void Java_net_sourceforge_projects_roadmap_RoadMap_FileSelectionResult(JNIEnv* env, jobject thiz, jstring js) +{ + char *s = (*env)->GetStringUTFChars(env, js, NULL); + (*global_cb)(s, global_mode); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-24 17:25:50
|
Revision: 2670 http://roadmap.svn.sourceforge.net/roadmap/?rev=2670&view=rev Author: dannybackx Date: 2011-03-24 17:25:44 +0000 (Thu, 24 Mar 2011) Log Message: ----------- Add interface definition for OpenIntents file manager. Modified Paths: -------------- trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java Added Paths: ----------- trunk/roadmap/src/android/src/org/ trunk/roadmap/src/android/src/org/openintents/ trunk/roadmap/src/android/src/org/openintents/intents/ trunk/roadmap/src/android/src/org/openintents/intents/FileManagerIntents.java Modified: trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java =================================================================== --- trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java 2011-03-24 16:46:53 UTC (rev 2669) +++ trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java 2011-03-24 17:25:44 UTC (rev 2670) @@ -56,6 +56,7 @@ import android.widget.LinearLayout; import android.widget.RelativeLayout; +import android.widget.Spinner; import android.location.Location; import android.location.LocationListener; @@ -88,6 +89,12 @@ import android.app.ProgressDialog; +import org.openintents.intents.FileManagerIntents; +import android.content.ActivityNotFoundException; +import android.content.Intent; +import android.net.Uri; +import java.io.File; + public class RoadMap extends Activity { private LocationManager mgr = null; @@ -97,6 +104,8 @@ Menu myMenu = null; int InputHandler; + Thread slt = null; /**< Socket listener thread */ + AssetManager asm; PowerManager power; PowerManager.WakeLock wl; @@ -119,8 +128,11 @@ public native void HardExit(int rc); public native void DialogSpecialCallback(int dlg, int btn); public native void ReturnStringDataHack(String s); - public native void RoadMapDialogChosen(int position, long id); + public native void RoadMapDialogChosen(int dlg, int position, long id); public native void NMEALogger(int id, String nmea); + public native void FileSelectionResult(String filename); + public native int MonitorSocketIO(); + public native void HandleSocketIO(int ix); @Override public void onCreate(Bundle state) @@ -191,6 +203,13 @@ } @Override + public void onResume() + { + super.onResume(); + // wl.acquire(); + } + + @Override public void onRestart() { super.onRestart(); @@ -257,17 +276,62 @@ mgr.removeGpsStatusListener(onGpsChange); } - public void MainSetInput(int id) { + public void MainSetInputAndroid(int id) { InputHandler = id; // Log.e("RoadMap", "MainSetInput("+id+")"); try { mgr.addNmeaListener(onNmea); } catch (Exception e) { - Log.e("RoadMap", "MainSetInput exception" + e); + Log.e("RoadMap", "MainSetInputAndroid exception" + e); } } + Handler socketHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + HandleSocketIO(msg.what); + } + }; + + public class SocketListenerThread implements Runnable { + public void run() { + while (true) { + /* + * The value returned by MonitorSocketIO is not a file descriptor + * but an index into a table in android/roadmap_main.c . + */ + int ix = MonitorSocketIO(); + if (slt.isInterrupted()) + return; + if (ix >= 0) { + Message m = socketHandler.obtainMessage(); + m.what = ix; + socketHandler.sendMessage(m); + // HandleSocketIO(ix); + } + + try { + Thread.sleep(1000); + } catch (Exception e) { + }; + } + } + } + + /* + * This needs to set up a thread that listens for signals on a socket, + * and then calls the IO listener (in C) for it. + */ + public void MainSetInput(int id) { + if (slt != null) { + slt.interrupt(); + } + + slt = new Thread(new SocketListenerThread()); + slt.start(); + } + NmeaListener onNmea = new NmeaListener() { public void onNmeaReceived(long ts, String nmea) { // Log.e("RoadMap", "onNmeaReceived("+ts+","+nmea+")"); @@ -285,7 +349,7 @@ public void onProviderEnabled(String provider) { // required for interface, not used } - + public void onStatusChanged(String provider, int status, Bundle extras) { mystatus = status; } @@ -303,7 +367,8 @@ int lat = (int) (location.getLatitude() * 1000000), lon = (int) (location.getLongitude() * 1000000), /* getAltitude() returns m */ - alt = (int) (location.getAltitude() * 1000000), + // alt = (int) (location.getAltitude() * 1000000), + alt = (int) location.getAltitude(), /* getSpeed() returns m/s, this calculation * turns it into knots, see roadmap_gpsd2.c . * Still need to divide by 1000, see below. @@ -386,6 +451,8 @@ public void Finish() { + if (slt != null) + slt.interrupt(); thiz.finish(); } @@ -974,40 +1041,43 @@ /* * Create ListView */ - public void DialogCreateList(int id) + public void DialogCreateList(int dlg) { + final int dlgid = dlg; try { LinearLayout row = new LinearLayout(this); row.setOrientation(LinearLayout.HORIZONTAL); - dialogs[id].ll.addView(row); - dialogs[id].row = row; -// Log.e("RoadMap", "DialogCreateList(" + id + ")"); + dialogs[dlg].ll.addView(row); + dialogs[dlg].row = row; +// Log.e("RoadMap", "DialogCreateList(" + dlg + ")"); ListView lv = new ListView(thiz); -// Log.e("RoadMap", "DialogCreateList(" + id + "), row " + dialogs[id].row); - dialogs[id].row.addView(lv); +// Log.e("RoadMap", "DialogCreateList(" + dlg + "), row " + dialogs[dlg].row); + dialogs[dlg].row.addView(lv); // lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { }); - lv.setOnItemClickListener(listener); + lv.setOnItemClickListener(new OnItemClickListener() { + public void onItemClick(AdapterView <?> parent, View view, + int position, long id) { + Log.e("RoadMap", "OnItemClickListener(" + position + + "," + id + ")"); + RoadMapDialogChosen(dlgid, position, id); + } + }); } catch (Exception e) { - Log.e("RoadMap", "DialogCreateList(" + id + ") : exception " + e); + Log.e("RoadMap", "DialogCreateList(" + dlg + ") : exception " + e); }; } + /* OnItemClickListener listener = new OnItemClickListener() { public void onItemClick(AdapterView <?> parent, View view, int position, long id) { Log.e("RoadMap", "OnItemClickListener(" + position + "," + id + ")"); RoadMapDialogChosen(position, id); } }; + */ - DialogInterface.OnClickListener listener2 = new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - Log.e("RoadMap", "OnClickListener(" + which + ")"); - // RoadMapDialogChosen(position, id); - } - }; - /* * Set a list contents */ @@ -1042,6 +1112,52 @@ } /* + * @brief Create a dropdown menu + * @param id points to the entry in dialogs[] to use + * @param name names this dropdown, CURRENTLY NOT USED, FIX ME + * @param items array of texts to show as items in the dropdown + * @return the index of the text field in the container widget + * + * started as a copy of DialogAddTextEntry + */ + public int DialogCreateDropDown(int id, String name, String[] items) + { + try { + // String [] items = { "this", "is", "a", "silly", "list" }; + // Log.e("RoadMap", "DialogCreateDropDown(" + id + "," + name + "," + items + ")"); + + Spinner spin = new Spinner(thiz); + LinearLayout row = dialogs[id].row; + row.addView(spin); + final int dlg = dialogs[id].ll.indexOfChild(row); + ArrayAdapter<String> aa = new ArrayAdapter<String>(thiz, + android.R.layout.simple_spinner_item, + items); + aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spin.setAdapter(aa); + spin.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { + public void onItemSelected(android.widget.AdapterView av, + View v, int position, long id) { + Spinner s = (Spinner) v.getParent(); + int pos = s.getSelectedItemPosition(); + // int pos = 0; + // Log.e("RoadMap", "Spinner.onItemSelected(" + position + "," + id + "), dlg " + dlg + ", pos " + pos); + RoadMapDialogChosen(dlg, position, id); + } + public void onNothingSelected(android.widget.AdapterView av) { + } + }); + + // Log.e("RoadMap", "DialogCreateDropDown(" + id + "," + name + "," + items + ") -> " + dlg); + return dlg; + + } catch (Exception e) { + Log.e("RoadMap", "DialogCreateDropDown(" + id + "," + name + ") exception " + e); + return -1; + } + } + + /* * Sound */ public int PlaySound(String fn) @@ -1077,4 +1193,60 @@ public void SetProgress(int percent) { } + + /* + * In my opinion, this is lacking from OpenIntents interface definition. + * .. copied from org/openintents/filemanager/demo/Demo.java . + */ + protected static final int REQUEST_CODE_PICK_FILE_OR_DIRECTORY = 1; + protected static final int REQUEST_CODE_GET_CONTENT = 2; + + /* + * Use OpenIntents FileManager if available + * Return -1 if no suitable filemanager + */ + public int FileSelection(String title, String filter, String path, int mode) + { + // Log.e("RoadMap", "FileSelection(" + filter + "," + path + "," + mode + ")"); + + try { + Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE); + + File file = new File(path); + intent.putExtra(FileManagerIntents.EXTRA_TITLE, title); + intent.setData(Uri.fromFile(file)); + + startActivityForResult(intent, REQUEST_CODE_PICK_FILE_OR_DIRECTORY); + } catch (Exception e) { + Toast.makeText(thiz, "File Manager interaction failed", 5000).show(); + return -1; + } + return 0; + } + + /** + * Called after the file manager finishes + */ + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + super.onActivityResult(requestCode, resultCode, data); + + switch (requestCode) { + case 1 /* ACTION_PICK_FILE */: + if (resultCode == RESULT_OK && data != null) { + /* obtain file name */ + Uri fileUri = data.getData(); + if (fileUri != null) { + String filePath = fileUri.getPath(); + + Log.e ("RoadMap", "onActivityResult(" + filePath + ")"); + + if (filePath != null) { + FileSelectionResult(filePath); + return; + } + } + } + } + } } Added: trunk/roadmap/src/android/src/org/openintents/intents/FileManagerIntents.java =================================================================== --- trunk/roadmap/src/android/src/org/openintents/intents/FileManagerIntents.java (rev 0) +++ trunk/roadmap/src/android/src/org/openintents/intents/FileManagerIntents.java 2011-03-24 17:25:44 UTC (rev 2670) @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2008 OpenIntents.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.openintents.intents; + +// Version Dec 9, 2008 + + +/** + * Provides OpenIntents actions, extras, and categories used by providers. + * <p>These specifiers extend the standard Android specifiers.</p> + */ +public final class FileManagerIntents { + + /** + * Activity Action: Pick a file through the file manager, or let user + * specify a custom file name. + * Data is the current file name or file name suggestion. + * Returns a new file name as file URI in data. + * + * <p>Constant Value: "org.openintents.action.PICK_FILE"</p> + */ + public static final String ACTION_PICK_FILE = "org.openintents.action.PICK_FILE"; + + /** + * Activity Action: Pick a directory through the file manager, or let user + * specify a custom file name. + * Data is the current directory name or directory name suggestion. + * Returns a new directory name as file URI in data. + * + * <p>Constant Value: "org.openintents.action.PICK_DIRECTORY"</p> + */ + public static final String ACTION_PICK_DIRECTORY = "org.openintents.action.PICK_DIRECTORY"; + + /** + * The title to display. + * + * <p>This is shown in the title bar of the file manager.</p> + * + * <p>Constant Value: "org.openintents.extra.TITLE"</p> + */ + public static final String EXTRA_TITLE = "org.openintents.extra.TITLE"; + + /** + * The text on the button to display. + * + * <p>Depending on the use, it makes sense to set this to "Open" or "Save".</p> + * + * <p>Constant Value: "org.openintents.extra.BUTTON_TEXT"</p> + */ + public static final String EXTRA_BUTTON_TEXT = "org.openintents.extra.BUTTON_TEXT"; + +} + Property changes on: trunk/roadmap/src/android/src/org/openintents/intents/FileManagerIntents.java ___________________________________________________________________ Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-03-24 16:46:59
|
Revision: 2669 http://roadmap.svn.sourceforge.net/roadmap/?rev=2669&view=rev Author: dannybackx Date: 2011-03-24 16:46:53 +0000 (Thu, 24 Mar 2011) Log Message: ----------- Change the gps_read() call - which was wrong - into gps_unpack(). This function will be documented with the next gpsd release, but it has been available for a long time. Modified Paths: -------------- trunk/roadmap/src/roadmap_gpsd3.c Modified: trunk/roadmap/src/roadmap_gpsd3.c =================================================================== --- trunk/roadmap/src/roadmap_gpsd3.c 2011-02-23 20:50:32 UTC (rev 2668) +++ trunk/roadmap/src/roadmap_gpsd3.c 2011-03-24 16:46:53 UTC (rev 2669) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin - * Copyright 2010, 2011, Danny Backx. + * Copyright (c) 2010, 2011, Danny Backx. * * This file is part of RoadMap. * @@ -107,7 +107,7 @@ static bool used[MAXCHANNELS]; #define MAX_POSSIBLE_SATS (MAXCHANNELS - 2) - if (gps_read(gpsdp) < 0) { + if (gps_unpack(sentence, gpsdp) < 0) { roadmap_log(ROADMAP_ERROR, "gpsd error %d", errno); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-23 20:50:39
|
Revision: 2668 http://roadmap.svn.sourceforge.net/roadmap/?rev=2668&view=rev Author: dannybackx Date: 2011-02-23 20:50:32 +0000 (Wed, 23 Feb 2011) Log Message: ----------- Remove almost meaningless comments. Add a few more cases, also add PARK or AMENITY to a bunch of existing AREAs. (Areas with a NULL next to them make black blobs on the maps, not really useful.) Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_common.c Modified: trunk/roadmap/src/buildmap_osm_common.c =================================================================== --- trunk/roadmap/src/buildmap_osm_common.c 2011-02-23 19:18:36 UTC (rev 2667) +++ trunk/roadmap/src/buildmap_osm_common.c 2011-02-23 20:50:32 UTC (rev 2668) @@ -310,24 +310,24 @@ { "water", LAKE, AREA }, /* 2 */ { "wood", NATURE, AREA }, /* 3 */ { "peak", NULL, 0 }, /* 4 */ - { "land", NULL, AREA }, /* 5 */ /* New - ok ? */ - { "bay", NULL, AREA }, /* 6 */ /* New - ok ? */ - { "beach", NULL, AREA }, /* 7 */ /* New - ok ? */ - { "cave_entrance", NULL, AREA }, /* 8 */ /* New - ok ? */ - { "cliff", NULL, AREA }, /* 9 */ /* New - ok ? */ - { "fell", NULL, AREA }, /* 10 */ /* New - ok ? */ - { "glacier", NULL, AREA }, /* 11 */ /* New - ok ? */ - { "heath", NULL, AREA }, /* 12 */ /* New - ok ? */ - { "marsh", NULL, AREA }, /* 13 */ /* New - ok ? */ - { "mud", NULL, AREA }, /* 14 */ /* New - ok ? */ - { "sand", NULL, AREA }, /* 15 */ /* New - ok ? */ - { "scree", NULL, AREA }, /* 16 */ /* New - ok ? */ - { "scrub", NULL, AREA }, /* 17 */ /* New - ok ? */ - { "sprint", NULL, AREA }, /* 18 */ /* New - ok ? */ - { "stone", NULL, AREA }, /* 19 */ /* New - ok ? */ - { "tree", NULL, AREA }, /* 20 */ /* New - ok ? */ - { "volcano", NULL, AREA }, /* 21 */ /* New - ok ? */ - { "wetland", NULL, AREA }, /* 22 */ /* New - ok ? */ + { "land", NULL, AREA }, /* 5 */ + { "bay", NULL, AREA }, /* 6 */ + { "beach", NULL, AREA }, /* 7 */ + { "cave_entrance", NULL, AREA }, /* 8 */ + { "cliff", NULL, AREA }, /* 9 */ + { "fell", NULL, AREA }, /* 10 */ + { "glacier", NULL, AREA }, /* 11 */ + { "heath", NULL, AREA }, /* 12 */ + { "marsh", NULL, AREA }, /* 13 */ + { "mud", NULL, AREA }, /* 14 */ + { "sand", NULL, AREA }, /* 15 */ + { "scree", NULL, AREA }, /* 16 */ + { "scrub", NULL, AREA }, /* 17 */ + { "sprint", NULL, AREA }, /* 18 */ + { "stone", NULL, AREA }, /* 19 */ + { "tree", NULL, AREA }, /* 20 */ + { "volcano", NULL, AREA }, /* 21 */ + { "wetland", NULL, AREA }, /* 22 */ { 0, NULL, 0 }, }; @@ -363,60 +363,62 @@ { "bus_station", NULL, 0 }, /* 18 */ { "place_of_worship", AMENITY, 0 }, /* 19 */ { "cafe", NULL, 0 }, /* 20 */ - { "bicycle_parking", NULL, AREA }, /* 21 */ - { "public_building", NULL, AREA }, /* 22 */ - { "grave_yard", NULL, AREA }, /* 23 */ - { "university", NULL, AREA }, /* 24 */ + { "bicycle_parking", AMENITY, AREA }, /* 21 */ + { "public_building", AMENITY, AREA }, /* 22 */ + { "grave_yard", PARK, AREA }, /* 23 */ + { "university", AMENITY, AREA }, /* 24 */ { "college", AMENITY, AREA }, /* 25 */ - { "townhall", NULL, AREA }, /* 26 */ - { "food_court", NULL, 0 }, /* 27 */ /* New - ok ? */ - { "drinking_water", NULL, 0 }, /* 28 */ /* New - ok ? */ - { "bbq", NULL, 0 }, /* 28 */ /* New - ok ? */ - { "bar", NULL, 0 }, /* 29 */ /* New - ok ? */ - { "biergarten", NULL, 0 }, /* 30 */ /* New - ok ? */ - { "ice_cream", NULL, 0 }, /* 31 */ /* New - ok ? */ - { "kindergarten", NULL, 0 }, /* 32 */ /* New - ok ? */ - { "ice_cream", NULL, 0 }, /* 33 */ /* New - ok ? */ - { "ferry_terminal", AMENITY, AREA }, /* 34 */ /* New - ok ? */ - { "bicycle_rental", NULL, 0 }, /* 35 */ /* New - ok ? */ - { "car_rental", NULL, 0 }, /* 36 */ /* New - ok ? */ - { "car_sharing", NULL, AREA }, /* 37 */ /* New - ok ? */ - { "car_wash", NULL, 0 }, /* 38 */ /* New - ok ? */ - { "grit_bin", NULL, 0 }, /* 39 */ /* New - ok ? */ - { "taxi", NULL, AREA }, /* 40 */ /* New - ok ? */ - { "atm", NULL, 0 }, /* 41 */ /* New - ok ? */ - { "bank", NULL, 0 }, /* 42 */ /* New - ok ? */ - { "bureau_de_change", NULL, 0 }, /* 43 */ /* New - ok ? */ - { "pharmacy", NULL, 0 }, /* 44 */ /* New - ok ? */ - { "baby_hatch", NULL, 0 }, /* 45 */ /* New - ok ? */ - { "dentist", NULL, 0 }, /* 46 */ /* New - ok ? */ - { "doctor", NULL, 0 }, /* 47 */ /* New - ok ? */ - { "social_facility", NULL, 0 }, /* 48 */ /* New - ok ? */ - { "veterinary", NULL, 0 }, /* 49 */ /* New - ok ? */ - { "architect_office", NULL, 0 }, /* 50 */ /* New - ok ? */ - { "arts_centre", AMENITY, AREA }, /* 51 */ /* New - ok ? */ - { "community_centre", AMENITY, AREA }, /* 52 */ /* New - ok ? */ - { "social_centre", AMENITY, AREA }, /* 53 */ /* New - ok ? */ - { "fountain", NULL, 0 }, /* 51 */ /* New - ok ? */ - { "nightclub", NULL, 0 }, /* 51 */ /* New - ok ? */ - { "stripclub", NULL, 0 }, /* 51 */ /* New - ok ? */ - { "studio", NULL, 0 }, /* 54 */ /* New - ok ? */ - { "bench", NULL, 0 }, /* 55 */ /* New - ok ? */ - { "brothel", NULL, 0 }, /* 56 */ /* New - ok ? */ - { "clock", NULL, 0 }, /* 57 */ /* New - ok ? */ - { "courthouse", AMENITY, 0 }, /* 58 */ /* New - ok ? */ - { "crematorium", AMENITY, 0 }, /* 59 */ /* New - ok ? */ - { "embassy", AMENITY, 0 }, /* 60 */ /* New - ok ? */ - { "hunting_stand", NULL, 0 }, /* 61 */ /* New - ok ? */ - { "marketplace", AMENITY, AREA }, /* 62 */ /* New - ok ? */ - { "prison", AMENITY, AREA }, /* 63 */ /* New - ok ? */ - { "recycling", NULL, 0 }, /* 64 */ /* New - ok ? */ - { "sauna", NULL, 0 }, /* 65 */ /* New - ok ? */ - { "shelter", NULL, AREA }, /* 66 */ /* New - ok ? */ - { "vending_machine", NULL, 0 }, /* 67 */ /* New - ok ? */ - { "waste_basket", NULL, 0 }, /* 68 */ /* New - ok ? */ - { "waste_disposal", NULL, 0 }, /* 69 */ /* New - ok ? */ - { "watering_place", NULL, 0 }, /* 70 */ /* New - ok ? */ + { "townhall", AMENITY, AREA }, /* 26 */ + { "food_court", NULL, 0 }, /* 27 */ + { "drinking_water", NULL, 0 }, /* 28 */ + { "bbq", NULL, 0 }, /* 28 */ + { "bar", NULL, 0 }, /* 29 */ + { "biergarten", NULL, 0 }, /* 30 */ + { "ice_cream", NULL, 0 }, /* 31 */ + { "kindergarten", NULL, 0 }, /* 32 */ + { "ice_cream", NULL, 0 }, /* 33 */ + { "ferry_terminal", AMENITY, AREA }, /* 34 */ + { "bicycle_rental", NULL, 0 }, /* 35 */ + { "car_rental", NULL, 0 }, /* 36 */ + { "car_sharing", AMENITY, AREA }, /* 37 */ + { "car_wash", NULL, 0 }, /* 38 */ + { "grit_bin", NULL, 0 }, /* 39 */ + { "taxi", AMENITY, AREA }, /* 40 */ + { "atm", NULL, 0 }, /* 41 */ + { "bank", NULL, 0 }, /* 42 */ + { "bureau_de_change", NULL, 0 }, /* 43 */ + { "pharmacy", NULL, 0 }, /* 44 */ + { "baby_hatch", NULL, 0 }, /* 45 */ + { "dentist", NULL, 0 }, /* 46 */ + { "doctor", NULL, 0 }, /* 47 */ + { "social_facility", NULL, 0 }, /* 48 */ + { "veterinary", NULL, 0 }, /* 49 */ + { "architect_office", NULL, 0 }, /* 50 */ + { "arts_centre", AMENITY, AREA }, /* 51 */ + { "community_centre", AMENITY, AREA }, /* 52 */ + { "social_centre", AMENITY, AREA }, /* 53 */ + { "fountain", NULL, 0 }, /* 51 */ + { "nightclub", NULL, 0 }, /* 51 */ + { "stripclub", NULL, 0 }, /* 51 */ + { "studio", NULL, 0 }, /* 54 */ + { "bench", NULL, 0 }, /* 55 */ + { "brothel", NULL, 0 }, /* 56 */ + { "clock", NULL, 0 }, /* 57 */ + { "courthouse", AMENITY, 0 }, /* 58 */ + { "crematorium", AMENITY, 0 }, /* 59 */ + { "embassy", AMENITY, 0 }, /* 60 */ + { "hunting_stand", NULL, 0 }, /* 61 */ + { "marketplace", AMENITY, AREA }, /* 62 */ + { "prison", AMENITY, AREA }, /* 63 */ + { "recycling", NULL, 0 }, /* 64 */ + { "sauna", NULL, 0 }, /* 65 */ + { "shelter", AMENITY, AREA }, /* 66 */ + { "vending_machine", NULL, 0 }, /* 67 */ + { "waste_basket", NULL, 0 }, /* 68 */ + { "waste_disposal", NULL, 0 }, /* 69 */ + { "watering_place", NULL, 0 }, /* 70 */ + { "bicycle parking", AMENITY, AREA }, /* 71 */ + { "public building", AMENITY, AREA }, /* 72 */ { 0, NULL, 0 }, }; @@ -444,8 +446,8 @@ { "fishing", NULL, AREA }, /* 5 */ { "slipway", NULL, 0 }, /* 6 */ { "water_park", NULL, AREA }, /* 7 */ - { "pitch", NULL, AREA }, /* 8 */ - { "track", NULL, AREA }, /* 9 */ + { "pitch", AMENITY, AREA }, /* 8 */ + { "track", AMENITY, AREA }, /* 9 */ { "marina", AMENITY, AREA }, /* 10 */ { "stadium", AMENITY, AREA }, /* 11 */ { "golf_course", PARK, AREA }, /* 12 */ @@ -457,6 +459,7 @@ { "miniature_golf", AMENITY, AREA }, /* 18 */ { "dance", AMENITY, AREA }, /* 19 */ { "swimming_pool", AMENITY, AREA }, /* 20 */ + { "golf course", PARK, AREA }, /* 21 */ { 0, NULL, 0 }, }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-23 19:18:43
|
Revision: 2667 http://roadmap.svn.sourceforge.net/roadmap/?rev=2667&view=rev Author: dannybackx Date: 2011-02-23 19:18:36 +0000 (Wed, 23 Feb 2011) Log Message: ----------- Novelties in allowed tags. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_common.c Modified: trunk/roadmap/src/buildmap_osm_common.c =================================================================== --- trunk/roadmap/src/buildmap_osm_common.c 2011-02-22 19:27:34 UTC (rev 2666) +++ trunk/roadmap/src/buildmap_osm_common.c 2011-02-23 19:18:36 UTC (rev 2667) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright (c) 2007 Paul Fox - * Copyright (c) 2008, 2010, Danny Backx + * Copyright (c) 2008, 2010, 2011, Danny Backx * * This file is part of RoadMap. * @@ -449,7 +449,14 @@ { "marina", AMENITY, AREA }, /* 10 */ { "stadium", AMENITY, AREA }, /* 11 */ { "golf_course", PARK, AREA }, /* 12 */ - { "sports_centre", NULL, AREA }, /* 13 */ + { "sports_centre", AMENITY, AREA }, /* 13 */ + { "sports centre", AMENITY, AREA }, /* 14 */ + { "dog_park", PARK, AREA }, /* 15 */ + { "playground", PARK, AREA }, /* 16 */ + { "ice_rink", AMENITY, AREA }, /* 17 */ + { "miniature_golf", AMENITY, AREA }, /* 18 */ + { "dance", AMENITY, AREA }, /* 19 */ + { "swimming_pool", AMENITY, AREA }, /* 20 */ { 0, NULL, 0 }, }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-22 19:27:40
|
Revision: 2666 http://roadmap.svn.sourceforge.net/roadmap/?rev=2666&view=rev Author: dannybackx Date: 2011-02-22 19:27:34 +0000 (Tue, 22 Feb 2011) Log Message: ----------- roadmap_trip.c : - use more end-user readable titles for file selection dialogs. - add comments/documentation roadmap_start.c, roadgps_logger.[ch] : add roadgps_shutdown(). roadmap_start.c : reorder roadmap_*_initialize calls so roadmap_track initialisation happens at the right time. Modified Paths: -------------- trunk/roadmap/src/roadgps_logger.c trunk/roadmap/src/roadgps_logger.h trunk/roadmap/src/roadmap_start.c trunk/roadmap/src/roadmap_trip.c Modified: trunk/roadmap/src/roadgps_logger.c =================================================================== --- trunk/roadmap/src/roadgps_logger.c 2011-02-16 21:53:59 UTC (rev 2665) +++ trunk/roadmap/src/roadgps_logger.c 2011-02-22 19:27:34 UTC (rev 2666) @@ -1,8 +1,8 @@ -/* roadgps_logger.c - Log NMEA messages. - * +/* * LICENSE: * * Copyright 2002 Pascal F. Martin + * Copyright (c) 2011, Danny Backx * * This file is part of RoadMap. * @@ -19,12 +19,13 @@ * You should have received a copy of the GNU General Public License * along with RoadMap; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * SYNOPSYS: - * - * See roadgps_logger.h */ +/** + * @file + * @brief roadgps_logger.c - Log NMEA messages. + */ + #include <stdio.h> #include "roadmap.h" @@ -42,6 +43,10 @@ static RoadMapConfigDescriptor RoadMapConfigLogPath = ROADMAP_CONFIG_ITEM("Log", "Path"); +/** + * @brief send this string to the log file + * @param sentence string to print + */ static void roadgps_logger (const char *sentence) { if (RoadGpsOutput != NULL) { @@ -51,7 +56,9 @@ roadmap_main_set_status (sentence); } - +/** + * @brief stop logging, close the file + */ void roadgps_logger_stop (void) { if (RoadGpsOutput != NULL) { @@ -60,7 +67,11 @@ } } - +/** + * @brief function called when the user confirms in the file selection dialog + * @param filename full path name of the file selected by the user + * @param mode "r" or "w" to indicate type of access -- always "w" in this case + */ static void roadgps_logger_file_dialog_ok (const char *filename, const char *mode) { @@ -79,17 +90,21 @@ roadmap_path_free(path); } - +/** + * @brief start logging, open the file + */ void roadgps_logger_start (void) { - roadmap_fileselection_new ("RoadGps Log", + roadmap_fileselection_new ("Select file for GPS logging", NULL, /* no filter. */ roadmap_config_get(&RoadMapConfigLogPath), "w", roadgps_logger_file_dialog_ok); } - +/** + * @brief initialize this module + */ void roadgps_logger_initialize (void) { roadmap_config_declare @@ -98,3 +113,10 @@ roadmap_gps_register_logger (roadgps_logger); } +/** + * @brief close down this module + */ +void roadgps_logger_shutdown (void) { + + roadgps_logger_stop (); +} Modified: trunk/roadmap/src/roadgps_logger.h =================================================================== --- trunk/roadmap/src/roadgps_logger.h 2011-02-16 21:53:59 UTC (rev 2665) +++ trunk/roadmap/src/roadgps_logger.h 2011-02-22 19:27:34 UTC (rev 2666) @@ -1,8 +1,9 @@ -/* roadgps_window.h - The interface for the RoadGps main window module. +/* roadgps_logging.h - The interface for the RoadGps logging module. * * LICENSE: * * Copyright 2002 Pascal F. Martin + * Copyright (c) 2011, Danny Backx * * This file is part of RoadMap. * @@ -25,6 +26,7 @@ #define INCLUDE__ROADGPS_LOGGER__H void roadgps_logger_initialize (void); +void roadgps_logger_shutdown (void); void roadgps_logger_start (void); void roadgps_logger_stop (void); Modified: trunk/roadmap/src/roadmap_start.c =================================================================== --- trunk/roadmap/src/roadmap_start.c 2011-02-16 21:53:59 UTC (rev 2665) +++ trunk/roadmap/src/roadmap_start.c 2011-02-22 19:27:34 UTC (rev 2666) @@ -1617,7 +1617,6 @@ #ifdef HAVE_NAVIGATE_PLUGIN roadmap_tripdb_initialize (); #endif - roadmap_track_initialize (); roadmap_landmark_initialize (); roadmap_features_initialize (); roadmap_pointer_initialize (); @@ -1628,6 +1627,7 @@ roadmap_display_initialize (); roadmap_voice_initialize (); roadmap_gps_initialize (); + roadmap_track_initialize (); roadgps_screen_initialize (); roadmap_canvas_register_configure_handler (roadmap_start_screen_configure); roadgps_logger_initialize (); @@ -1769,6 +1769,7 @@ roadmap_config_shutdown (); roadmap_sprite_shutdown (); roadmap_layer_shutdown (); + roadgps_logger_shutdown (); roadmap_path_shutdown (); roadmap_log (ROADMAP_WARNING, "RoadMap exiting, time %s", roadmap_start_now()); } Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2011-02-16 21:53:59 UTC (rev 2665) +++ trunk/roadmap/src/roadmap_trip.c 2011-02-22 19:27:34 UTC (rev 2666) @@ -1423,8 +1423,7 @@ RoadMapTripRefresh = 1; } - - +#if USE_ICON_NAME /** * @brief * @param name @@ -1432,10 +1431,15 @@ * @param sprite * @return */ -#if USE_ICON_NAME waypoint * roadmap_trip_new_waypoint (const char *name, RoadMapPosition * position, const char *sprite) #else +/** + * @brief + * @param name + * @param position + * @return + */ waypoint * roadmap_trip_new_waypoint (const char *name, RoadMapPosition * position) #endif { @@ -2588,6 +2592,7 @@ /** * @brief start a new trip + * Save the current one if there are unsaved changes */ void roadmap_trip_new (void) { @@ -2681,22 +2686,22 @@ * @brief create a file selection dialog * @param mode */ -static void roadmap_trip_file_dialog (const char *mode) +static void roadmap_trip_file_dialog (const char *title, const char *mode) { - roadmap_fileselection_new ("RoadMap Trip", + roadmap_fileselection_new (title, #ifdef _WIN32 - "*.gpx", + "*.gpx", #else - NULL, /* no filter. */ + NULL, /* no filter. */ #endif - roadmap_path_trips (), - mode, - roadmap_trip_file_dialog_ok); + roadmap_path_trips (), + mode, + roadmap_trip_file_dialog_ok); } -static void roadmap_trip_file_merge_dialog (const char *mode) { +static void roadmap_trip_file_merge_dialog (const char *title, const char *mode) { - roadmap_fileselection_new ("RoadMap Trip Merge", NULL, /* no filter. */ + roadmap_fileselection_new (title, NULL, /* no filter. */ roadmap_path_trips (), mode, roadmap_trip_file_merge_dialog_ok); } @@ -2857,14 +2862,19 @@ */ void roadmap_trip_load_ask (void) { - roadmap_trip_file_dialog ("r"); + roadmap_trip_file_dialog ("Select file to read trip", "r"); } void roadmap_trip_merge_ask (void) { - roadmap_trip_file_merge_dialog ("r"); + roadmap_trip_file_merge_dialog ("Select file to merge trip with", "r"); } +/** + * @brief Save the current trip to a file named in the parameter + * @param name file name to save into + * @return 1 if success, 0 on failure + */ static int roadmap_trip_save_file (const char *name) { const char *path = NULL; @@ -2886,6 +2896,10 @@ } +/** + * @brief Save the current trip if there are unsaved changes. + * @return 1 if success, 0 on failure + */ int roadmap_trip_save (void) { int ret = 1; /* success */ @@ -2932,7 +2946,7 @@ } void roadmap_trip_save_as() { - roadmap_trip_file_dialog ("w"); + roadmap_trip_file_dialog ("Select file to save trip", "w"); } @@ -3662,8 +3676,13 @@ } +/** + * @brief reinitialize the roadmap_trip module + */ void roadmap_trip_shutdown (void) { + roadmap_trip_save(); + // route_del (RoadMapCurrentRoute); RoadMapCurrentRoute = NULL; RoadMapRouteInProgress = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-16 21:54:05
|
Revision: 2665 http://roadmap.svn.sourceforge.net/roadmap/?rev=2665&view=rev Author: dannybackx Date: 2011-02-16 21:53:59 +0000 (Wed, 16 Feb 2011) Log Message: ----------- Implement NMEA logging for Android (with a shortcut for the file selection dialog). Modified Paths: -------------- trunk/roadmap/src/android/roadmap_androidgps.c trunk/roadmap/src/android/roadmap_fileselection.c trunk/roadmap/src/android/roadmap_main.c trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java Modified: trunk/roadmap/src/android/roadmap_androidgps.c =================================================================== --- trunk/roadmap/src/android/roadmap_androidgps.c 2011-02-16 21:51:48 UTC (rev 2664) +++ trunk/roadmap/src/android/roadmap_androidgps.c 2011-02-16 21:53:59 UTC (rev 2665) @@ -1,7 +1,7 @@ /* * LICENSE: * - * Copyright 2010 Danny Backx + * Copyright (c) 2010, 2011 Danny Backx * * This file is part of RoadMap. * @@ -52,29 +52,59 @@ { } +/** + * @brief indicate that this function is to be called when the GPS triggers us + * @param navigation + */ void roadmap_androidgps_subscribe_to_navigation (RoadMapGpsdNavigation navigation) { navigationListener = navigation; } - +/** + * @brief indicate that this function is to be called when the GPS triggers us + * @param satellite + */ void roadmap_androidgps_subscribe_to_satellites (RoadMapGpsdSatellite satellite) { satelliteListener = satellite; } - +/** + * @brief indicate that this function is to be called when the GPS triggers us + * @param dilution + */ void roadmap_androidgps_subscribe_to_dilution (RoadMapGpsdDilution dilution) { dilutionListener = dilution; } - +/** + * @brief On Android, we don't need this function : no need to decode ASCII streams + * from the GPS device in RoadMap. Android already does that for us. + * @param user_context + * @param decoder_context + * @param sentence + */ +#if 0 int roadmap_androidgps_decode (void *user_context, void *decoder_context, char *sentence) { __android_log_print (ANDROID_LOG_ERROR, "RoadMap", "roadmap_androidgps_decode()"); } +#endif +/** + * @brief function called every time the Android GPS passes a new gps fix + * @param env the JNI environment + * @param thiz the Java object referred to via JNI + * @param status a status byte, RoadMap related + * @param gpstime the time + * @param lat the latitude + * @param lon the longitude + * @param alt the altitude + * @param speed the speed + * @param steering the steering + */ void Java_net_sourceforge_projects_roadmap_RoadMap_HereAmI(JNIEnv* env, jobject thiz, int status, int gpstime, int lat, int lon, int alt, int speed, int steering) @@ -96,9 +126,9 @@ extern jobject RoadMapThiz; /** - * @brief - * @param - * @return + * @brief get the Java layer to request Android location info + * @param name not used on Android + * @return 0 on success, -1 on failure */ RoadMapSocket roadmap_androidgps_connect (const char *name) { @@ -113,6 +143,9 @@ return 0; } +/** + * @brief stop getting location info + */ void roadmap_androidgps_close (void) { jmethodID mid; Modified: trunk/roadmap/src/android/roadmap_fileselection.c =================================================================== --- trunk/roadmap/src/android/roadmap_fileselection.c 2011-02-16 21:51:48 UTC (rev 2664) +++ trunk/roadmap/src/android/roadmap_fileselection.c 2011-02-16 21:53:59 UTC (rev 2665) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin - * Copyright 2010 Danny Backx + * Copyright (c) 2010, 2011 Danny Backx * * This file is part of RoadMap. * @@ -30,13 +30,12 @@ #include <string.h> #include <stdlib.h> -#include <unistd.h> -// #include <gtk/gtk.h> +#include "roadmap.h" +#include "roadmap_types.h" +#include "roadmap_start.h" +#include "roadmap_jni.h" #include "roadmap_fileselection.h" - -#include "roadmap.h" -#include "roadmap_types.h" #include "roadmap_file.h" @@ -69,9 +68,45 @@ static RoadMapFileSelection *RoadMapFileWindows = NULL; +/* + * JNI + */ +#define MYCLS2 "net/sourceforge/projects/roadmap/RoadMap" +static jclass myRmClassCache = (jclass) 0; +static jclass TheRoadMapClass() +{ + if (myRmClassCache == 0) { + myRmClassCache = (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, MYCLS2); + myRmClassCache = (*RoadMapJniEnv)->NewGlobalRef(RoadMapJniEnv, myRmClassCache); + } + if (myRmClassCache == 0) { + __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "Class not found"); + // throw + (*RoadMapJniEnv)->ThrowNew(RoadMapJniEnv, + (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, "java/io/IOException"), + "A JNI Exception occurred"); + } + + return myRmClassCache; +} + +static jmethodID TheMethod(const jclass cls, const char *name, const char *signature) +{ + jmethodID mid; + + mid = (*RoadMapJniEnv)->GetMethodID(RoadMapJniEnv, cls, name, signature); + if (mid == 0) { + (*RoadMapJniEnv)->ThrowNew(RoadMapJniEnv, + (*RoadMapJniEnv)->FindClass(RoadMapJniEnv, "java/io/IOException"), + "A JNI Exception occurred"); + } + return mid; +} + + /** - * @brief + * @brief huh ? always returns NULL * @param title * @return */ @@ -100,12 +135,22 @@ } #endif - +/** + * @brief open a file selection dialog + * @param title + * @param filter + * @param path + * @param mode + * @param callback + */ void roadmap_fileselection_new (const char *title, const char *filter, const char *path, const char *mode, RoadMapFileCallback callback) { + roadmap_log(ROADMAP_WARNING, "roadmap_fileselection_new(%s,%s,%s,%s)", title, filter, path, mode); + + callback("/sdcard/roadmap/yow.gpx", mode); #if 0 RoadMapFileSelection *item = roadmap_fileselection_search (title); @@ -170,3 +215,12 @@ gtk_widget_show_all (GTK_WIDGET(item->dialog)); #endif } + +#if 0 + jclass cls = TheRoadMapClass(); + jmethodID mid = TheMethod(cls, "CreateHeading", "(Ljava/lang/String;I)I"); + jstring js = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, frame); + + (*RoadMapJniEnv)->CallIntMethod(RoadMapJniEnv, RoadMapThiz, mid, js, + parent->w); +#endif Modified: trunk/roadmap/src/android/roadmap_main.c =================================================================== --- trunk/roadmap/src/android/roadmap_main.c 2011-02-16 21:51:48 UTC (rev 2664) +++ trunk/roadmap/src/android/roadmap_main.c 2011-02-16 21:53:59 UTC (rev 2665) @@ -27,6 +27,10 @@ * @ingroup android */ +/** + * @defgroup android RoadMap implementation for Android + */ + #include <stdlib.h> #include <stdlib.h> #include <string.h> @@ -52,7 +56,7 @@ RoadMapInput callback; }; -#define ROADMAP_MAX_IO 16 +#define ROADMAP_MAX_IO 4 static struct roadmap_main_io RoadMapMainIo[ROADMAP_MAX_IO]; @@ -144,7 +148,7 @@ jmethodID mid = TheMethod(cls, "CreateMenu", "(Ljava/lang/String;)I"); jstring js; - roadmap_log (ROADMAP_WARNING, "roadmap_main_new_menu(%s)", title); + // roadmap_log (ROADMAP_WARNING, "roadmap_main_new_menu(%s)", title); js = (*RoadMapJniEnv)->NewStringUTF(RoadMapJniEnv, title); int i = (*RoadMapJniEnv)->CallIntMethod(RoadMapJniEnv, RoadMapThiz, mid, js); @@ -167,12 +171,12 @@ */ void roadmap_main_add_menu (RoadMapMenu menu, const char *label) { - roadmap_log (ROADMAP_WARNING, "roadmap_main_add_menu(%d,%s) /* FIX ME */", (int)menu, label); + // roadmap_log (ROADMAP_WARNING, "roadmap_main_add_menu(%d,%s) /* FIX ME */", (int)menu, label); int m = (int)menu; jclass cls = TheRoadMapClass(); jmethodID mid = TheMethod(cls, "AttachMenuToBar", "(I)V"); - __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_main_add_menu(%d,%s)", m, label); + // __android_log_print(ANDROID_LOG_ERROR, "RoadMap", "roadmap_main_add_menu(%d,%s)", m, label); (*RoadMapJniEnv)->CallVoidMethod(RoadMapJniEnv, RoadMapThiz, mid, m); } @@ -216,7 +220,7 @@ maxcallbacks += 100; callbacks = realloc(callbacks, sizeof(struct callback) * maxcallbacks); - roadmap_log (ROADMAP_WARNING, "roadmap_main_add_menu_item %d", maxcallbacks); + roadmap_log (ROADMAP_DEBUG, "roadmap_main_add_menu_item %d", maxcallbacks); } if (i < maxcallbacks) { /* This should now always be true */ @@ -387,9 +391,18 @@ RoadMapMainIo[i].io = *io; RoadMapMainIo[i].callback = callback; RoadMapMainIo[i].id = 0; - break; + + jclass cls = TheRoadMapClass(); + jmethodID mid = TheMethod(cls, "MainSetInput", "(I)V"); + + (*RoadMapJniEnv)->CallVoidMethod(RoadMapJniEnv, RoadMapThiz, mid, i); + + return; } } + + /* Error if we make it here */ + roadmap_log (ROADMAP_FATAL, "roadmap_main_set_input failed"); } /** @@ -411,6 +424,27 @@ } /** + * @brief Receive an NMEA string from Java, pass it through our channel to roadmap_io, + * then call the handler for this. + * Note this has been written with only one purpose : logging NMEA to a file. + * @param env the JNI environment + * @param thiz the JNI object + * @param id points to the right context + * @param nmea string (Java format) passed by Android + */ +void +Java_net_sourceforge_projects_roadmap_RoadMap_NMEALogger(JNIEnv* env, jobject thiz, int id, jstring nmea) +{ + struct roadmap_main_io *context = &RoadMapMainIo[id]; + const char *s = (*env)->GetStringUTFChars(env, nmea, NULL); + int l = strlen(s); + + roadmap_io_write(&context->io, s, l); + + (*context->callback)(&context->io); +} + +/** * @brief Call the callback periodically from now on * @param interval * @param callback Modified: trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java =================================================================== --- trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java 2011-02-16 21:51:48 UTC (rev 2664) +++ trunk/roadmap/src/android/src/net/sourceforge/projects/roadmap/RoadMap.java 2011-02-16 21:53:59 UTC (rev 2665) @@ -60,8 +60,10 @@ import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; +import android.location.LocationManager; import android.location.GpsStatus; import android.location.GpsStatus.Listener; +import android.location.GpsStatus.NmeaListener; import android.location.GpsSatellite; import android.content.res.AssetManager; @@ -93,6 +95,7 @@ LinearLayout ll, buttons = null; Panel p; Menu myMenu = null; + int InputHandler; AssetManager asm; PowerManager power; @@ -117,6 +120,7 @@ public native void DialogSpecialCallback(int dlg, int btn); public native void ReturnStringDataHack(String s); public native void RoadMapDialogChosen(int position, long id); + public native void NMEALogger(int id, String nmea); @Override public void onCreate(Bundle state) @@ -253,6 +257,24 @@ mgr.removeGpsStatusListener(onGpsChange); } + public void MainSetInput(int id) { + InputHandler = id; + + // Log.e("RoadMap", "MainSetInput("+id+")"); + try { + mgr.addNmeaListener(onNmea); + } catch (Exception e) { + Log.e("RoadMap", "MainSetInput exception" + e); + } + } + + NmeaListener onNmea = new NmeaListener() { + public void onNmeaReceived(long ts, String nmea) { + // Log.e("RoadMap", "onNmeaReceived("+ts+","+nmea+")"); + NMEALogger(InputHandler, nmea); + } + }; + LocationListener onLocationChange = new LocationListener() { int mystatus; @@ -449,16 +471,12 @@ else parent = menuCache[i].menu; - Log.e("RoadMap", "onCreateOptionsMenu -> " + i - + " [" + menuCache[i].label - + "] in bar : " + menuCache[i].inbar); + // Log.e("RoadMap", "onCreateOptionsMenu -> " + i + " [" + menuCache[i].label + "] in bar : " + menuCache[i].inbar); if (menuCache[i].inbar != 0) { try { menuCache[i].menu = parent.addSubMenu(menuCache[i].label); } catch (Exception e) { - Log.e("RoadMap", "AddSubMenu {" + i - + "} (" + parent + "," - + menuCache[i].label + ") : exception " + e); + // Log.e("RoadMap", "AddSubMenu {" + i + "} (" + parent + "," + menuCache[i].label + ") : exception " + e); return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-16 21:51:54
|
Revision: 2664 http://roadmap.svn.sourceforge.net/roadmap/?rev=2664&view=rev Author: dannybackx Date: 2011-02-16 21:51:48 +0000 (Wed, 16 Feb 2011) Log Message: ----------- Rename ROADMAP_IO_ANDROID to ROADMAP_IO_MEMORY and implement a simplistic way to pass data around. Fix a case where a pointer to a function was called without checking whether it was non-null. Modified Paths: -------------- trunk/roadmap/src/roadmap_gps.c trunk/roadmap/src/roadmap_input.c trunk/roadmap/src/roadmap_io.c trunk/roadmap/src/roadmap_io.h Modified: trunk/roadmap/src/roadmap_gps.c =================================================================== --- trunk/roadmap/src/roadmap_gps.c 2011-02-14 19:33:23 UTC (rev 2663) +++ trunk/roadmap/src/roadmap_gps.c 2011-02-16 21:51:48 UTC (rev 2664) @@ -294,7 +294,7 @@ } /** - * @brief + * @brief call the logger functions * @param data */ static void roadmap_gps_call_loggers (const char *data) { @@ -819,7 +819,7 @@ if (RoadMapGpsLink.subsystem == ROADMAP_IO_INVALID) return; #ifdef ANDROID - if (RoadMapGpsLink.subsystem == ROADMAP_IO_ANDROID) { + if (RoadMapGpsLink.subsystem == ROADMAP_IO_MEMORY) { roadmap_androidgps_close (); } #endif @@ -1075,7 +1075,7 @@ RoadMapGpsRetryPending = 0; } #else /* ANDROID */ - RoadMapGpsLink.subsystem = ROADMAP_IO_ANDROID; + RoadMapGpsLink.subsystem = ROADMAP_IO_MEMORY; RoadMapGpsProtocol = ROADMAP_GPS_ANDROID; #endif @@ -1139,7 +1139,10 @@ } } - +/** + * @brief register a logger + * @param logger function to be called to log + */ void roadmap_gps_register_logger (roadmap_gps_logger logger) { int i; @@ -1220,7 +1223,7 @@ #ifdef ANDROID case ROADMAP_GPS_ANDROID: - decode.decoder = roadmap_androidgps_decode; + decode.decoder = NULL; /* roadmap_androidgps_decode is not required */ decode.decoder_context = NULL; break; #endif Modified: trunk/roadmap/src/roadmap_input.c =================================================================== --- trunk/roadmap/src/roadmap_input.c 2011-02-14 19:33:23 UTC (rev 2663) +++ trunk/roadmap/src/roadmap_input.c 2011-02-16 21:51:48 UTC (rev 2664) @@ -2,6 +2,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin + * Copyright (c) 2011 Danny Backx * * This file is part of RoadMap. * @@ -116,7 +117,7 @@ } /** - * @brief + * @brief called from e.g. roadmap_gps_input, which has augmented the context with configuration dependent functions to call * @param context * @return */ @@ -128,7 +129,6 @@ char *line_start; char *data_end; - /* Receive more data if available. */ if (context->cursor >= (int)sizeof(context->data) - 1) { @@ -204,7 +204,8 @@ if (context->logger != NULL) { context->logger (line_start); } - result |= context->decoder (context->user_context, + if (context->decoder) + result |= context->decoder (context->user_context, context->decoder_context, line_start); Modified: trunk/roadmap/src/roadmap_io.c =================================================================== --- trunk/roadmap/src/roadmap_io.c 2011-02-14 19:33:23 UTC (rev 2663) +++ trunk/roadmap/src/roadmap_io.c 2011-02-16 21:51:48 UTC (rev 2664) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin - * Copyright 2010 Danny Backx + * Copyright (c) 2010, 2011 Danny Backx * * This file is part of RoadMap. * @@ -36,6 +36,7 @@ */ #include "roadmap_io.h" +#include "roadmap.h" int roadmap_io_read (RoadMapIO *io, void *data, int size) { @@ -55,8 +56,22 @@ return roadmap_spawn_read_pipe (io->os.pipe, data, size); case ROADMAP_IO_NULL: - case ROADMAP_IO_ANDROID: return 0; /* Cannot receive anything from there. */ + + case ROADMAP_IO_MEMORY: + if (io->os.data) { + int l = strlen(io->os.data); + if (l < size) { + strcpy(data, io->os.data); + io->os.data = NULL; + return l; + } + + strncpy(data, io->os.data, size); + io->os.data = NULL; + return size; + } + return 0; } return -1; } @@ -79,8 +94,11 @@ return roadmap_spawn_write_pipe (io->os.pipe, data, length); case ROADMAP_IO_NULL: - case ROADMAP_IO_ANDROID: return length; /* It's all done, since there is nothing to do. */ + + case ROADMAP_IO_MEMORY: + io->os.data = data; + return length; } return -1; } @@ -107,7 +125,7 @@ break; case ROADMAP_IO_NULL: - case ROADMAP_IO_ANDROID: + case ROADMAP_IO_MEMORY: break; } io->subsystem = ROADMAP_IO_INVALID; @@ -140,7 +158,7 @@ break; case ROADMAP_IO_NULL: - case ROADMAP_IO_ANDROID: + case ROADMAP_IO_MEMORY: break; /* No reason to be any different from each other. */ } Modified: trunk/roadmap/src/roadmap_io.h =================================================================== --- trunk/roadmap/src/roadmap_io.h 2011-02-14 19:33:23 UTC (rev 2663) +++ trunk/roadmap/src/roadmap_io.h 2011-02-16 21:51:48 UTC (rev 2664) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin - * Copyright 2010 Danny Backx + * Copyright (c) 2010, 2011 Danny Backx * * This file is part of RoadMap. * @@ -23,7 +23,7 @@ /** * @file - * @brief roadmap_file.h - a module to open/read/close a roadmap database file. + * @brief roadmap_io.h - a unique interface to all types of IO * * DESCRIPTION: * @@ -52,17 +52,18 @@ #define ROADMAP_IO_SERIAL 3 #define ROADMAP_IO_PIPE 4 #define ROADMAP_IO_NULL 5 /* Bottomless pitt (i.e., no IO). */ -#define ROADMAP_IO_ANDROID 6 +#define ROADMAP_IO_MEMORY 6 /* Simply pass data in memory, currently Android only. */ typedef struct { int subsystem; union { - RoadMapFile file; + RoadMapFile file; RoadMapSocket socket; RoadMapSerial serial; RoadMapPipe pipe; + char *data; } os; } RoadMapIO; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-14 19:33:29
|
Revision: 2663 http://roadmap.svn.sourceforge.net/roadmap/?rev=2663&view=rev Author: dannybackx Date: 2011-02-14 19:33:23 +0000 (Mon, 14 Feb 2011) Log Message: ----------- Add <tag k='place' v='suburb'/> as a grey area. Reykjavic has some of this. Modified Paths: -------------- trunk/roadmap/src/buildmap_osm_common.c trunk/roadmap/src/default/All Modified: trunk/roadmap/src/buildmap_osm_common.c =================================================================== --- trunk/roadmap/src/buildmap_osm_common.c 2011-02-13 14:01:31 UTC (rev 2662) +++ trunk/roadmap/src/buildmap_osm_common.c 2011-02-14 19:33:23 UTC (rev 2663) @@ -84,6 +84,7 @@ int BuildMapLayerMall = 0; int BuildMapLayerNature = 0; int BuildMapLayerAmenity = 0; +int BuildMapLayerSuburbs = 0; /* Water layers. */ @@ -116,6 +117,7 @@ #define BOUNDARY &BuildMapLayerBoundary #define NATURE &BuildMapLayerNature #define AMENITY &BuildMapLayerAmenity +#define SUBURBS &BuildMapLayerSuburbs BuildMapDictionary DictionaryPrefix; BuildMapDictionary DictionaryStreet; @@ -149,6 +151,7 @@ BuildMapLayerNature = buildmap_layer_get ("nature"); BuildMapLayerAmenity = buildmap_layer_get ("amenity"); + BuildMapLayerSuburbs = buildmap_layer_get ("suburbs"); BuildMapLayerBoundary = buildmap_layer_get ("boundaries"); } @@ -428,7 +431,7 @@ { "town", NULL, AREA }, /* 7 */ { "village", NULL, AREA }, /* 8 */ { "hamlet", NULL, AREA }, /* 9 */ - { "suburb", NULL, AREA }, /* 10 */ + { "suburb", SUBURBS, AREA }, /* 10 */ { 0, NULL, 0 }, }; Modified: trunk/roadmap/src/default/All =================================================================== --- trunk/roadmap/src/default/All 2011-02-13 14:01:31 UTC (rev 2662) +++ trunk/roadmap/src/default/All 2011-02-14 19:33:23 UTC (rev 2663) @@ -1,6 +1,6 @@ Class.Name: All Class.Lines: Freeways Ramps Highways Streets Trails Rivers Shore Railroads Boundaries -Class.Polygons: Lakes Sea Parks Hospitals Airports Stations Malls Nature Amenity +Class.Polygons: Lakes Sea Parks Hospitals Airports Stations Malls Nature Amenity Suburbs Class.NavigationModes: Car Bike Foot Boat Navigation.Car: Freeways Ramps Highways Streets Navigation.Bike: Streets Trails Shore Parks @@ -89,3 +89,7 @@ Amenity.Declutter: 1300 Amenity.Thickness: 1 Amenity.Speed: 1 +Suburbs.Color: grey +Suburbs.Declutter: 1300 +Suburbs.Thickness: 1 +Suburbs.Speed: 50 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-13 14:01:38
|
Revision: 2662 http://roadmap.svn.sourceforge.net/roadmap/?rev=2662&view=rev Author: dannybackx Date: 2011-02-13 14:01:31 +0000 (Sun, 13 Feb 2011) Log Message: ----------- Quiet some of the logging (e.g. in roadmap_layer.c, from warning to debug). Clean up (especially in navigate/) to decrease warnings. Modified Paths: -------------- trunk/roadmap/src/navigate/navigate.c trunk/roadmap/src/navigate/navigate.h trunk/roadmap/src/navigate/navigate_route.c trunk/roadmap/src/navigate/navigate_simple.h trunk/roadmap/src/roadmap_layer.c trunk/roadmap/src/roadmap_plugin.c trunk/roadmap/src/roadmap_trip.c trunk/roadmap/src/roadmap_trip.h Modified: trunk/roadmap/src/navigate/navigate.c =================================================================== --- trunk/roadmap/src/navigate/navigate.c 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/navigate/navigate.c 2011-02-13 14:01:31 UTC (rev 2662) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2006 Ehud Shabtai - * Copyright (c) 2008, 2009 by Danny Backx. + * Copyright (c) 2008, 2009, 2011 by Danny Backx. * * This file is part of RoadMap. * @@ -67,6 +67,11 @@ #include "navigate_cost.h" #include "navigate_route.h" #include "navigate.h" +#include "navigate_visual.h" +#include "navigate_simple.h" +#ifdef ROADMAP_NAVIGATE_SHOOTINGSTAR +#include "navigate_shst.h" +#endif #define ROUTE_PEN_WIDTH 4 @@ -85,33 +90,29 @@ RoadMapConfigDescriptor NavigateConfigNavigating = ROADMAP_CONFIG_ITEM("Navigation", "Is navigating"); -int NavigateEnabled = 0; -int NavigatePluginID = -1; +static int NavigateEnabled = 0; /**< is navigation currently enabled */ static int NavigateTrackEnabled = 0; -static int NavigateTrackFollowGPS = 0; +// static int NavigateTrackFollowGPS = 0; static RoadMapPen NavigatePen[2]; static RoadMapPen NavigatePenEst[2]; static void navigate_update (RoadMapPosition *position, PluginLine *current); -static void navigate_get_next_line - (PluginLine *current, int direction, PluginLine *next); +// static void navigate_get_next_line (PluginLine *current, int direction, PluginLine *next); -static RoadMapCallback NextMessageUpdate; - -static int NavigateDistanceToDest; -static int NavigateETA; -static int NavigateDistanceToTurn; -static int NavigateETAToTurn; +// static int NavigateDistanceToDest; +// static int NavigateETA; +// static int NavigateDistanceToTurn; +// static int NavigateETAToTurn; static int NavigateFlags; -static NavigateSegment NavigateSegments[MAX_NAV_SEGMENTS]; +// static NavigateSegment NavigateSegments[MAX_NAV_SEGMENTS]; static int NavigateNumSegments = 0; -static int NavigateCurrentSegment = 0; +// static int NavigateCurrentSegment = 0; static PluginLine NavigateDestination = PLUGIN_LINE_NULL; -static int NavigateDestPoint; +// static int NavigateDestPoint; static RoadMapPosition NavigateDestPos; -static RoadMapPosition NavigateSrcPos; -static int NavigateNextAnnounce; +// static RoadMapPosition NavigateSrcPos; +// static int NavigateNextAnnounce; /** * @brief new style structure for navigation info @@ -119,8 +120,8 @@ NavigateStatus status; /** - * @brief - * @return + * @brief recalculate the route (implemented in navigate_route.c) + * @return status */ static int navigate_recalc_route () { @@ -447,6 +448,9 @@ /** * @brief gets a GPS position update * @param position + * @param line + * @param street + * @param street_has_changed our caller already figured out whether we're in another street than before */ #define HYST 15 void navigate_update_position (const RoadMapPosition *position, @@ -457,7 +461,7 @@ static RoadMapPosition old, cur; int x, y; static int firsttime = 1; - int doit; + int need_recalc = 0, r; static int skip = 0; /**< count #times < HYST */ if (position == 0) @@ -466,10 +470,12 @@ if (firsttime) { roadmap_log (ROADMAP_WARNING, "navigate_update_position(%d %d) initial", position->longitude, position->latitude); + need_recalc = 1; } + firsttime = 0; if (position->longitude == oldpos.longitude && position->latitude == oldpos.latitude) { - firsttime = 0; + roadmap_log (ROADMAP_WARNING, "navigate_update_position return samepos"); return; } @@ -502,28 +508,31 @@ #endif /* If we find that we need to re-evaluate the route, set this to 1 */ - doit = 0; - if (firsttime) - doit = 1; + if (street_has_changed) + need_recalc = 1; + /* If the current line is outside the current route ... */ + if (line && ! navigate_line_in_route (&status, line->line_id)) + need_recalc = 1; - if (line && ! navigate_line_in_route (&status, line->line_id)) { - navigate_recalc_route(); + /* Recalculate the route under conditions determined above */ + roadmap_log (ROADMAP_WARNING, "navigate_update_position recalc %d", need_recalc); + if (need_recalc) { + r = navigate_recalc_route(); } oldpos = *position; old = cur; - firsttime = 0; } +#if 0 /** * @brief * @param current * @param direction * @param next */ -void navigate_get_next_line (PluginLine *current, int direction, PluginLine *next) +static void navigate_get_next_line (PluginLine *current, int direction, PluginLine *next) { -#if 0 int new_instruction = 0; if (!NavigateTrackEnabled) { @@ -636,8 +645,8 @@ } return; +} #endif -} /** * @brief @@ -705,7 +714,9 @@ /* Initialize the algorithms */ navigate_simple_initialize (); +#ifdef ROADMAP_NAVIGATE_SHOOTINGSTAR navigate_shst_initialize (); +#endif navigate_set (1); @@ -752,7 +763,7 @@ int flags; NavigateIteration *p; - const char *focus = roadmap_trip_get_focus_name (); + // const char *focus = roadmap_trip_get_focus_name (); if (!(fp = roadmap_trip_get_position ("Departure"))) { roadmap_log (ROADMAP_DEBUG, "navigate_calc_route: no departure"); @@ -777,8 +788,10 @@ status = navigate_route_get_initial (&from_line, from_pos, &NavigateDestination, NavigateDestPos); - roadmap_log(ROADMAP_DEBUG, "navigate_calc_route: time %d", track_time); + track_time = status.last->cost.time; + roadmap_log(ROADMAP_WARNING, "navigate_calc_route: time %d", track_time); + if (status.current == 0 || status.current->cost.distance <= 0) { roadmap_dialog_hide ("Route calc"); NavigateTrackEnabled = 0; @@ -966,10 +979,10 @@ } /** - * @brief - * @param stp - * @param line - * @return + * @brief figure out whether the line passed is on the route + * @param stp current navigation status (= list of lines) + * @param line a line identifier + * @return 1 if the line is on this route, 0 if not */ int navigate_line_in_route (NavigateStatus *stp, int line) { Modified: trunk/roadmap/src/navigate/navigate.h =================================================================== --- trunk/roadmap/src/navigate/navigate.h 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/navigate/navigate.h 2011-02-13 14:01:31 UTC (rev 2662) @@ -146,4 +146,6 @@ void navigate_update_position (const RoadMapPosition *, const PluginLine *, const PluginStreet *, const int); // plugin_update_position navigate_update_position; +int navigate_line_in_route (NavigateStatus *stp, int line); + #endif /* INCLUDE__NAVIGATE_H */ Modified: trunk/roadmap/src/navigate/navigate_route.c =================================================================== --- trunk/roadmap/src/navigate/navigate_route.c 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/navigate/navigate_route.c 2011-02-13 14:01:31 UTC (rev 2662) @@ -1,7 +1,7 @@ /* * LICENSE: * - * Copyright (c) 2008, 2009 by Danny Backx. + * Copyright (c) 2008, 2009, 2011 by Danny Backx. * * This file is part of RoadMap. * @@ -58,8 +58,15 @@ nAlgorithms++; } +/** + * @brief recalculate the route + * @param stp pointer to current route + * @return 0 for success + */ int navigate_route_recalc (NavigateStatus *stp) { + roadmap_log (ROADMAP_WARNING, "navigate_route_recalc"); + return 0; } /** @@ -83,6 +90,8 @@ NavigateIteration *p; NavigateStatus status, rev; + roadmap_log (ROADMAP_WARNING, "navigate_route_get_initial"); + if (! Algo) return (NavigateStatus) {NULL, NULL, NULL, 0, 0}; @@ -143,6 +152,8 @@ if (! ok) roadmap_log (ROADMAP_WARNING, "Max #iterations reached (%d).", Algo->max_iterations); + else + roadmap_log (ROADMAP_WARNING, "navigate_route_get_initial, %d iterations", status.iteration); return status; } Modified: trunk/roadmap/src/navigate/navigate_simple.h =================================================================== --- trunk/roadmap/src/navigate/navigate_simple.h 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/navigate/navigate_simple.h 2011-02-13 14:01:31 UTC (rev 2662) @@ -1,7 +1,7 @@ /* * LICENSE: * - * Copyright (c) 2008, 2009, Danny Backx + * Copyright (c) 2008, 2009, 2011, Danny Backx * * This file is part of RoadMap. * @@ -33,6 +33,8 @@ #define GRAPH_IGNORE_TURNS 1 +void navigate_simple_initialize(void); + int navigate_simple_get_segments (PluginLine *from_line, RoadMapPosition from_pos, PluginLine *to_line, Modified: trunk/roadmap/src/roadmap_layer.c =================================================================== --- trunk/roadmap/src/roadmap_layer.c 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/roadmap_layer.c 2011-02-13 14:01:31 UTC (rev 2662) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2003 Pascal F. Martin - * Copyright (c) 2008, 2009, 2010, Danny Backx. + * Copyright (c) 2008, 2009, 2010, 2011, Danny Backx. * * This file is part of RoadMap. * @@ -719,7 +719,7 @@ const char *class_config = roadmap_config_new (class_file, 0); const char *class_name; - roadmap_log (ROADMAP_WARNING, "roadmap_layer_load_file(%s)", class_file); + roadmap_log (ROADMAP_DEBUG, "roadmap_layer_load_file(%s)", class_file); if (class_config == NULL) { roadmap_log (ROADMAP_FATAL, "cannot access class file %s", class_file); } @@ -769,7 +769,7 @@ ((polygons_count + lines_count) * sizeof(RoadMapLayer)), 1); roadmap_check_allocated(new_class); - roadmap_log (ROADMAP_WARNING, "Class [%s] lines %d polygons %d", + roadmap_log (ROADMAP_DEBUG, "Class [%s] lines %d polygons %d", class_name, lines_count, polygons_count); new_class->name = class_name; @@ -929,7 +929,7 @@ RoadMapNavigationMode, ROADMAP_MAX_NAVIGATION_MODES); if (RoadMapNavigationModeCount <= 0) return; - roadmap_log (ROADMAP_WARNING, "RoadMapNavigationModeCount %d", RoadMapNavigationModeCount); + roadmap_log (ROADMAP_DEBUG, "RoadMapNavigationModeCount %d", RoadMapNavigationModeCount); for (i = 0; i < (int)RoadMapNavigationModeCount; ++i) { @@ -943,7 +943,7 @@ "Navigation", RoadMapNavigationMode[i], navigation_layers, ROADMAP_MAX_LAYERS); - roadmap_log (ROADMAP_WARNING, "Navigation %d [%s] -> %d modes", + roadmap_log (ROADMAP_DEBUG, "Navigation %d [%s] -> %d modes", i, RoadMapNavigationMode[i], layers_count); for (j = layers_count - 1; j >= 0; --j) { Modified: trunk/roadmap/src/roadmap_plugin.c =================================================================== --- trunk/roadmap/src/roadmap_plugin.c 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/roadmap_plugin.c 2011-02-13 14:01:31 UTC (rev 2662) @@ -79,7 +79,7 @@ int i; - roadmap_log(ROADMAP_WARNING, "roadmap_plugin_register(%s)", hook->name); + roadmap_log(ROADMAP_DEBUG, "roadmap_plugin_register(%s)", hook->name); if (PluginCount == 0) { for (i=1; i<MAX_PLUGINS; i++) { hooks[i].initialized = 0; Modified: trunk/roadmap/src/roadmap_trip.c =================================================================== --- trunk/roadmap/src/roadmap_trip.c 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/roadmap_trip.c 2011-02-13 14:01:31 UTC (rev 2662) @@ -3719,7 +3719,7 @@ * @param name name of a position (Departure, GPS, Destination, ..) * @return the position requested */ -const RoadMapPosition *roadmap_trip_get_position (const char *name) +/* const */ RoadMapPosition *roadmap_trip_get_position (const char *name) { int i; RoadMapConfigDescriptor *fp; Modified: trunk/roadmap/src/roadmap_trip.h =================================================================== --- trunk/roadmap/src/roadmap_trip.h 2011-02-13 10:49:15 UTC (rev 2661) +++ trunk/roadmap/src/roadmap_trip.h 2011-02-13 14:01:31 UTC (rev 2662) @@ -3,7 +3,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin - * Copyright 2011 Danny Backx + * Copyright (c) 2011 Danny Backx * * This file is part of RoadMap. * @@ -152,4 +152,6 @@ void roadmap_trip_departure_waypoint(void); void roadmap_trip_destination_waypoint(void); + +RoadMapPosition *roadmap_trip_get_position (const char *name); #endif // INCLUDE__ROADMAP_TRIP__H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-13 10:49:22
|
Revision: 2661 http://roadmap.svn.sourceforge.net/roadmap/?rev=2661&view=rev Author: dannybackx Date: 2011-02-13 10:49:15 +0000 (Sun, 13 Feb 2011) Log Message: ----------- Remove logging that slipped in Modified Paths: -------------- trunk/roadmap/src/unix/roadmap_path.c Modified: trunk/roadmap/src/unix/roadmap_path.c =================================================================== --- trunk/roadmap/src/unix/roadmap_path.c 2011-02-13 10:29:27 UTC (rev 2660) +++ trunk/roadmap/src/unix/roadmap_path.c 2011-02-13 10:49:15 UTC (rev 2661) @@ -2,7 +2,7 @@ * LICENSE: * * Copyright 2002 Pascal F. Martin - * Copyright (c) 2008, 2010, Danny Backx. + * Copyright (c) 2008, 2010, 2011, Danny Backx. * * This file is part of RoadMap. * @@ -744,11 +744,9 @@ if (! strcmp (match, extension)) { *(cursor++) = strdup (entry->d_name); - roadmap_log (ROADMAP_WARNING, "--> %s", entry->d_name); } } else { *(cursor++) = strdup (entry->d_name); - roadmap_log (ROADMAP_WARNING, "--> %s", entry->d_name); } } *cursor = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-13 10:29:34
|
Revision: 2660 http://roadmap.svn.sourceforge.net/roadmap/?rev=2660&view=rev Author: dannybackx Date: 2011-02-13 10:29:27 +0000 (Sun, 13 Feb 2011) Log Message: ----------- Nobody's looking at this (the navigate plugin) yet so I'll sync my drive with SVN. Modified Paths: -------------- trunk/roadmap/src/navigate/navigate.c trunk/roadmap/src/navigate/navigate.h trunk/roadmap/src/navigate/navigate_bar.c trunk/roadmap/src/navigate/navigate_cost.c trunk/roadmap/src/navigate/navigate_cost.h trunk/roadmap/src/navigate/navigate_instr.c trunk/roadmap/src/navigate/navigate_plugin.c trunk/roadmap/src/navigate/navigate_plugin.h trunk/roadmap/src/navigate/navigate_route.c trunk/roadmap/src/navigate/navigate_route.h trunk/roadmap/src/navigate/navigate_simple.c trunk/roadmap/src/navigate/navigate_simple.h Modified: trunk/roadmap/src/navigate/navigate.c =================================================================== --- trunk/roadmap/src/navigate/navigate.c 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate.c 2011-02-13 10:29:27 UTC (rev 2660) @@ -24,6 +24,7 @@ /** * @file * @brief Navigate plugin, main plugin file + * @ingroup NavigatePlugin */ /** @@ -113,11 +114,23 @@ static int NavigateNextAnnounce; /** + * @brief new style structure for navigation info + */ +NavigateStatus status; + +/** * @brief * @return */ static int navigate_recalc_route () { + int r; + + roadmap_log (ROADMAP_DEBUG, "navigate_recalc_route"); + + r = navigate_route_recalc (&status); + + return r; #if 0 int track_time; PluginLine from_line; @@ -427,11 +440,82 @@ return; counter = 0; - roadmap_log (ROADMAP_WARNING, "navigate_format_messages -> navigate_update(NULL, NULL);"); +// roadmap_log (ROADMAP_WARNING, "navigate_format_messages -> navigate_update(NULL, NULL);"); navigate_update(NULL, NULL); } /** + * @brief gets a GPS position update + * @param position + */ +#define HYST 15 +void navigate_update_position (const RoadMapPosition *position, + const PluginLine *line, const PluginStreet *street, + const int street_has_changed) +{ + static RoadMapPosition oldpos; + static RoadMapPosition old, cur; + int x, y; + static int firsttime = 1; + int doit; + static int skip = 0; /**< count #times < HYST */ + + if (position == 0) + return; + + if (firsttime) { + roadmap_log (ROADMAP_WARNING, "navigate_update_position(%d %d) initial", + position->longitude, position->latitude); + } + + if (position->longitude == oldpos.longitude && position->latitude == oldpos.latitude) { + firsttime = 0; + return; + } + + cur = *position; + +#if 0 + if (roadmap_math_distance(&cur, &old) < HYST) { + firsttime = 0; + skip++; + return; + } + + roadmap_log (ROADMAP_WARNING, + "navigate_update_position(%d %d), line %d, street %d, changed %d, skip %d", + position->longitude, position->latitude, + line ? line->line_id : 0, + street ? street->street_id : 0, + street_has_changed, skip); + skip = 0; + +#else + firsttime = 0; + + roadmap_log (ROADMAP_WARNING, + "navigate_update_position(%d %d), line %d, street %d, changed %d", + position->longitude, position->latitude, + line ? line->line_id : 0, + street ? street->street_id : 0, + street_has_changed); +#endif + + /* If we find that we need to re-evaluate the route, set this to 1 */ + doit = 0; + if (firsttime) + doit = 1; + + if (line && ! navigate_line_in_route (&status, line->line_id)) { + navigate_recalc_route(); + } + + oldpos = *position; + old = cur; + firsttime = 0; +} + +/** * @brief * @param current * @param direction @@ -618,7 +702,10 @@ navigate_cost_initialize (); navigate_bar_initialize (); navigate_visual_initialize (); + + /* Initialize the algorithms */ navigate_simple_initialize (); + navigate_shst_initialize (); navigate_set (1); @@ -663,7 +750,6 @@ PluginLine from_line; RoadMapPosition from_pos, *fp, *dp; int flags; - NavigateStatus status; NavigateIteration *p; const char *focus = roadmap_trip_get_focus_name (); @@ -867,8 +953,8 @@ } /** - * @brief - * @param + * @brief Update the progress indicator + * @param progress */ void navigate_update_progress (int progress) { @@ -879,3 +965,20 @@ roadmap_main_flush (); } +/** + * @brief + * @param stp + * @param line + * @return + */ +int navigate_line_in_route (NavigateStatus *stp, int line) +{ + NavigateIteration *p; + + for (p=stp->first; p; p = p->next) { + if (line == p->segment->line.line_id) + return 1; + } + + return 0; +} Modified: trunk/roadmap/src/navigate/navigate.h =================================================================== --- trunk/roadmap/src/navigate/navigate.h 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate.h 2011-02-13 10:29:27 UTC (rev 2660) @@ -24,6 +24,7 @@ /** * @file * @brief navigate.h - main plugin file + * @ingroup NavigatePlugin */ #ifndef INCLUDE__NAVIGATE_H @@ -142,4 +143,7 @@ void navigate_adjust_layer (int layer, int thickness, int pen_count); void navigate_format_messages (void); +void navigate_update_position (const RoadMapPosition *, + const PluginLine *, const PluginStreet *, const int); +// plugin_update_position navigate_update_position; #endif /* INCLUDE__NAVIGATE_H */ Modified: trunk/roadmap/src/navigate/navigate_bar.c =================================================================== --- trunk/roadmap/src/navigate/navigate_bar.c 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_bar.c 2011-02-13 10:29:27 UTC (rev 2660) @@ -24,6 +24,7 @@ /** * @file * @brief implement navigation bar + * @ingroup NavigatePlugin */ #include <stdlib.h> Modified: trunk/roadmap/src/navigate/navigate_cost.c =================================================================== --- trunk/roadmap/src/navigate/navigate_cost.c 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_cost.c 2011-02-13 10:29:27 UTC (rev 2660) @@ -24,6 +24,7 @@ /** * @file * @brief cost calculations + * @ingroup NavigatePlugin */ #include <stdio.h> @@ -72,7 +73,7 @@ * @brief determine a penalty for taking some kind of road * @param line_id * @param layer - * @param prev_line_id + * @param prev_line * @return */ static int calc_penalty (int line_id, int layer, int prev_line) Modified: trunk/roadmap/src/navigate/navigate_cost.h =================================================================== --- trunk/roadmap/src/navigate/navigate_cost.h 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_cost.h 2011-02-13 10:29:27 UTC (rev 2660) @@ -23,6 +23,7 @@ /** * @file * @brief navigate_cost.h - generic navigate cost functions + * @ingroup NavigatePlugin */ #ifndef _NAVIGATE_COST_H_ Modified: trunk/roadmap/src/navigate/navigate_instr.c =================================================================== --- trunk/roadmap/src/navigate/navigate_instr.c 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_instr.c 2011-02-13 10:29:27 UTC (rev 2660) @@ -25,6 +25,7 @@ /** * @file * @brief calculate navigation instructions + * @ingroup NavigatePlugin */ #include <stdlib.h> Modified: trunk/roadmap/src/navigate/navigate_plugin.c =================================================================== --- trunk/roadmap/src/navigate/navigate_plugin.c 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_plugin.c 2011-02-13 10:29:27 UTC (rev 2660) @@ -24,6 +24,7 @@ /** * @file * @brief implement plugin interfaces + * @ingroup NavigatePlugin */ #include <stdlib.h> @@ -126,14 +127,19 @@ {"navigate", "Navigate", NULL, NULL, "Calculate route", NULL, navigate_start_navigate}, -#if 0 - {"deletewaypoints", "Delete Waypoints...", "Delete...", NULL, - "Delete selected waypoints", NULL, roadmap_start_delete_waypoint}, -#endif + {"setasdeparture", "Set as Departure", NULL, NULL, "Set the selected street block as the trip's departure", NULL, roadmap_start_set_departure}, + {"departure-waypoint", "Set waypoint as Departure", NULL, NULL, + "Set the selected street block as the trip's departure", NULL, + roadmap_trip_departure_waypoint}, + + {"destination-waypoint", "Set waypoint as Destination", NULL, NULL, + "Set the selected street block as the trip's departure", NULL, + roadmap_trip_destination_waypoint}, + {"traffic", "Routing preferences", NULL, NULL, "Change routing preferences", NULL, navigate_cost_preferences}, @@ -149,14 +155,19 @@ {"navigate-disable", "Disable navigation", NULL, NULL, "Disable navigation", NULL, roadmap_navigate_disable}, + {"navigate-shutdown", "Stop navigation", NULL, NULL, + "Stop navigation", NULL, navigate_shutdown}, + {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }; static const char *NavigateMenu[] = { ROADMAP_MENU "Navigate", // RoadMapFactorySeparator, + "setasdeparture", + "departure-waypoint", "setasdestination", - "setasdeparture", + "destination-waypoint", // "addaswaypoint", cannot be here, is a RoadMap action // "deletewaypoints", "navigate-be-debug", @@ -166,6 +177,7 @@ "traffic", "navigate-enable", "navigate-disable", + "navigate-shutdown", NULL }; @@ -204,7 +216,8 @@ /* after_refresh */ &navigate_bar_after_refresh, /* format messages */ &navigate_format_messages, /* route_clear */ navigate_visual_route_clear, - /* route_add */ navigate_visual_route_add + /* route_add */ navigate_visual_route_add, + /* update_position */ navigate_update_position }; /** Modified: trunk/roadmap/src/navigate/navigate_plugin.h =================================================================== --- trunk/roadmap/src/navigate/navigate_plugin.h 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_plugin.h 2011-02-13 10:29:27 UTC (rev 2660) @@ -1,9 +1,8 @@ -/** - * @file navigate_plugin.h - Editor plugin interfaces - * +/* * LICENSE: * * Copyright 2005 Ehud Shabtai + * Copyright (c) 2009, 2011 Danny Backx * * This file is part of RoadMap. * @@ -22,6 +21,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/** + * @file + * @brief navigate_plugin.h - Editor plugin interfaces + * @ingroup NavigatePlugin + */ + #ifndef INCLUDE__NAVIGATE_PLUGIN__H #define INCLUDE__NAVIGATE_PLUGIN__H Modified: trunk/roadmap/src/navigate/navigate_route.c =================================================================== --- trunk/roadmap/src/navigate/navigate_route.c 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_route.c 2011-02-13 10:29:27 UTC (rev 2660) @@ -23,6 +23,7 @@ /** * @file * @brief entry points for route calculation, to become a user centric plugin mechanism + * @ingroup NavigatePlugin */ #include <stdio.h> @@ -39,6 +40,8 @@ #include "navigate_route.h" static NavigateAlgorithm *Algo = NULL; +static int nAlgorithms = 0; +static int alloc = 0; /** * @brief register an algorithm @@ -46,9 +49,19 @@ */ void navigate_algorithm_register(NavigateAlgorithm *algo) { - Algo = algo; + if (nAlgorithms == alloc) { + alloc += 4; + Algo = (NavigateAlgorithm *)realloc((void *)Algo, + sizeof(NavigateAlgorithm) * alloc); + } + Algo[nAlgorithms] = *algo; + nAlgorithms++; } +int navigate_route_recalc (NavigateStatus *stp) +{ +} + /** * @brief calculate the basic route. * @@ -59,27 +72,14 @@ * @param from_pos * @param to_line * @param to_pos - * @param segments - * @param size - * @param flags either NEW_ROUTE or RECALC_ROUTE * @return track time */ -#if 0 -int navigate_route_get_segments (PluginLine *from_line, - RoadMapPosition from_pos, - PluginLine *to_line, - RoadMapPosition to_pos, - NavigateSegment *segments, - int *size, - int *flags) -#else NavigateStatus navigate_route_get_initial (PluginLine *from_line, RoadMapPosition from_pos, PluginLine *to_line, RoadMapPosition to_pos) -#endif { - int i; + int i, ok; NavigateIteration *p; NavigateStatus status, rev; @@ -124,19 +124,25 @@ rev.last = status.first; status.iteration = 1; + ok = 0; while (status.iteration <= Algo->max_iterations) { Algo->step_fn(Algo, &status); if (Algo->end_fn(&status)) { + ok = 1; break; } if (Algo->both_ways) { Algo->step_fn(Algo, &rev); if (Algo->end_fn(&status)) { + ok = 1; break; } } status.iteration++; } + if (! ok) + roadmap_log (ROADMAP_WARNING, "Max #iterations reached (%d).", + Algo->max_iterations); return status; } Modified: trunk/roadmap/src/navigate/navigate_route.h =================================================================== --- trunk/roadmap/src/navigate/navigate_route.h 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_route.h 2011-02-13 10:29:27 UTC (rev 2660) @@ -25,6 +25,7 @@ /** * @file * @brief navigate_route.h - generic navigate functions + * @ingroup NavigatePlugin */ #ifndef _NAVIGATE_ROUTE_H_ @@ -53,5 +54,7 @@ PluginLine *to_line, RoadMapPosition to_pos); +int navigate_route_recalc (NavigateStatus *); + #endif /* _NAVIGATE_ROUTE_H_ */ Modified: trunk/roadmap/src/navigate/navigate_simple.c =================================================================== --- trunk/roadmap/src/navigate/navigate_simple.c 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_simple.c 2011-02-13 10:29:27 UTC (rev 2660) @@ -22,6 +22,7 @@ /** * @file * @brief simple (shortest path) route calculation + * @ingroup NavigatePlugin */ #include <stdio.h> @@ -121,29 +122,32 @@ */ static int navigate_simple_algo_cost(NavigateIteration *iter) { - int cost; - if (iter == 0) return 0; if (iter->segment == 0) return 0; - cost = navigate_cost_time(iter->next->segment->line.line_id, + + iter->next->segment->time = navigate_cost_time(iter->next->segment->line.line_id, iter->next->segment->line_direction, iter->segment->time, iter->segment->line.line_id, iter->segment->line_direction); - iter->next->segment->time = cost; // iter->next->segment->heuristic = iter->next->segment->dist_from_destination; - iter->next->segment->heuristic = - iter->next->segment->dist_from_destination - + iter->next->segment->time; + +#if 1 + iter->next->segment->heuristic = iter->next->segment->dist_from_destination + iter->next->segment->time; +#endif +#if 0 + iter->next->segment->heuristic = iter->next->segment->dist_from_destination; +#endif + roadmap_log (ROADMAP_DEBUG, "navigate_simple_algo_cost(cost %d, dist_from_dest %d) -> %d", - cost, + iter->next->segment->time, iter->next->segment->dist_from_destination, iter->next->segment->heuristic); - return cost; + return iter->next->segment->time; } /** @@ -230,6 +234,7 @@ continue; } +#if 0 /* Oneway street ? */ if (roadmap_line_get_oneway(lines[i].line_id) == ROADMAP_LINE_DIRECTION_ONEWAY) { roadmap_log (ROADMAP_WARNING, "Not taking oneway street %d (%s)", @@ -249,7 +254,7 @@ stp->current->segment->line.line_id); continue; } - +#endif stp->current->next->segment->line = lines[i]; newpt2 = roadmap_line_from_point(lines[i].line_id); if (point == newpt2) { @@ -404,7 +409,7 @@ NavigateAlgorithm SimpleAlgo = { "Simple navigation", /**< name of this algorithm */ 0, /**< cannot go both ways */ - 500, /**< max #iterations */ + 1000, /**< max #iterations */ navigate_simple_algo_cost, /**< cost function */ navigate_simple_algo_step, /**< step function */ navigate_simple_algo_end /**< end function */ Modified: trunk/roadmap/src/navigate/navigate_simple.h =================================================================== --- trunk/roadmap/src/navigate/navigate_simple.h 2011-02-13 10:23:36 UTC (rev 2659) +++ trunk/roadmap/src/navigate/navigate_simple.h 2011-02-13 10:29:27 UTC (rev 2660) @@ -23,6 +23,7 @@ /** * @file * @brief API of the "simple" route calculation + * @ingroup NavigatePlugin */ #ifndef _NAVIGATE_SIMPLE_H_ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2011-02-13 10:23:43
|
Revision: 2659 http://roadmap.svn.sourceforge.net/roadmap/?rev=2659&view=rev Author: dannybackx Date: 2011-02-13 10:23:36 +0000 (Sun, 13 Feb 2011) Log Message: ----------- Mostly typos in comments that doxygen warns about Modified Paths: -------------- trunk/roadmap/src/android/roadmap_dialog.c trunk/roadmap/src/android/roadmap_messagebox.c trunk/roadmap/src/buildmap_dbwrite.c trunk/roadmap/src/buildmap_opt.c trunk/roadmap/src/buildmap_point.c trunk/roadmap/src/roadmap.doxy trunk/roadmap/src/roadmap_config.c trunk/roadmap/src/roadmap_line.c Modified: trunk/roadmap/src/android/roadmap_dialog.c =================================================================== --- trunk/roadmap/src/android/roadmap_dialog.c 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/android/roadmap_dialog.c 2011-02-13 10:23:36 UTC (rev 2659) @@ -715,7 +715,7 @@ * @brief Store some data. See notes below. * @param frame used to determine the dialog * @param name used to determine the dialog - * @param pointer to the data passed back + * @param data pointer to the data passed back * * Note the data is sent to the user interface only if the widget is ROADMAP_WIDGET_ENTRY or * ROADMAP_WIDGET_LABEL. In those cases we know it's string data. Modified: trunk/roadmap/src/android/roadmap_messagebox.c =================================================================== --- trunk/roadmap/src/android/roadmap_messagebox.c 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/android/roadmap_messagebox.c 2011-02-13 10:23:36 UTC (rev 2659) @@ -22,8 +22,8 @@ */ /** - * @brief - * @file manage the roadmap dialogs used for user info. + * @file + * @brief manage the roadmap dialogs used for user info. */ #include <stdlib.h> Modified: trunk/roadmap/src/buildmap_dbwrite.c =================================================================== --- trunk/roadmap/src/buildmap_dbwrite.c 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/buildmap_dbwrite.c 2011-02-13 10:23:36 UTC (rev 2659) @@ -201,7 +201,7 @@ } /** - * @bref remove the output file, it is bad + * @brief remove the output file, it is bad * @param path * @param name */ Modified: trunk/roadmap/src/buildmap_opt.c =================================================================== --- trunk/roadmap/src/buildmap_opt.c 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/buildmap_opt.c 2011-02-13 10:23:36 UTC (rev 2659) @@ -136,10 +136,8 @@ } /** - * Retrieve the value of an option. - * @param opts internal state + * @brief Retrieve the value of an option. * @param opt option to retrieve value for - * @param fmt format of returned option (currently "int" or "str") * @param val pointer to variable of correct type to hold value * @return Zero on success, non-zero on error. * @@ -311,9 +309,9 @@ } /** - * Parse argv and extract options. + * @brief Parse argv and extract options. * - * @param opts pointer to structure to populate with options + * @param options pointer to structure to populate with options * @param argc number of elements in argv -- changes on return * @param argv argv array as passed to main() -- changes on return * @param mixed can options and positional arguments be intermixed? Modified: trunk/roadmap/src/buildmap_point.c =================================================================== --- trunk/roadmap/src/buildmap_point.c 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/buildmap_point.c 2011-02-13 10:23:36 UTC (rev 2659) @@ -154,8 +154,8 @@ /** * @brief get the id of a point - * @param point the point to query - * @return id + * @param pointid the id of the point to query + * @return */ static BuildMapPoint *buildmap_point_get (int pointid) { @@ -172,7 +172,7 @@ /** * @brief get the square of a point - * @param point the point to query + * @param pointid the point to query * @return square */ int buildmap_point_get_square (int pointid) { @@ -182,7 +182,7 @@ /** * @brief get the longitude of a point - * @param point the point to query + * @param pointid the point to query * @return longitude */ int buildmap_point_get_longitude (int pointid) { @@ -192,7 +192,7 @@ /** * @brief get the latitude of a point - * @param point the point to query + * @param pointid the point to query * @return latitude */ int buildmap_point_get_latitude (int pointid) { @@ -202,8 +202,8 @@ /** * @brief get the id of a point - * @param point the point to query - * @return id + * @param pointid the point to query + * @return */ int buildmap_point_get_sorted (int pointid) { @@ -217,7 +217,7 @@ /** * @brief get the square of a sorted point * @param point the point to query - * @return square + * @return */ int buildmap_point_get_square_sorted (int point) { Modified: trunk/roadmap/src/roadmap.doxy =================================================================== --- trunk/roadmap/src/roadmap.doxy 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/roadmap.doxy 2011-02-13 10:23:36 UTC (rev 2659) @@ -159,7 +159,7 @@ # If set to NO, the detailed description appears after the member # documentation. -DETAILS_AT_TOP = NO +# DETAILS_AT_TOP = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it Modified: trunk/roadmap/src/roadmap_config.c =================================================================== --- trunk/roadmap/src/roadmap_config.c 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/roadmap_config.c 2011-02-13 10:23:36 UTC (rev 2659) @@ -823,7 +823,7 @@ /** * @brief get the value from a configuration item - * @param pointer to the descriptor + * @param descriptor pointer to the descriptor * @return the value */ int roadmap_config_get_integer(RoadMapConfigDescriptor *descriptor) { @@ -1005,7 +1005,7 @@ /** * @brief reload a part of the configuration - * @param s names the configuration to be reloaded + * @param name names the configuration to be reloaded */ void roadmap_config_reload(const char *name) { Modified: trunk/roadmap/src/roadmap_line.c =================================================================== --- trunk/roadmap/src/roadmap_line.c 2011-02-13 09:54:34 UTC (rev 2658) +++ trunk/roadmap/src/roadmap_line.c 2011-02-13 10:23:36 UTC (rev 2659) @@ -472,7 +472,7 @@ /** * @brief determine the layer that some line is in - * @param line_id the line whose layer we want to query + * @param line the line whose layer we want to query * @return the layer */ int roadmap_line_get_layer (int line) @@ -498,7 +498,7 @@ /** * @brief determine the layer that some line is in - * @param line_id the line whose layer we want to query + * @param line the line whose layer we want to query * @return the layer */ int roadmap_line_get_oneway (int line) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |