Marble

KmlLinearRingTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "KmlLinearRingTagHandler.h"
8 
9 #include "MarbleDebug.h"
10 
11 #include "KmlElementDictionary.h"
12 #include "KmlObjectTagHandler.h"
13 #include "GeoDataPlacemark.h"
14 #include "GeoDataPolygon.h"
15 #include "GeoDataMultiGeometry.h"
16 #include "GeoDataLinearRing.h"
17 
18 #include "GeoParser.h"
19 
20 namespace Marble
21 {
22 namespace kml
23 {
24 KML_DEFINE_TAG_HANDLER( LinearRing )
25 
26 GeoNode* KmlLinearRingTagHandler::parse( GeoParser& parser ) const
27 {
28  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(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  GeoDataLinearRing *linearRing = new GeoDataLinearRing;
46  KmlObjectTagHandler::parseIdentifiers( parser, linearRing );
47  GeoDataPlacemark *placemark = parentItem.nodeAs<GeoDataPlacemark>();
48  placemark->setGeometry( linearRing );
49  return placemark->geometry();
50 
51  } else if( parentItem.is<GeoDataMultiGeometry>() ) {
52  GeoDataLinearRing *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-2023 The KDE developers.
Generated on Mon Sep 25 2023 03:50:19 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.