6#include "KmlFeatureTagWriter.h"
8#include "GeoDataCamera.h"
9#include "GeoDataDocument.h"
10#include "GeoDataExtendedData.h"
11#include "GeoDataLatLonAltBox.h"
12#include "GeoDataLookAt.h"
13#include "GeoDataPlacemark.h"
14#include "GeoDataRegion.h"
15#include "GeoDataStyle.h"
16#include "GeoDataStyleMap.h"
17#include "GeoDataTimeSpan.h"
18#include "GeoDataTimeStamp.h"
20#include "KmlElementDictionary.h"
21#include "KmlObjectTagWriter.h"
22#include "KmlOsmPlacemarkDataTagWriter.h"
23#include "OsmPlacemarkData.h"
30KmlFeatureTagWriter::KmlFeatureTagWriter(
const QString &elementName)
31 : m_elementName(elementName)
36bool KmlFeatureTagWriter::write(
const Marble::GeoNode *node, GeoWriter &writer)
const
38 const auto feature =
static_cast<const GeoDataFeature *
>(node);
40 if (
const auto document = geodata_cast<GeoDataDocument>(feature)) {
43 if ((document->id().isEmpty()) && (document->name().isEmpty()) && (document->targetId().isEmpty()) && (document->styles().isEmpty())
44 && (document->styleMaps().isEmpty()) && (document->extendedData().isEmpty()) && (document->featureList().count() == 1)) {
45 writeElement(document->featureList().constFirst(), writer);
50 writer.writeStartElement(m_elementName);
52 KmlObjectTagWriter::writeIdentifiers(writer, feature);
56 writer.writeOptionalElement(QStringLiteral(
"address"), feature->address());
58 if (!feature->description().isEmpty()) {
59 writer.writeStartElement(
"description");
60 if (feature->descriptionIsCDATA()) {
61 writer.writeCDATA(feature->description());
63 writer.writeCharacters(feature->description());
65 writer.writeEndElement();
68 auto const *lookAt =
dynamic_cast<const GeoDataLookAt *
>(feature->abstractView());
70 writeElement(lookAt, writer);
72 auto const *
camera =
dynamic_cast<const GeoDataCamera *
>(feature->abstractView());
74 writeElement(
camera, writer);
77 if (feature->timeStamp().when().isValid()) {
78 writeElement(&feature->timeStamp(), writer);
81 if (feature->timeSpan().isValid()) {
82 writeElement(&feature->timeSpan(), writer);
85 if (!feature->region().latLonAltBox().isNull()) {
86 writeElement(&feature->region(), writer);
89 bool const result = writeMid(node, writer);
91 if (geodata_cast<GeoDataPlacemark>(feature)) {
92 KmlOsmPlacemarkDataTagWriter::write(feature, writer);
95 if (!feature->extendedData().isEmpty()) {
96 writeElement(&feature->extendedData(), writer);
99 writer.writeEndElement();
A shared base class for all classes that are mapped to a specific tag (ie.
Q_SCRIPTABLE QString camera()
Binds a QML item to a specific geodetic location in screen coordinates.
QString fromLatin1(QByteArrayView str)
QString number(double n, char format, int precision)