Generates KML files from FERS simulation scenarios for geographical visualization.
More...
Generates KML files from FERS simulation scenarios for geographical visualization.
This class generates KML files for geographical visualization of FERS scenarios. It converts the stored platform coordinates to geodetic KML output using the user-specified KML/geospatial coordinate system in the XML file. This affects KML conversion only; the signal simulation uses the raw platform vectors directly. The KML/geospatial coordinate system can be one of:
- ENU (East-North-Up): Default. Local Cartesian coordinates (x, y, z) are treated as meters in an ENU tangent plane centered at a geodetic
<origin>.
- UTM (Universal Transverse Mercator): Coordinates (x, y, z) are treated as easting (m), northing (m), and altitude (m) within a specified UTM zone and hemisphere.
- ECEF (Earth-Centered, Earth-Fixed): Coordinates (x, y, z) are treated as geocentric X, Y, Z values in meters.
All input coordinates are converted to WGS84 geodetic coordinates (latitude, longitude, altitude) for the final KML output. The KML is written with <altitudeMode>absolute</altitudeMode>, where altitude is relative to Mean Sea Level (MSL).
Definition at line 49 of file kml_generator.h.
| std::expected< void, std::string > serial::KmlGenerator::generateKml |
( |
const core::World & |
world, |
|
|
const std::string & |
outputKmlPath |
|
) |
| |
|
static |
Generates a KML file from a pre-built simulation world.
- Parameters
-
| world | The simulation world containing all objects and paths. |
| outputKmlPath | The path for the output KML file. |
- Returns
- Success or an error message describing why generation failed.
Definition at line 28 of file kml_generator.cpp.
30 {
31 try
32 {
33 kml_generator_utils::KmlContext
ctx;
35
36 switch (
ctx.parameters.coordinate_frame)
37 {
39 {
40 auto proj = std::make_shared<GeographicLib::LocalCartesian>(
ctx.parameters.origin_latitude,
41 ctx.parameters.origin_longitude,
42 ctx.parameters.origin_altitude);
45 break;
46 }
48 {
49 const int zone =
ctx.parameters.utm_zone;
50 const bool northp =
ctx.parameters.utm_north_hemisphere;
52 {
53 double gamma = std::numeric_limits<double>::quiet_NaN();
54 double k = std::numeric_limits<double>::quiet_NaN();
57 };
58 break;
59 }
61 {
62 const auto&
earth = GeographicLib::Geocentric::WGS84();
65 break;
66 }
67 }
68
70 if (!kml_file.is_open())
71 {
74 return std::unexpected(
message);
75 }
76
78 kml_file.close();
79 }
80 catch (
const std::exception&
e)
81 {
82 const std::string
message =
"Error generating KML file: " + std::string(
e.what());
84 return std::unexpected(
message);
85 }
86 catch (...)
87 {
88 const std::string
message =
"Unknown error occurred while generating KML file.";
90 return std::unexpected(
message);
91 }
92 return {};
93 }
A class representing a vector in rectangular coordinates.
RealType x
The x component of the vector.
RealType z
The z component of the vector.
RealType y
The y component of the vector.
@ ERROR
Error level for error events.
@ UTM
Universal Transverse Mercator.
@ ENU
East-North-Up local tangent plane (default)
@ ECEF
Earth-Centered, Earth-Fixed.
Parameters params
Global simulation parameter state.
void generateKmlToStream(std::ostream &out, const core::World &world, const KmlContext &ctx)
Master entry point designed to convert the comprehensive simulation world state into a valid KML docu...
References params::ECEF, params::ENU, logging::ERROR, serial::kml_generator_utils::generateKmlToStream(), LOG, max, params::params, params::UTM, math::Vec3::x, math::Vec3::y, and math::Vec3::z.
Referenced by fers_generate_kml().