• 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
KmlTimeStampTagWriter.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 2011 Javier Becerra <javier@auva.es>
9 //
10 
11 #include "KmlTimeStampTagWriter.h"
12 
13 #include "GeoDataTimeStamp.h"
14 #include "GeoDataTypes.h"
15 #include "GeoWriter.h"
16 #include "KmlElementDictionary.h"
17 #include "KmlObjectTagWriter.h"
18 
19 #include <QDateTime>
20 
21 namespace Marble
22 {
23 
24 static GeoTagWriterRegistrar s_writerTimeStamp( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataTimeStampType,
25  kml::kmlTag_nameSpaceOgc22),
26  new KmlTimeStampTagWriter() );
27 
28 
29 bool KmlTimeStampTagWriter::write( const GeoNode *node,
30  GeoWriter& writer ) const
31 {
32  const GeoDataTimeStamp *timestamp = static_cast<const GeoDataTimeStamp*>(node);
33 
34  if( timestamp->when().isValid() )
35  {
36  writer.writeStartElement( kml::kmlTag_TimeStamp );
37  KmlObjectTagWriter::writeIdentifiers( writer, timestamp );
38 
39  writer.writeStartElement( kml::kmlTag_when);
40  writer.writeCharacters( toString( *timestamp ) );
41  writer.writeEndElement();
42 
43  writer.writeEndElement();
44  }
45  return true;
46 }
47 
48 QString KmlTimeStampTagWriter::toString( const GeoDataTimeStamp &timestamp )
49 {
50  switch ( timestamp.resolution() ) {
51  case GeoDataTimeStamp::SecondResolution: return timestamp.when().toString( Qt::ISODate );
52  case GeoDataTimeStamp::DayResolution: return timestamp.when().toString( "yyyy-MM-dd" );
53  case GeoDataTimeStamp::MonthResolution: return timestamp.when().toString( "yyyy-MM" );
54  case GeoDataTimeStamp::YearResolution: return timestamp.when().toString( "yyyy" );
55  }
56 
57  Q_ASSERT( false && "not reachable" );
58  return QString();
59 }
60 
61 }
Marble::KmlTimeStampTagWriter::toString
static QString toString(const GeoDataTimeStamp &timestamp)
Definition: KmlTimeStampTagWriter.cpp:48
QDateTime::toString
QString toString(Qt::DateFormat format) const
Marble::GeoDataTimeStamp
Definition: GeoDataTimeStamp.h:27
Marble::GeoDataTimeStamp::MonthResolution
Definition: GeoDataTimeStamp.h:33
Marble::GeoDataTypes::GeoDataTimeStampType
const char * GeoDataTimeStampType
Definition: GeoDataTypes.cpp:82
Marble::GeoDataTimeStamp::resolution
TimeResolution resolution() const
Definition: GeoDataTimeStamp.cpp:81
KmlObjectTagWriter.h
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
GeoDataTimeStamp.h
Marble::kml::kmlTag_TimeStamp
const char * kmlTag_TimeStamp
Definition: KmlElementDictionary.cpp:187
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::kml::kmlTag_when
const char * kmlTag_when
Definition: KmlElementDictionary.cpp:200
KmlElementDictionary.h
Marble::GeoDataTimeStamp::DayResolution
Definition: GeoDataTimeStamp.h:32
Marble::GeoDataTimeStamp::when
QDateTime when() const
return the when time of timestamp
Definition: GeoDataTimeStamp.cpp:66
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::GeoDataTimeStamp::YearResolution
Definition: GeoDataTimeStamp.h:34
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
QString
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
QDateTime::isValid
bool isValid() const
Marble::GeoDataTimeStamp::SecondResolution
Definition: GeoDataTimeStamp.h:31
Marble::s_writerTimeStamp
static GeoTagWriterRegistrar s_writerTimeStamp(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataTimeStampType, kml::kmlTag_nameSpaceOgc22), new KmlTimeStampTagWriter())
GeoDataTypes.h
Marble::KmlTimeStampTagWriter::write
virtual bool write(const GeoNode *node, GeoWriter &writer) const
Definition: KmlTimeStampTagWriter.cpp:29
QXmlStreamWriter::writeCharacters
void writeCharacters(const QString &text)
KmlTimeStampTagWriter.h
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