Marble

KmlLineStringTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2008 Patrick Spendrin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "KmlLineStringTagHandler.h"
8 
9 #include "MarbleDebug.h"
10 
11 #include "KmlElementDictionary.h"
12 #include "KmlObjectTagHandler.h"
13 #include "GeoDataPlacemark.h"
14 #include "GeoDataLineString.h"
15 #include "GeoDataMultiGeometry.h"
16 
17 #include "GeoParser.h"
18 
19 namespace Marble
20 {
21 namespace kml
22 {
23 KML_DEFINE_TAG_HANDLER( LineString )
24 
25 GeoNode* KmlLineStringTagHandler::parse( GeoParser& parser ) const
26 {
27  Q_ASSERT(parser.isStartElement() && parser.isValidElement(QLatin1String(kmlTag_LineString)));
28 
29  GeoStackItem parentItem = parser.parentElement();
30 
31  GeoDataLineString *lineString = new GeoDataLineString;
32  KmlObjectTagHandler::parseIdentifiers( parser, lineString );
33 
34  if( parentItem.represents( kmlTag_Placemark ) ) {
35  parentItem.nodeAs<GeoDataPlacemark>()->setGeometry( lineString );
36  return parentItem.nodeAs<GeoDataPlacemark>()->geometry();
37 
38  } else if( parentItem.represents( kmlTag_MultiGeometry ) ) {
39  parentItem.nodeAs<GeoDataMultiGeometry>()->append( lineString );
40  return lineString;
41 
42  } else {
43  delete lineString;
44  return nullptr;
45  }
46 }
47 
48 }
49 }
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 Oct 2 2023 03:52:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.