You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reverse_route.cc 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. Route reversal filter.
  3. Copyright (C) 2003 Robert Lipe, robertlipe+source@gpsbabel.org
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
  15. */
  16. #include "defs.h"
  17. #include "filterdefs.h"
  18. #if FILTERS_ENABLED
  19. #define MYNAME "Route reversal filter"
  20. static int prev_new_trkseg;
  21. static
  22. arglist_t reverse_route_args[] = {
  23. ARG_TERMINATOR
  24. };
  25. /*
  26. * reverse_route_wpt fixes up the waypoint flag new_trkseg
  27. */
  28. static void reverse_route_wpt(const Waypoint* waypointp)
  29. {
  30. /* Cast away const-ness */
  31. Waypoint* wpp = (Waypoint*) waypointp;
  32. int curr_new_trkseg;
  33. curr_new_trkseg = waypointp->wpt_flags.new_trkseg;
  34. wpp->wpt_flags.new_trkseg = prev_new_trkseg;
  35. prev_new_trkseg = curr_new_trkseg;
  36. }
  37. void
  38. reverse_route_head(const route_head* rte)
  39. {
  40. route_reverse(rte);
  41. prev_new_trkseg = 1;
  42. }
  43. void
  44. reverse_route_process(void)
  45. {
  46. track_disp_all(reverse_route_head, NULL, reverse_route_wpt);
  47. route_disp_all(reverse_route_head, NULL, NULL);
  48. }
  49. void
  50. reverse_route_init(const char* args)
  51. {
  52. switch (global_opts.objective) {
  53. case rtedata:
  54. break;
  55. case trkdata:
  56. break;
  57. default:
  58. fatal(MYNAME ": This filter only works in track "
  59. "or route (-t or -r) mode.\n");
  60. }
  61. }
  62. void
  63. reverse_route_deinit(void)
  64. {
  65. /* do nothing */
  66. }
  67. filter_vecs_t reverse_route_vecs = {
  68. reverse_route_init,
  69. reverse_route_process,
  70. reverse_route_deinit,
  71. NULL,
  72. reverse_route_args
  73. };
  74. #endif