12#include <implot_internal.h>
91 if (j.contains(
"dynamicInputPins"))
95 if (j.contains(
"FileWriter"))
105 _filestream <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
106 "<kml xmlns=\"http://earth.google.com/kml/2.2\">\n"
108 "<Style id=\"P0\">\n"
110 " <color>ffffffff</color>\n"
111 " <scale>0.3</scale>\n"
112 " <Icon><href>http://maps.google.com/mapfiles/kml/pal2/icon18.png</href></Icon>\n"
115 "<Style id=\"P2\">\n"
117 " <color>ff00aaff</color>\n"
118 " <scale>0.2</scale>\n"
119 " <Icon><href>http://maps.google.com/mapfiles/kml/pal2/icon18.png</href></Icon>\n"
123 ImPlotContext& gp = *ImPlot::GetCurrentContext();
124 int cmap = gp.Style.Colormap;
125 int nColors = gp.ColormapData.GetKeyCount(cmap);
129 int cidx =
static_cast<int>(i) % nColors;
130 ImColor color(gp.ColormapData.GetKeyColor(cmap, cidx));
134 << fmt::format(
"{:02x}{:02x}{:02x}{:02x}",
135 static_cast<int>(color.Value.w * 255.0F),
136 static_cast<int>(color.Value.z * 255.0F),
137 static_cast<int>(color.Value.y * 255.0F),
138 static_cast<int>(color.Value.x * 255.0F))
140 " <width>1</width>\n"
148 if (posData.empty()) {
continue; }
150 if (posData.size() > 1)
153 <<
"<name>" <<
inputPins.at(i).name <<
" Track</name>\n"
154 <<
"<styleUrl>#line" << i <<
"</styleUrl>\n"
156 <<
"<altitudeMode>absolute</altitudeMode>\n"
158 for (
const auto& lla : posData)
160 fmt::print(
_filestream,
"{:.9f},{:.9f},{:.3f}\n", lla.y(), lla.x(), lla.z());
170 if (posData.size() > 1)
173 <<
"<name>" <<
inputPins.at(i).name <<
" Position</name>\n"
174 <<
"<visibility>0</visibility>";
176 for (
const auto& lla : posData)
179 if (posData.size() > 1)
189 "<extrude>1</extrude>\n"
190 "<altitudeMode>absolute</altitudeMode>\n"
192 fmt::print(
_filestream,
"{:.9f},{:.9f},{:.3f}", lla.y(), lla.x(), lla.z());
197 if (posData.size() > 1)
235 auto* kmlNode =
static_cast<KmlLogger*
>(node);
241 kmlNode->_positionData.emplace_back();
246 auto* kmlNode =
static_cast<KmlLogger*
>(node);
248 kmlNode->_positionData.erase(std::next(kmlNode->_positionData.begin(),
static_cast<int64_t
>(pinIdx)));
255 auto obs = std::static_pointer_cast<const Pos>(queue.
extract_front());
nlohmann::json json
json namespace
Data Logger for Pos data as KML (Keyhole Markup Language) files (input for Google Earth)
Utility class for logging to console and file.
#define LOG_DEBUG
Debug information. Should not be called on functions which receive observations (spamming)
#define LOG_DATA
All output which occurs repeatedly every time observations are received.
#define LOG_TRACE
Detailled info to trace the execution of the program. Should not be called on functions which receive...
Utility class which specifies available nodes.
FileType _fileType
File Type.
void deinitialize()
Deinitialize the file reader.
bool guiConfig(const char *vFilters, const std::vector< std::string > &extensions, size_t id, const std::string &nameId)
ImGui config.
void restore(const json &j)
Restores the node from a json object.
json save() const
Saves the node into a json object.
bool initialize()
Initialize the file reader.
std::ofstream _filestream
File stream to write the file.
~KmlLogger() override
Destructor.
void restore(const json &j) override
Restores the node from a json object.
std::string type() const override
String representation of the Class Type.
json save() const override
Saves the node into a json object.
static void pinDeleteCallback(Node *node, size_t pinIdx)
Function to call to delete a pin.
static std::string typeStatic()
String representation of the Class Type.
static std::string category()
String representation of the Class Category.
static void pinAddCallback(Node *node)
Function to call to add a new pin.
gui::widgets::DynamicInputPins _dynamicInputPins
Dynamic input pins.
void guiConfig() override
ImGui config window which is shown on double click.
std::vector< std::vector< Eigen::Vector3d > > _positionData
One data set of positions for each pin in Latitude [deg], Longitude [deg], Height above Mean Sea Leve...
void deinitialize() override
Deinitialize the node.
bool initialize() override
Initialize the node.
void flush() override
Function called by the flow executer after finishing to flush out remaining data.
KmlLogger()
Default constructor.
void writeObservation(InputPin::NodeDataQueue &queue, size_t pinIdx)
Write Observation to the file.
bool doDeinitialize(bool wait=false)
Asks the node worker to deinitialize the node.
ImVec2 _guiConfigDefaultWindowSize
Node(std::string name)
Constructor.
std::vector< InputPin > inputPins
List of input pins.
std::string nameId() const
Node name and id.
std::string name
Name of the Node.
bool _hasConfig
Flag if the config window should be shown.
auto extract_front()
Returns a copy of the first element in the container and removes it from the container.
bool DeleteInputPin(InputPin &pin)
Deletes the input pin. Invalidates the pin reference given.
InputPin * CreateInputPin(Node *node, const char *name, Pin::Type pinType, const std::vector< std::string > &dataIdentifier={}, InputPin::Callback callback=static_cast< InputPin::FlowFirableCallbackFunc >(nullptr), InputPin::FlowFirableCheckFunc firable=nullptr, int priority=0, int idx=-1)
Create an Input Pin object.
void ApplyChanges()
Signals that there have been changes to the flow.
double egm96_compute_altitude_offset(double lat, double lon)
Compute the geoid undulation from the EGM96 potential coefficient model to The WGS84 ellipsoid.
constexpr auto rad2deg(const T &rad)
Convert Radians to Degree.