00001 #ifndef CAJUN_RNDF_PRINTER_H
00002 #define CAJUN_RNDF_PRINTER_H
00003
00004
00005
00006
00007 #include "rndf.H"
00008
00009
00010 #include <string>
00011 #include <cmath>
00012 #include <iostream>
00013 #include <iomanip>
00014
00015 #define R2D 180/M_PI
00016 #define D2R (M_PI / 180)
00017 #define M2F 3.2808399
00018
00019 namespace cajun
00020 {
00021 static char const *boundary_str[5] =
00022 {
00023 "double_yellow",
00024 "solid_yellow",
00025 "solid_white",
00026 "broken_white",
00027 NULL
00028 };
00029
00030
00031
00032
00033
00034
00035 class rndf_printer_t
00036 {
00037 public:
00038 void rndf_name () const
00039 { std::cout << "RNDF_name\t" << m_rndf.name () << "\n"; }
00040 void num_segments () const
00041 { std::cout << "num_segments\t" << m_rndf.num_segments () << "\n"; }
00042 void num_zones () const
00043 { std::cout << "num_zones\t" << m_rndf.num_zones () << "\n"; }
00044 void format_version () const
00045 { std::cout << "format_version\t" << m_rndf.format_version () << "\n"; }
00046 void creation_date () const
00047 { std::cout << "creation_date\t" << m_rndf.creation_date () << "\n"; }
00048 void end_file () const
00049 { std::cout << "end_file\n"; }
00050
00051 void segment (unsigned num_) const
00052 { std::cout << "segment\t" <<num_ << "\n"; }
00053 void segment_num_lanes (unsigned num_) const
00054 { std::cout << "num_lanes\t" <<
00055 m_rndf.segment (num_).num_lanes () << "\n"; }
00056 void segment_name (unsigned num_) const
00057 { std::cout << "segment_name\t" << m_rndf.segment (num_).name () << "\n"; }
00058 void end_segment () const
00059 { std::cout << "end_segment\n"; }
00060
00061 void lane (unsigned id0_, unsigned id1_) const
00062 { std::cout << "lane\t" << id0_ << "." << id1_ << "\n"; }
00063 void lane_num_waypoints (unsigned id0_, unsigned id1_) const
00064 { std::cout << "num_waypoints\t" << m_rndf.segment (id0_).
00065 lane (id1_).num_waypoints () << "\n"; }
00066 void lane_width (unsigned id0_, unsigned id1_) const
00067 {
00068 if (m_rndf.segment (id0_).lane (id1_).width () != 0.0)
00069 std::cout << "lane_width\t" <<
00070 int(m_rndf.segment (id0_).lane (id1_).width ()
00071 * M2F) << "\n";
00072 }
00073 void lane_boundary (unsigned id0_, unsigned id1_) const
00074 {
00075
00076
00077
00078
00079 unsigned left_bound = m_rndf.segment (id0_).lane (id1_).boundary (
00080 rndf_t::lane_t::side_t (0));
00081 unsigned right_bound = m_rndf.segment (id0_).lane (id1_).boundary (
00082 rndf_t::lane_t::side_t (1));
00083
00084 if (boundary_str[left_bound] != NULL)
00085 std::cout << "left_boundary\t" << boundary_str [left_bound]
00086 << "\n";
00087 if (boundary_str[right_bound] != NULL)
00088 std::cout << "right_boundary\t" << boundary_str[right_bound]
00089 << "\n";
00090
00091 }
00092 void lane_checkpoint (unsigned id0_, unsigned id1_, unsigned num_) const
00093 {
00094 rndf_t::waypoint_id_t waypt_id = m_rndf.segment (id0_).
00095 lane (id1_).checkpoint (num_).id ();
00096 std::cout << "checkpoint\t"
00097 << waypt_id[0] << "." << waypt_id[1] << "." << waypt_id[2]
00098 << "\t" << m_rndf.segment (id0_).lane (id1_).checkpoint
00099 (num_).checkpoint_id () << "\n";
00100 }
00101 void lane_exit (unsigned id0_, unsigned id1_, unsigned num_) const
00102 {
00103 rndf_t::waypoint_t exit = m_rndf.
00104 segment (id0_).lane (id1_).exit (num_);
00105 rndf_t::waypoint_id_t exit_id = m_rndf.
00106 segment (id0_).lane (id1_).exit (num_).id ();
00107
00108 for (unsigned e = 0; e < exit.num_exits (); ++e)
00109 {
00110 rndf_t::waypoint_id_t entry_id = exit.exit (e).id ();
00111 std::cout << "exit\t" << exit_id[0] << "." <<
00112 exit_id[1] << "." << exit_id[2] << "\t" <<
00113 entry_id[0] << "." << entry_id[1] << "." <<
00114 entry_id[2] << "\n";
00115 }
00116 }
00117 void lane_waypt (unsigned id0_, unsigned id1_, unsigned id2_) const
00118 {
00119 rndf_t::waypoint_id_t waypt_id = m_rndf.segment (id0_).
00120 lane (id1_).waypoint (id2_).id ();
00121 rndf_t::waypoint_t waypt = m_rndf.segment (id0_).
00122 lane (id1_).waypoint (id2_);
00123 std::cout.setf (std::ios::fixed);
00124 std::cout
00125 << waypt_id[0] << "." << waypt_id[1] << "." << waypt_id[2]
00126 << "\t" << std::setprecision (6) << waypt.lat () * R2D
00127 << "\t" << std::setprecision (6) << waypt.lon () * R2D
00128 << "\n";
00129 }
00130 void lane_stop (unsigned id0_, unsigned id1_, unsigned num_) const
00131 {
00132 rndf_t::waypoint_id_t waypt_id =
00133 m_rndf.segment (id0_).lane (id1_).stop (num_).id ();
00134 std::cout << "stop\t" << waypt_id[0] << "."
00135 << waypt_id[1] << "." << waypt_id[2] << "\n";
00136 }
00137 void end_lane () const
00138 { std::cout << "end_lane\n"; }
00139
00140
00141 void zone (unsigned num_) const
00142 { std::cout << "zone\t" << num_ << "\n"; }
00143 void zone_num_spots (unsigned num_) const
00144 { std::cout << "num_spots\t" <<
00145 m_rndf.zone (num_).num_spots () << "\n"; }
00146 void zone_name (unsigned num_) const
00147 { std::cout << "zone_name\t" << m_rndf.zone (num_).name ()
00148 << "\n"; }
00149 void end_zone () const { std::cout << "end_zone\n"; }
00150
00151
00152 void perimeter (unsigned zone_num_) const
00153 {
00154 std::cout << "perimeter\t" << zone_num_
00155 << "." << 0 << "\n";
00156 }
00157 void perimeter_num_points (unsigned num_) const
00158 { std::cout << "num_perimeterpoints\t" <<
00159 m_rndf.zone (num_).num_points () << "\n"; }
00160 void perimeter_waypt (unsigned zone_num_, unsigned point_num_) const
00161 {
00162 rndf_t::waypoint_id_t waypt_id = m_rndf.zone (zone_num_).
00163 point (point_num_).id ();
00164 rndf_t::waypoint_t waypt = m_rndf.zone (zone_num_).
00165 point (point_num_);
00166 std::cout.setf (std::ios::fixed);
00167 std::cout
00168 << waypt_id[0] << "." << waypt_id[1] << "." << waypt_id[2]
00169 << "\t" << std::setprecision (6) << waypt.lat () * R2D
00170 << "\t" << std::setprecision (6) << waypt.lon () * R2D
00171 << "\n";
00172 }
00173 void perimeter_exit (unsigned zone_num_, unsigned exit_num_) const
00174 {
00175 rndf_t::waypoint_t exit = m_rndf.
00176 zone (zone_num_).exit (exit_num_);
00177 rndf_t::waypoint_id_t exit_id = m_rndf.
00178 zone (zone_num_).exit (exit_num_).id ();
00179
00180 for (unsigned e = 0; e < exit.num_exits (); ++e)
00181 {
00182 rndf_t::waypoint_id_t entry_id = exit.exit (e).id ();
00183 std::cout << "exit\t" << exit_id[0] << "." <<
00184 exit_id[1] << "." << exit_id[2] << "\t" <<
00185 entry_id[0] << "." << entry_id[1] << "." <<
00186 entry_id[2] << "\n";
00187 }
00188 }
00189 void end_perimeter () const { std::cout << "end_perimeter\n"; }
00190
00191
00192 void spot (unsigned id0_, unsigned id1_) const
00193 {std::cout << "spot\t" << id0_ << "." << id1_ << "\n";}
00194 void spot_width (unsigned id0_, unsigned id1_) const
00195 {
00196 rndf_t::spot_t spot = m_rndf.zone (id0_).spot (id1_);
00197 if (spot.width () != 0.0)
00198 std::cout << "spot_width\t" <<
00199 int(spot.width () * M2F) << "\n";
00200 }
00201 void spot_checkpoint (unsigned id0_, unsigned id1_, unsigned num_) const
00202 {
00203 rndf_t::waypoint_id_t waypt_id =
00204 m_rndf.zone (id0_).spot (id1_).checkpoint (num_).id ();
00205
00206 std::cout << "checkpoint\t"
00207 << waypt_id[0] << "." << waypt_id[1] << "." << waypt_id[2]
00208 << "\t" << m_rndf.zone (id0_).spot (id1_).
00209 checkpoint (num_).checkpoint_id () << "\n";
00210 }
00211 void spot_waypt (unsigned id0_, unsigned id1_, unsigned num_) const
00212 {
00213 rndf_t::waypoint_t waypt =
00214 m_rndf.zone (id0_).spot (id1_).waypoint (num_);
00215 rndf_t::waypoint_id_t waypt_id =
00216 m_rndf.zone (id0_).spot (id1_).waypoint (num_).id ();
00217 std::cout.setf (std::ios::fixed);
00218 std::cout
00219 << waypt_id[0] << "." << waypt_id[1] << "." << waypt_id[2]
00220 << "\t" << std::setprecision (6) << waypt.lat () * R2D
00221 << "\t" << std::setprecision (6) << waypt.lon () * R2D
00222 << "\n";
00223 }
00224 void end_spot () const { std::cout << "end_spot\n"; }
00225
00226 rndf_printer_t (rndf_t &rndf_);
00227 ~rndf_printer_t ();
00228 void print_rndf () const;
00229 private:
00230
00231
00232 rndf_t const &m_rndf;
00233
00234 };
00235 }
00236 #endif