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.

jogmap.cc 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. Support for XML files from jogmap.de
  3. Copyright (C) 2009 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 "garmin_tables.h"
  18. #include "jeeps/gpsmath.h"
  19. #include "xmlgeneric.h"
  20. #include <QtCore/QXmlStreamAttributes>
  21. static route_head* trk;
  22. static arglist_t jogmap_args[] = {
  23. ARG_TERMINATOR
  24. };
  25. #define MYNAME "xol"
  26. // static xg_callback jogmap_shape, xol_shape_end;
  27. // static xg_callback jogmap_waypt, xol_overlay;
  28. #define XOL "/overlays/overlay"
  29. static void
  30. jogmap_markers(xg_string args, const QXmlStreamAttributes* attrv)
  31. {
  32. trk = route_head_alloc();
  33. track_add_head(trk);
  34. }
  35. static void
  36. jogmap_marker(xg_string args, const QXmlStreamAttributes* attrv)
  37. {
  38. Waypoint* wpt = new Waypoint;
  39. if (attrv->hasAttribute("lat")) {
  40. wpt->latitude = attrv->value("lat").toString().toDouble();
  41. }
  42. if (attrv->hasAttribute("lng")) {
  43. wpt->longitude = attrv->value("lng").toString().toDouble();
  44. }
  45. if (trk) {
  46. track_add_wpt(trk, wpt);
  47. }
  48. }
  49. static
  50. xg_tag_mapping jogmap_map[] = {
  51. { jogmap_markers, cb_start, "/markers" },
  52. { jogmap_marker, cb_start, "/markers/marker" },
  53. { NULL, (xg_cb_type)0, NULL }
  54. };
  55. static void
  56. jogmap_rd_init(const QString& fname)
  57. {
  58. trk = NULL;
  59. xml_init(fname, jogmap_map, NULL);
  60. }
  61. static void
  62. jogmap_read(void)
  63. {
  64. xml_read();
  65. }
  66. static void
  67. jogmap_rd_deinit(void)
  68. {
  69. xml_deinit();
  70. }
  71. ff_vecs_t jogmap_vecs = {
  72. ff_type_file,
  73. {
  74. ff_cap_none, /* waypoints */
  75. ff_cap_read, /* tracks */
  76. ff_cap_none
  77. }, /* routes */
  78. jogmap_rd_init,
  79. NULL,
  80. jogmap_rd_deinit,
  81. NULL,
  82. jogmap_read,
  83. NULL,
  84. NULL,
  85. jogmap_args,
  86. CET_CHARSET_UTF8, 0
  87. };