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

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • data
GeoDataRegion.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 2009 Torsten Rahn <rahn@kde.org>
9 //
10 
11 
12 // Own
13 #include "GeoDataRegion.h"
14 
15 // Private
16 #include "GeoDataRegion_p.h"
17 
18 // GeoData
19 #include "GeoDataFeature.h"
20 #include "GeoDataPlacemark.h"
21 #include "GeoDataGeometry.h"
22 
23 #include "GeoDataTypes.h"
24 
25 // std
26 #include <algorithm>
27 
28 
29 namespace Marble
30 {
31 GeoDataRegion::GeoDataRegion()
32  : GeoDataObject(),
33  d( new GeoDataRegionPrivate )
34 {
35 }
36 
37 GeoDataRegion::GeoDataRegion( const GeoDataRegion& other )
38  : GeoDataObject( other ),
39  d( new GeoDataRegionPrivate( *other.d ) )
40 {
41 }
42 
43 GeoDataRegion::GeoDataRegion( GeoDataFeature * feature )
44  : GeoDataObject(),
45  d( new GeoDataRegionPrivate( feature ) )
46 {
47 }
48 
49 
50 GeoDataRegion::~GeoDataRegion()
51 {
52  delete d;
53 }
54 
55 
56 const char* GeoDataRegion::nodeType() const
57 {
58  return d->nodeType();
59 }
60 
61 
62 const GeoDataLatLonAltBox& GeoDataRegion::latLonAltBox() const
63 {
64  // FIXME: This isn't exactly what a 'const' function should do, is it?
65 
66  // If the latLonAltBox hasn't been set try to determine it automatically
67  if ( !d->m_latLonAltBox ) {
68  // If there is a parent try to
69  if ( d->m_parent ) {
70 
71  if ( d->m_parent->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
72 
73  GeoDataPlacemark * placemark = dynamic_cast<GeoDataPlacemark*>( d->m_parent );
74  GeoDataGeometry * geometry = placemark->geometry();
75  if ( geometry ) {
76  // TODO: automatically calculate the geometry from the
77  // GeoDataGeometry object.
78  // return geometry->latLonAltBox();
79  }
80 
81  d->m_latLonAltBox = new GeoDataLatLonAltBox( placemark->coordinate() );
82  }
83  else {
84  // If the parent is not a placemark then create a default LatLonAltBox
85  // FIXME: reference a shared object instead
86  d->m_latLonAltBox = new GeoDataLatLonAltBox();
87  }
88  }
89  else {
90  // If there is no parent then create a default LatLonAltBox
91  // FIXME: reference a shared object instead
92  d->m_latLonAltBox = new GeoDataLatLonAltBox();
93  }
94  }
95 
96  return *(d->m_latLonAltBox);
97 }
98 
99 
100 void GeoDataRegion::setLatLonAltBox( const GeoDataLatLonAltBox & latLonAltBox )
101 {
102  delete d->m_latLonAltBox;
103  d->m_latLonAltBox = new GeoDataLatLonAltBox( latLonAltBox );
104 }
105 
106 
107 GeoDataLod& GeoDataRegion::lod() const
108 {
109  // If the lod hasn't been set then return a shared one
110  if ( !d->m_lod ) {
111  // FIXME: reference a shared object instead
112  d->m_lod = new GeoDataLod();
113  }
114 
115  return *(d->m_lod);
116 }
117 
118 
119 void GeoDataRegion::setLod( const GeoDataLod & lod )
120 {
121  delete d->m_lod;
122  d->m_lod = new GeoDataLod( lod );
123 }
124 
125 
126 void GeoDataRegion::pack( QDataStream& stream ) const
127 {
128  GeoDataObject::pack( stream );
129 
130  d->m_lod->pack( stream );
131  d->m_latLonAltBox->pack( stream );
132 }
133 
134 
135 void GeoDataRegion::unpack( QDataStream& stream )
136 {
137  GeoDataObject::unpack( stream );
138 
139  d->m_lod->unpack( stream );
140  d->m_latLonAltBox->unpack( stream );
141 }
142 
143 GeoDataRegion &GeoDataRegion::operator=( const GeoDataRegion& other )
144 {
145  // Self assignment
146  if ( this == &other ) return *this;
147 
148  GeoDataRegion temp( other );
149  swap( temp );
150  return *this;
151 }
152 
153 void GeoDataRegion::swap( GeoDataRegion & other )
154 {
155  std::swap( d, other.d );
156 }
157 
158 }
159 
Marble::GeoDataRegion::setLatLonAltBox
void setLatLonAltBox(const GeoDataLatLonAltBox &latLonAltBox)
Sets the latLonAltBox of the region. Sets the geodesic bounding box that describes the extent of a fe...
Definition: GeoDataRegion.cpp:100
Marble::GeoDataRegion::pack
virtual void pack(QDataStream &stream) const
Serialize the Region to a stream.
Definition: GeoDataRegion.cpp:126
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::GeoDataGeometry
A base class for all geodata features.
Definition: GeoDataGeometry.h:47
Marble::GeoDataTypes::GeoDataPlacemarkType
const char * GeoDataPlacemarkType
Definition: GeoDataTypes.cpp:62
Marble::GeoDataRegion::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoNode.
Definition: GeoDataRegion.cpp:56
Marble::GeoDataObject::pack
virtual void pack(QDataStream &stream) const
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:114
Marble::GeoDataRegion::~GeoDataRegion
virtual ~GeoDataRegion()
Destroys a Region object.
Definition: GeoDataRegion.cpp:50
Marble::GeoDataPlacemark::coordinate
GeoDataCoordinates coordinate(const QDateTime &dateTime=QDateTime(), bool *iconAtCoordinates=0) const
Return the coordinates of the placemark at time dateTime as a GeoDataCoordinates. ...
Definition: GeoDataPlacemark.cpp:78
Marble::GeoDataPlacemark::geometry
GeoDataGeometry * geometry() const
The geometry of the GeoDataPlacemark is to be rendered to the marble map along with the icon at the c...
Definition: GeoDataPlacemark.cpp:63
Marble::GeoDataRegion::setLod
void setLod(const GeoDataLod &lod)
Sets a region's level of detail. The level of detail is set as a lod object.
Definition: GeoDataRegion.cpp:119
Marble::GeoDataRegion::GeoDataRegion
GeoDataRegion()
Creates a new GeoDataRegion object that is not assigned to a feature. Naturally it's recommended to a...
Definition: GeoDataRegion.cpp:31
Marble::GeoDataRegion::operator=
GeoDataRegion & operator=(const GeoDataRegion &other)
Definition: GeoDataRegion.cpp:143
GeoDataFeature.h
GeoDataRegion.h
Marble::GeoDataRegionPrivate::nodeType
const char * nodeType() const
Definition: GeoDataRegion_p.h:64
Marble::GeoDataLod
The level of detail which indicates visibility and importance.
Definition: GeoDataLod.h:44
Marble::GeoDataRegionPrivate::m_lod
GeoDataLod * m_lod
Definition: GeoDataRegion_p.h:71
GeoDataPlacemark.h
Marble::GeoDataRegion::latLonAltBox
const GeoDataLatLonAltBox & latLonAltBox() const
Returns a geodesic bounding box ("latLonAltBox") of the region. Returns a geodesic bounding box that ...
Definition: GeoDataRegion.cpp:62
Marble::GeoDataRegionPrivate::m_parent
GeoDataFeature * m_parent
Definition: GeoDataRegion_p.h:69
Marble::GeoDataLod::unpack
virtual void unpack(QDataStream &stream)
Unserialize the Lod from a stream.
Definition: GeoDataLod.cpp:99
Marble::GeoDataLatLonAltBox::pack
virtual void pack(QDataStream &stream) const
Serialize the contents of the feature to stream.
Definition: GeoDataLatLonAltBox.cpp:292
Marble::GeoDataRegion::unpack
virtual void unpack(QDataStream &stream)
Unserialize the Region from a stream.
Definition: GeoDataRegion.cpp:135
Marble::GeoDataRegionPrivate::m_latLonAltBox
GeoDataLatLonAltBox * m_latLonAltBox
Definition: GeoDataRegion_p.h:70
Marble::GeoDataRegion::lod
GeoDataLod & lod() const
Returns the region's level of detail. The level of detail is returned as a lod object. If no lod has been set then a GeoDataLod object with default values is being returned.
Definition: GeoDataRegion.cpp:107
Marble::GeoDataLod::pack
virtual void pack(QDataStream &stream) const
Serialize the Lod to a stream.
Definition: GeoDataLod.cpp:91
Marble::GeoDataFeature
A base class for all geodata features.
Definition: GeoDataFeature.h:55
Marble::GeoDataRegion
GeoDataRegion describes the visibility and extent of a feature.
Definition: GeoDataRegion.h:49
Marble::GeoDataObject::unpack
virtual void unpack(QDataStream &steam)
Reimplemented from Serializable.
Definition: GeoDataObject.cpp:120
GeoDataGeometry.h
GeoDataTypes.h
GeoDataRegion_p.h
Marble::GeoDataRegionPrivate
Definition: GeoDataRegion_p.h:21
Marble::GeoDataFeature::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoData.
Definition: GeoDataFeature.cpp:94
Marble::GeoDataPlacemark
a class representing a point of interest on the map
Definition: GeoDataPlacemark.h:54
Marble::GeoDataLatLonAltBox
A class that defines a 3D bounding box for geographic data.
Definition: GeoDataLatLonAltBox.h:49
Marble::GeoDataLatLonAltBox::unpack
virtual void unpack(QDataStream &stream)
Unserialize the contents of the feature from stream.
Definition: GeoDataLatLonAltBox.cpp:300
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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