Marble

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

KDE's Doxygen guidelines are available online.