• 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
  • 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 bool GeoDataRegion::operator==(const GeoDataRegion& other) const
62 {
63  return equals(other)
64  && this->latLonAltBox() == other.latLonAltBox()
65  && this->lod() == other.lod();
66 }
67 
68 bool GeoDataRegion::operator!=(const GeoDataRegion& other) const
69 {
70  return !this->operator==(other);
71 }
72 
73 const GeoDataLatLonAltBox& GeoDataRegion::latLonAltBox() const
74 {
75  // FIXME: This isn't exactly what a 'const' function should do, is it?
76 
77  // If the latLonAltBox hasn't been set try to determine it automatically
78  if ( !d->m_latLonAltBox ) {
79  // If there is a parent try to
80  if ( d->m_parent ) {
81 
82  if ( d->m_parent->nodeType() == GeoDataTypes::GeoDataPlacemarkType ) {
83 
84  GeoDataPlacemark * placemark = dynamic_cast<GeoDataPlacemark*>( d->m_parent );
85  const GeoDataGeometry * geometry = placemark->geometry();
86  if ( geometry ) {
87  d->m_latLonAltBox = new GeoDataLatLonAltBox( placemark->geometry()->latLonAltBox() );
88  }
89  else {
90  d->m_latLonAltBox = new GeoDataLatLonAltBox();
91  }
92  }
93  else {
94  // If the parent is not a placemark then create a default LatLonAltBox
95  // FIXME: reference a shared object instead
96  d->m_latLonAltBox = new GeoDataLatLonAltBox();
97  }
98  }
99  else {
100  // If there is no parent then create a default LatLonAltBox
101  // FIXME: reference a shared object instead
102  d->m_latLonAltBox = new GeoDataLatLonAltBox();
103  }
104  }
105 
106  return *(d->m_latLonAltBox);
107 }
108 
109 
110 void GeoDataRegion::setLatLonAltBox( const GeoDataLatLonAltBox & latLonAltBox )
111 {
112  delete d->m_latLonAltBox;
113  d->m_latLonAltBox = new GeoDataLatLonAltBox( latLonAltBox );
114 }
115 
116 
117 GeoDataLod& GeoDataRegion::lod() const
118 {
119  // If the lod hasn't been set then return a shared one
120  if ( !d->m_lod ) {
121  // FIXME: reference a shared object instead
122  d->m_lod = new GeoDataLod();
123  }
124 
125  return *(d->m_lod);
126 }
127 
128 
129 void GeoDataRegion::setLod( const GeoDataLod & lod )
130 {
131  delete d->m_lod;
132  d->m_lod = new GeoDataLod( lod );
133 }
134 
135 
136 void GeoDataRegion::pack( QDataStream& stream ) const
137 {
138  GeoDataObject::pack( stream );
139 
140  d->m_lod->pack( stream );
141  d->m_latLonAltBox->pack( stream );
142 }
143 
144 
145 void GeoDataRegion::unpack( QDataStream& stream )
146 {
147  GeoDataObject::unpack( stream );
148 
149  d->m_lod->unpack( stream );
150  d->m_latLonAltBox->unpack( stream );
151 }
152 
153 GeoDataRegion &GeoDataRegion::operator=( const GeoDataRegion& other )
154 {
155  // Self assignment
156  if ( this == &other ) return *this;
157 
158  GeoDataRegion temp( other );
159  swap( temp );
160  return *this;
161 }
162 
163 void GeoDataRegion::swap( GeoDataRegion & other )
164 {
165  std::swap( d, other.d );
166 }
167 
168 }
169 
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:110
QDataStream
Marble::GeoDataRegion::pack
virtual void pack(QDataStream &stream) const
Serialize the Region to a stream.
Definition: GeoDataRegion.cpp:136
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:66
Marble::GeoDataObject::equals
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
Definition: GeoDataObject.cpp:126
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::geometry
GeoDataGeometry * geometry()
The geometry of the GeoDataPlacemark is to be rendered to the marble map along with the icon at the c...
Definition: GeoDataPlacemark.cpp:152
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:129
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:153
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:73
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:112
Marble::GeoDataRegion::operator==
bool operator==(const GeoDataRegion &other) const
Definition: GeoDataRegion.cpp:61
Marble::GeoDataLatLonAltBox::pack
virtual void pack(QDataStream &stream) const
Serialize the contents of the feature to stream.
Definition: GeoDataLatLonAltBox.cpp:291
Marble::GeoDataRegion::unpack
virtual void unpack(QDataStream &stream)
Unserialize the Region from a stream.
Definition: GeoDataRegion.cpp:145
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:117
Marble::GeoDataLod::pack
virtual void pack(QDataStream &stream) const
Serialize the Lod to a stream.
Definition: GeoDataLod.cpp:104
Marble::GeoDataRegion::operator!=
bool operator!=(const GeoDataRegion &other) const
Definition: GeoDataRegion.cpp:68
Marble::GeoDataFeature
A base class for all geodata features.
Definition: GeoDataFeature.h:57
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
Marble::GeoDataGeometry::latLonAltBox
virtual const GeoDataLatLonAltBox & latLonAltBox() const
Definition: GeoDataGeometry.cpp:122
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:158
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:299
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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