Marble

KmlPolygonTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Shou Ya <shouyatf@gmail.com>
4// SPDX-FileCopyrightText: 2014 Marek Hakala <hakala.marek@gmail.com>
5//
6
7#include "KmlPolygonTagWriter.h"
8
9#include "GeoDataLinearRing.h"
10#include "GeoDataPolygon.h"
11#include "GeoDataTypes.h"
12#include "GeoWriter.h"
13#include "KmlElementDictionary.h"
14#include "KmlObjectTagWriter.h"
15
16namespace Marble
17{
18
19static GeoTagWriterRegistrar s_writerLookAt(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataPolygonType),
20 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
21 new KmlPolygonTagWriter);
22
23bool KmlPolygonTagWriter::write(const GeoNode *node, GeoWriter &writer) const
24{
25 const auto polygon = static_cast<const GeoDataPolygon *>(node);
26
27 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Polygon));
28 KmlObjectTagWriter::writeIdentifiers(writer, polygon);
29 writer.writeOptionalElement(QLatin1String(kml::kmlTag_extrude), QString::number(polygon->extrude()), QStringLiteral("0"));
30
31 writer.writeStartElement("outerBoundaryIs");
32 writeElement(&polygon->outerBoundary(), writer);
33 writer.writeEndElement();
34
35 const QList<GeoDataLinearRing> &linearRings = polygon->innerBoundaries();
36 if (!linearRings.isEmpty()) {
37 writer.writeStartElement("innerBoundaryIs");
38 for (int i = 0; i < linearRings.size(); ++i) {
39 const GeoDataLinearRing &ring = linearRings[i];
40 writeElement(&ring, writer);
41 }
42 writer.writeEndElement();
43 }
44
45 writer.writeEndElement();
46
47 return true;
48}
49
50}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Binds a QML item to a specific geodetic location in screen coordinates.
bool isEmpty() const const
qsizetype size() const const
QString fromLatin1(QByteArrayView str)
QString fromUtf8(QByteArrayView str)
QString number(double n, char format, int precision)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.