Marble

KmlLinearRingTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "KmlLinearRingTagHandler.h"
8
9#include "MarbleDebug.h"
10
11#include "GeoDataLinearRing.h"
12#include "GeoDataMultiGeometry.h"
13#include "GeoDataPlacemark.h"
14#include "GeoDataPolygon.h"
15#include "KmlElementDictionary.h"
16#include "KmlObjectTagHandler.h"
17
18#include "GeoParser.h"
19
20namespace Marble
21{
22namespace kml
23{
24KML_DEFINE_TAG_HANDLER(LinearRing)
25
26GeoNode *KmlLinearRingTagHandler::parse(GeoParser &parser) const
27{
28 Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1StringView(kmlTag_LinearRing)));
29
30 GeoStackItem parentItem = parser.parentElement();
31
32 if (parentItem.represents(kmlTag_outerBoundaryIs)) {
33 GeoDataLinearRing linearRing;
34 KmlObjectTagHandler::parseIdentifiers(parser, &linearRing);
35 parentItem.nodeAs<GeoDataPolygon>()->setOuterBoundary(linearRing);
36 return &parentItem.nodeAs<GeoDataPolygon>()->outerBoundary();
37
38 } else if (parentItem.represents(kmlTag_innerBoundaryIs)) {
39 GeoDataLinearRing linearRing;
40 KmlObjectTagHandler::parseIdentifiers(parser, &linearRing);
41 parentItem.nodeAs<GeoDataPolygon>()->appendInnerBoundary(linearRing);
42 return &parentItem.nodeAs<GeoDataPolygon>()->innerBoundaries().last();
43
44 } else if (parentItem.represents(kmlTag_Placemark)) {
45 auto linearRing = new GeoDataLinearRing;
46 KmlObjectTagHandler::parseIdentifiers(parser, linearRing);
47 auto placemark = parentItem.nodeAs<GeoDataPlacemark>();
48 placemark->setGeometry(linearRing);
49 return placemark->geometry();
50
51 } else if (parentItem.is<GeoDataMultiGeometry>()) {
52 auto linearRing = new GeoDataLinearRing;
53 KmlObjectTagHandler::parseIdentifiers(parser, linearRing);
54 parentItem.nodeAs<GeoDataMultiGeometry>()->append(linearRing);
55 return linearRing;
56 } else
57 return nullptr;
58}
59
60}
61}
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.