9 #include "GeoDataGeometry.h"
10 #include "GeoDataGeometry_p.h"
12 #include "GeoDataLinearRing.h"
13 #include "GeoDataLineString.h"
14 #include "GeoDataModel.h"
15 #include "GeoDataMultiGeometry.h"
16 #include "GeoDataMultiTrack.h"
17 #include "GeoDataPoint.h"
18 #include "GeoDataPolygon.h"
19 #include "GeoDataTrack.h"
20 #include "GeoDataTypes.h"
22 #include "MarbleDebug.h"
24 #include <QDataStream>
30 GeoDataGeometry::GeoDataGeometry(
const GeoDataGeometry& other )
37 GeoDataGeometry::GeoDataGeometry( GeoDataGeometryPrivate* priv )
44 GeoDataGeometry::~GeoDataGeometry()
46 if (!d_ptr->ref.deref())
50 void GeoDataGeometry::detach()
52 if(d_ptr->ref.load() == 1) {
56 GeoDataGeometryPrivate* new_d = d_ptr->copy();
58 if (!d_ptr->ref.deref())
65 GeoDataGeometry& GeoDataGeometry::operator=(
const GeoDataGeometry& other )
67 GeoDataObject::operator=( other );
69 if (!d_ptr->ref.deref())
78 bool GeoDataGeometry::operator==(
const GeoDataGeometry &other)
const
80 if (
nodeType() != other.nodeType()) {
84 if (
nodeType() == GeoDataTypes::GeoDataPolygonType) {
85 const GeoDataPolygon &thisPoly =
static_cast<const GeoDataPolygon &
>(*this);
86 const GeoDataPolygon &otherPoly =
static_cast<const GeoDataPolygon &
>(other);
88 return thisPoly == otherPoly;
89 }
else if (
nodeType() == GeoDataTypes::GeoDataLinearRingType) {
90 const GeoDataLinearRing &thisRing =
static_cast<const GeoDataLinearRing&
>(*this);
91 const GeoDataLinearRing &otherRing =
static_cast<const GeoDataLinearRing&
>(other);
93 return thisRing == otherRing;
94 }
else if (
nodeType() == GeoDataTypes::GeoDataLineStringType) {
95 const GeoDataLineString &thisLine =
static_cast<const GeoDataLineString &
>(*this);
96 const GeoDataLineString &otherLine =
static_cast<const GeoDataLineString &
>(other);
98 return thisLine == otherLine;
99 }
else if (
nodeType() == GeoDataTypes::GeoDataModelType) {
100 const GeoDataModel &thisModel =
static_cast<const GeoDataModel &
>(*this);
101 const GeoDataModel &otherModel =
static_cast<const GeoDataModel &
>(other);
103 return thisModel == otherModel;
104 }
else if (
nodeType() == GeoDataTypes::GeoDataMultiGeometryType) {
105 const GeoDataMultiGeometry &thisMG =
static_cast<const GeoDataMultiGeometry &
>(*this);
106 const GeoDataMultiGeometry &otherMG =
static_cast<const GeoDataMultiGeometry &
>(other);
108 return thisMG == otherMG;
109 }
else if (
nodeType() == GeoDataTypes::GeoDataTrackType) {
110 const GeoDataTrack &thisTrack =
static_cast<const GeoDataTrack &
>(*this);
111 const GeoDataTrack &otherTrack =
static_cast<const GeoDataTrack &
>(other);
113 return thisTrack == otherTrack;
114 }
else if (
nodeType() == GeoDataTypes::GeoDataMultiTrackType) {
115 const GeoDataMultiTrack &thisMT =
static_cast<const GeoDataMultiTrack &
>(*this);
116 const GeoDataMultiTrack &otherMT =
static_cast<const GeoDataMultiTrack &
>(other);
118 return thisMT == otherMT;
119 }
else if (
nodeType() == GeoDataTypes::GeoDataPointType) {
120 const GeoDataPoint &thisPoint =
static_cast<const GeoDataPoint &
>(*this);
121 const GeoDataPoint &otherPoint =
static_cast<const GeoDataPoint &
>(other);
123 return thisPoint == otherPoint;
129 bool GeoDataGeometry::extrude()
const
131 return d_ptr->m_extrude;
134 void GeoDataGeometry::setExtrude(
bool extrude )
137 d_ptr->m_extrude = extrude;
142 return d_ptr->m_altitudeMode;
145 void GeoDataGeometry::setAltitudeMode(
const AltitudeMode altitudeMode )
148 d_ptr->m_altitudeMode = altitudeMode;
151 const GeoDataLatLonAltBox& GeoDataGeometry::latLonAltBox()
const
153 return d_ptr->m_latLonAltBox;
160 stream << d_ptr->m_extrude;
161 stream << d_ptr->m_altitudeMode;
170 stream >> d_ptr->m_extrude;
178 d_ptr->m_extrude == other.d_ptr->m_extrude &&
179 d_ptr->m_altitudeMode == other.d_ptr->m_altitudeMode;