Marble

KmlMemberTagHandler.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2015 Marius-Valeriu Stanciu <stanciumarius94@gmail.com>
4//
5
6#include "KmlMemberTagHandler.h"
7
8#include "GeoDataPlacemark.h"
9#include "GeoDataLinearRing.h"
10#include "GeoDataPolygon.h"
11#include "GeoDataGeometry.h"
12#include "GeoDataTypes.h"
13#include "KmlElementDictionary.h"
14#include "osm/OsmPlacemarkData.h"
15#include "GeoParser.h"
16
17#include <QtDebug>
18
19namespace Marble
20{
21namespace kml
22{
23KML_DEFINE_TAG_HANDLER_MX( member )
24
25GeoNode* KmlmemberTagHandler::parse( GeoParser& parser ) const
26{
27 int memberIndex = parser.attribute( "index" ).toInt();
28 /* Only possible case: member of polygon placemark:
29 *...
30 * <Placemark>
31 * <ExtendedData>
32 * <mx:OsmPlacemarkData>
33 * <mx:member index="-1">
34 * <mx:OsmPlacemarkData>
35 * <mx:nd index="0">...</nd>
36 * <mx:nd index="1">...</nd>
37 * ...
38 */
39 if( parser.parentElement( 2 ).is<GeoDataPlacemark>() ) {
40 GeoDataPlacemark *placemark = parser.parentElement( 2 ).nodeAs<GeoDataPlacemark>();
41 GeoDataPolygon *polygon = geodata_cast<GeoDataPolygon>(placemark->geometry());
42 if (!polygon) {
43 return nullptr;
44 }
45
46 // The memberIndex is used to determine which member this tag represents
47 if ( memberIndex == -1 ) {
48 return &polygon->outerBoundary();
49 }
50 else {
51 if ( memberIndex >= polygon->innerBoundaries().size() ) {
52 return nullptr;
53 }
54 return &polygon->innerBoundaries()[ memberIndex ];
55 }
56 }
57
58 return nullptr;
59}
60
61}
62}
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 Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.