52 inline void PlotCoordinates2D(
const std::vector<geoops::UTMCoordinate>& vCoordinates,
const std::string& szTitle =
"UTMCoordinatePlot")
55 std::string szPlotTitle = szTitle;
56 matplot::figure_handle mtPlot = matplot::figure(
true);
57 matplot::axes_handle mtAxes = mtPlot->current_axes();
60 if (vCoordinates.empty())
63 LOG_WARNING(logging::g_qSharedLogger,
"Coordinates vector is empty. Cannot plot.");
67 if (szPlotTitle.empty())
70 LOG_WARNING(logging::g_qSharedLogger,
"Plot title is empty. Setting title to default.");
71 szPlotTitle =
"UTMCoordinatePlot";
75 std::string szFileName = logging::g_szLoggingOutputPath +
"/path_plots/" + szTitle;
77 while (std::filesystem::exists(szFileName +
".png"))
79 szFileName = szFileName + std::to_string(nFileNum);
84 if (!std::filesystem::exists(logging::g_szLoggingOutputPath +
"/path_plots"))
86 std::filesystem::create_directory(logging::g_szLoggingOutputPath +
"/path_plots");
89 mtPlot->backend()->output(szFileName +
".png");
92 std::vector<double> vEasting, vNorthing;
95 vEasting.push_back(stCoordinate.dEasting);
96 vNorthing.push_back(stCoordinate.dNorthing);
98 mtAxes->plot(vEasting, vNorthing,
"-o");
99 mtPlot->title(szPlotTitle);
100 mtAxes->xlabel(
"Easting");
101 mtAxes->ylabel(
"Northing");
104 mtAxes->xtickangle(45);
105 mtAxes->axis(matplot::square);
106 mtAxes->xtickformat(
"%.0f");
107 mtAxes->ytickformat(
"%.0f");
112 for (
size_t i = 1; i < vCoordinates.size(); ++i)
114 double dDistance = std::sqrt(std::pow(vCoordinates[i].dEasting - vCoordinates[i - 1].dEasting, 2) +
115 std::pow(vCoordinates[i].dNorthing - vCoordinates[i - 1].dNorthing, 2));
116 double dMidEasting = (vCoordinates[i].dEasting + vCoordinates[i - 1].dEasting) / 2;
117 double dMidNorthing = (vCoordinates[i].dNorthing + vCoordinates[i - 1].dNorthing) / 2;
118 mtAxes->text(dMidEasting, dMidNorthing, std::to_string(
int(dDistance)) +
" m");
122 mtPlot->save(szFileName +
".png");
134 inline void PlotCoordinates2D(
const std::vector<geoops::GPSCoordinate>& vCoordinates,
const std::string& szTitle =
"GPSCoordinatePlot")
137 std::string szPlotTitle = szTitle;
138 matplot::figure_handle mtPlot = matplot::figure(
true);
139 matplot::axes_handle mtAxes = mtPlot->current_axes();
142 if (vCoordinates.empty())
145 LOG_WARNING(logging::g_qSharedLogger,
"Coordinates vector is empty. Cannot plot.");
150 if (szPlotTitle.empty())
153 LOG_WARNING(logging::g_qSharedLogger,
"Plot title is empty. Setting title to default.");
154 szPlotTitle =
"GPSCoordinatePlot";
158 std::string szFileName = logging::g_szLoggingOutputPath +
"/path_plots/" + szTitle;
160 while (std::filesystem::exists(szFileName +
".png"))
162 szFileName = szFileName + std::to_string(nFileNum);
167 if (!std::filesystem::exists(logging::g_szLoggingOutputPath +
"/path_plots"))
169 std::filesystem::create_directory(logging::g_szLoggingOutputPath +
"/path_plots");
172 mtPlot->backend()->output(szFileName +
".png");
175 std::vector<double> vLatitude, vLongitude;
178 vLatitude.push_back(stCoordinate.dLatitude);
179 vLongitude.push_back(stCoordinate.dLongitude);
181 mtAxes->plot(vLatitude, vLongitude,
"-o");
182 mtPlot->title(szPlotTitle);
183 mtAxes->xlabel(
"Latitude");
184 mtAxes->ylabel(
"Longitude");
187 mtAxes->xtickangle(45);
188 mtAxes->axis(matplot::square);
189 mtAxes->xtickformat(
"%.0f");
190 mtAxes->ytickformat(
"%.0f");
195 for (
size_t i = 1; i < vCoordinates.size(); ++i)
198 double dMidLatitude = (vCoordinates[i].dLatitude + vCoordinates[i - 1].dLatitude) / 2;
199 double dMidLongitude = (vCoordinates[i].dLongitude + vCoordinates[i - 1].dLongitude) / 2;
200 mtAxes->text(dMidLatitude, dMidLongitude, std::to_string(
int(dDistance)) +
" m");
204 mtPlot->save(szFileName +
".png");
216 inline void PlotCoordinates2D(
const std::vector<geoops::Waypoint>& vWaypoints,
const std::string& szTitle =
"WaypointPlot")
219 std::string szPlotTitle = szTitle;
220 matplot::figure_handle mtPlot = matplot::figure(
true);
221 matplot::axes_handle mtAxes = mtPlot->current_axes();
224 if (vWaypoints.empty())
227 LOG_WARNING(logging::g_qSharedLogger,
"Waypoints vector is empty. Cannot plot.");
232 if (szPlotTitle.empty())
235 LOG_WARNING(logging::g_qSharedLogger,
"Plot title is empty. Setting title to default.");
236 szPlotTitle =
"WaypointPlot";
240 std::string szFileName = logging::g_szLoggingOutputPath +
"/path_plots/" + szTitle;
242 while (std::filesystem::exists(szFileName +
".png"))
244 szFileName = szFileName + std::to_string(nFileNum);
249 if (!std::filesystem::exists(logging::g_szLoggingOutputPath +
"/path_plots"))
251 std::filesystem::create_directory(logging::g_szLoggingOutputPath +
"/path_plots");
254 mtPlot->backend()->output(szFileName +
".png");
257 std::vector<double> vEasting, vNorthing;
260 vEasting.push_back(stWaypoint.GetUTMCoordinate().dEasting);
261 vNorthing.push_back(stWaypoint.GetUTMCoordinate().dNorthing);
263 mtAxes->plot(vEasting, vNorthing,
"-o");
264 mtPlot->title(szPlotTitle);
265 mtAxes->xlabel(
"Easting");
266 mtAxes->ylabel(
"Northing");
269 mtAxes->xtickangle(45);
270 mtAxes->axis(matplot::square);
271 mtAxes->xtickformat(
"%.0f");
272 mtAxes->ytickformat(
"%.0f");
277 for (
size_t i = 1; i < vWaypoints.size(); ++i)
280 double dMidEasting = (vWaypoints[i].GetUTMCoordinate().dEasting + vWaypoints[i - 1].GetUTMCoordinate().dEasting) / 2;
281 double dMidNorthing = (vWaypoints[i].GetUTMCoordinate().dNorthing + vWaypoints[i - 1].GetUTMCoordinate().dNorthing) / 2;
282 mtAxes->text(dMidEasting, dMidNorthing, std::to_string(
int(dDistance)) +
" m");
286 mtPlot->save(szFileName +
".png");
298 inline void PlotCoordinates3D(
const std::vector<geoops::UTMCoordinate>& vCoordinates,
const std::string& szTitle =
"UTMCoordinatePlot")
301 std::string szPlotTitle = szTitle;
302 matplot::figure_handle mtPlot = matplot::figure(
true);
303 matplot::axes_handle mtAxes = mtPlot->current_axes();
306 if (vCoordinates.empty())
309 LOG_WARNING(logging::g_qSharedLogger,
"Coordinates vector is empty. Cannot plot.");
314 if (szPlotTitle.empty())
317 LOG_WARNING(logging::g_qSharedLogger,
"Plot title is empty. Setting title to default.");
318 szPlotTitle =
"UTMCoordinatePlot";
322 std::string szFileName = logging::g_szLoggingOutputPath +
"/path_plots/" + szTitle;
324 while (std::filesystem::exists(szFileName +
".png"))
326 szFileName = szFileName + std::to_string(nFileNum);
331 if (!std::filesystem::exists(logging::g_szLoggingOutputPath +
"/path_plots"))
333 std::filesystem::create_directory(logging::g_szLoggingOutputPath +
"/path_plots");
336 mtPlot->backend()->output(szFileName +
".png");
339 std::vector<double> vEasting, vNorthing, vAltitude;
342 vEasting.push_back(stCoordinate.dEasting);
343 vNorthing.push_back(stCoordinate.dNorthing);
344 vAltitude.push_back(stCoordinate.dAltitude);
347 mtAxes->plot3(vEasting, vNorthing, vAltitude,
"-o");
348 mtPlot->title(szPlotTitle);
349 mtAxes->xlabel(
"Easting");
350 mtAxes->ylabel(
"Northing");
351 mtAxes->zlabel(
"Altitude");
354 mtAxes->xtickangle(45);
355 mtAxes->axis(matplot::square);
356 mtAxes->xtickformat(
"%.0f");
357 mtAxes->ytickformat(
"%.0f");
358 mtAxes->ztickformat(
"%.0f");
363 mtPlot->save(szFileName +
".png");
375 inline void PlotCoordinates3D(
const std::vector<geoops::GPSCoordinate>& vCoordinates,
const std::string& szTitle =
"GPSCoordinatePlot")
378 std::string szPlotTitle = szTitle;
379 matplot::figure_handle mtPlot = matplot::figure(
true);
380 matplot::axes_handle mtAxes = mtPlot->current_axes();
383 if (vCoordinates.empty())
386 LOG_WARNING(logging::g_qSharedLogger,
"Coordinates vector is empty. Cannot plot.");
391 if (szPlotTitle.empty())
394 LOG_WARNING(logging::g_qSharedLogger,
"Plot title is empty. Setting title to default.");
395 szPlotTitle =
"GPSCoordinatePlot";
399 std::string szFileName = logging::g_szLoggingOutputPath +
"/path_plots/" + szTitle;
401 while (std::filesystem::exists(szFileName +
".png"))
403 szFileName = szFileName + std::to_string(nFileNum);
408 if (!std::filesystem::exists(logging::g_szLoggingOutputPath +
"/path_plots"))
410 std::filesystem::create_directory(logging::g_szLoggingOutputPath +
"/path_plots");
413 mtPlot->backend()->output(szFileName +
".png");
416 std::vector<double> vLatitude, vLongitude, vAltitude;
419 vLatitude.push_back(stCoordinate.dLatitude);
420 vLongitude.push_back(stCoordinate.dLongitude);
421 vAltitude.push_back(stCoordinate.dAltitude);
424 mtAxes->plot3(vLatitude, vLongitude, vAltitude,
"-o");
425 mtPlot->title(szPlotTitle);
426 mtAxes->xlabel(
"Latitude");
427 mtAxes->ylabel(
"Longitude");
428 mtAxes->zlabel(
"Altitude");
431 mtAxes->xtickangle(45);
432 mtAxes->axis(matplot::square);
433 mtAxes->xtickformat(
"%.0f");
434 mtAxes->ytickformat(
"%.0f");
435 mtAxes->ztickformat(
"%.0f");
440 mtPlot->save(szFileName +
".png");
452 inline void PlotCoordinates3D(
const std::vector<geoops::Waypoint>& vWaypoints,
const std::string& szTitle =
"WaypointPlot")
455 std::string szPlotTitle = szTitle;
456 matplot::figure_handle mtPlot = matplot::figure(
true);
457 matplot::axes_handle mtAxes = mtPlot->current_axes();
460 if (vWaypoints.empty())
463 LOG_WARNING(logging::g_qSharedLogger,
"Waypoints vector is empty. Cannot plot.");
468 if (szPlotTitle.empty())
471 LOG_WARNING(logging::g_qSharedLogger,
"Plot title is empty. Setting title to default.");
472 szPlotTitle =
"WaypointPlot";
476 std::string szFileName = logging::g_szLoggingOutputPath +
"/path_plots/" + szTitle;
478 while (std::filesystem::exists(szFileName +
".png"))
480 szFileName = szFileName + std::to_string(nFileNum);
485 if (!std::filesystem::exists(logging::g_szLoggingOutputPath +
"/path_plots"))
487 std::filesystem::create_directory(logging::g_szLoggingOutputPath +
"/path_plots");
490 mtPlot->backend()->output(szFileName +
".png");
493 std::vector<double> vEasting, vNorthing, vAltitude;
496 vEasting.push_back(stWaypoint.GetUTMCoordinate().dEasting);
497 vNorthing.push_back(stWaypoint.GetUTMCoordinate().dNorthing);
498 vAltitude.push_back(stWaypoint.GetUTMCoordinate().dAltitude);
501 mtAxes->plot3(vEasting, vNorthing, vAltitude,
"-o");
502 mtPlot->title(szPlotTitle);
503 mtAxes->xlabel(
"Easting");
504 mtAxes->ylabel(
"Northing");
505 mtAxes->zlabel(
"Altitude");
508 mtAxes->xtickangle(45);
509 mtAxes->axis(matplot::square);
510 mtAxes->xtickformat(
"%.0f");
511 mtAxes->ytickformat(
"%.0f");
512 mtAxes->ztickformat(
"%.0f");
517 mtPlot->save(szFileName +
".png");
GeoMeasurement CalculateGeoMeasurement(const GPSCoordinate &stCoord1, const GPSCoordinate &stCoord2)
The shortest path between two points on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the g...
Definition GeospatialOperations.hpp:522
void PlotCoordinates2D(const std::vector< geoops::UTMCoordinate > &vCoordinates, const std::string &szTitle="UTMCoordinatePlot")
Plot a 2D graph of UTM coordinates.
Definition PlotsAndGraphs.hpp:52
void PlotCoordinates3D(const std::vector< geoops::UTMCoordinate > &vCoordinates, const std::string &szTitle="UTMCoordinatePlot")
Plot a 3D graph of UTM coordinates.
Definition PlotsAndGraphs.hpp:298
This struct is used by the WaypointHandler class to store location, size, and type information about ...
Definition GeospatialOperations.hpp:392