• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • writers
  • kml
KmlPolygonTagWriter.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Shou Ya <shouyatf@gmail.com>
9 // Copyright 2014 Marek Hakala <hakala.marek@gmail.com>
10 //
11 
12 #include "KmlPolygonTagWriter.h"
13 
14 #include "GeoDataPolygon.h"
15 #include "GeoDataTypes.h"
16 #include "GeoWriter.h"
17 #include "KmlElementDictionary.h"
18 #include "KmlObjectTagWriter.h"
19 
20 namespace Marble
21 {
22 
23 static GeoTagWriterRegistrar s_writerLookAt(
24  GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataPolygonType,
25  kml::kmlTag_nameSpaceOgc22 ),
26  new KmlPolygonTagWriter);
27 
28 bool KmlPolygonTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
29 {
30  const GeoDataPolygon *polygon = static_cast<const GeoDataPolygon*>( node );
31 
32  writer.writeStartElement( kml::kmlTag_Polygon );
33  KmlObjectTagWriter::writeIdentifiers( writer, polygon );
34  writer.writeOptionalElement( kml::kmlTag_extrude, QString::number( polygon->extrude() ), "0" );
35 
36  writer.writeStartElement( "outerBoundaryIs" );
37  writeElement( &polygon->outerBoundary(), writer );
38  writer.writeEndElement();
39 
40  const QVector<GeoDataLinearRing>& linearRings = polygon->innerBoundaries();
41  if (linearRings.size() > 0) {
42  writer.writeStartElement( "innerBoundaryIs" );
43  for ( int i = 0; i < linearRings.size(); ++i ) {
44  const GeoDataLinearRing& ring = linearRings[i];
45  writeElement( &ring, writer );
46  }
47  writer.writeEndElement();
48  }
49 
50  writer.writeEndElement();
51 
52  return true;
53 
54 }
55 
56 }
57 
Marble::GeoWriter::writeOptionalElement
void writeOptionalElement(const QString &key, const QString &value, const QString &defaultValue=QString())
Convenience method to write value if value is not equal to defaultValue.
Definition: GeoWriter.cpp:98
Marble::s_writerLookAt
static GeoTagWriterRegistrar s_writerLookAt(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataGroundOverlayType, kml::kmlTag_nameSpaceOgc22), new KmlGroundOverlayWriter)
Marble::KmlPolygonTagWriter::write
virtual bool write(const GeoNode *node, GeoWriter &writer) const
Definition: KmlPolygonTagWriter.cpp:28
Marble::GeoDataLinearRing
A LinearRing that allows to store a closed, contiguous set of line segments.
Definition: GeoDataLinearRing.h:68
Marble::GeoDataTypes::GeoDataPolygonType
const char * GeoDataPolygonType
Definition: GeoDataTypes.cpp:69
Marble::kml::kmlTag_extrude
const char * kmlTag_extrude
Definition: KmlElementDictionary.cpp:68
KmlObjectTagWriter.h
GeoDataPolygon.h
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
Marble::KmlObjectTagWriter::writeIdentifiers
static void writeIdentifiers(GeoWriter &writer, const GeoDataObject *object)
Parses the id and targetId attributes and assign their values to the given object.
Definition: KmlObjectTagWriter.cpp:15
GeoWriter.h
Marble::GeoDataGeometry::extrude
bool extrude() const
Definition: GeoDataGeometry.cpp:100
QString::number
QString number(int n, int base)
KmlElementDictionary.h
Marble::GeoDataPolygon
A polygon that can have "holes".
Definition: GeoDataPolygon.h:81
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:29
Marble::GeoTagWriter::QualifiedName
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:48
Marble::GeoDataPolygon::outerBoundary
GeoDataLinearRing & outerBoundary()
Returns the outer boundary that is represented as a LinearRing.
Definition: GeoDataPolygon.cpp:123
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
Marble::GeoTagWriter::writeElement
bool writeElement(const GeoNode *object, GeoWriter &writer) const
Definition: GeoTagWriter.cpp:29
KmlPolygonTagWriter.h
Marble::GeoDataPolygon::innerBoundaries
QVector< GeoDataLinearRing > & innerBoundaries()
Returns a set of inner boundaries which are represented as LinearRings.
Definition: GeoDataPolygon.cpp:139
QVector
GeoDataTypes.h
QVector::size
int size() const
Marble::kml::kmlTag_Polygon
const char * kmlTag_Polygon
Definition: KmlElementDictionary.cpp:145
QXmlStreamWriter::writeEndElement
void writeEndElement()
QXmlStreamWriter::writeStartElement
void writeStartElement(const QString &qualifiedName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal