File indexing completed on 2025-01-05 03:58:57
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Mayank Madan <maddiemadan@gmail.com> 0004 // SPDX-FileCopyrightText: 2013 Sanjiban Bairagya <sanjiban22393@gmail.com> 0005 // 0006 0007 #include "GeoDataModel.h" 0008 #include "GeoDataGeometry_p.h" 0009 0010 #include "GeoDataTypes.h" 0011 #include "GeoDataLocation.h" 0012 #include "GeoDataOrientation.h" 0013 #include "GeoDataResourceMap.h" 0014 #include "GeoDataScale.h" 0015 0016 #include <cstdio> 0017 0018 namespace Marble { 0019 0020 class GeoDataModelPrivate : public GeoDataGeometryPrivate 0021 { 0022 public: 0023 GeoDataModelPrivate(); 0024 0025 GeoDataGeometryPrivate *copy() const override { return new GeoDataModelPrivate( *this ); } 0026 0027 GeoDataCoordinates m_coordinates; 0028 0029 GeoDataScale m_scale; 0030 GeoDataOrientation m_orientation; 0031 GeoDataLocation m_location; 0032 GeoDataLink m_link; 0033 GeoDataResourceMap m_map; 0034 QString m_targetHref; 0035 QString m_sourceHref; 0036 }; 0037 0038 GeoDataModelPrivate::GeoDataModelPrivate() : 0039 m_coordinates(), 0040 m_scale(), 0041 m_orientation(), 0042 m_location(), 0043 m_link(), 0044 m_map(), 0045 m_targetHref(), 0046 m_sourceHref() 0047 { 0048 } 0049 0050 GeoDataModel::GeoDataModel() : 0051 GeoDataGeometry( new GeoDataModelPrivate ) 0052 { 0053 setAltitudeMode( ClampToGround ); 0054 } 0055 0056 GeoDataModel::GeoDataModel( const GeoDataModel &other ) : 0057 GeoDataGeometry( other ) 0058 { 0059 // nothing to do 0060 } 0061 0062 GeoDataModel &GeoDataModel::operator=( const GeoDataModel &other ) 0063 { 0064 GeoDataGeometry::operator=( other ); 0065 return *this; 0066 } 0067 0068 const char *GeoDataModel::nodeType() const 0069 { 0070 return GeoDataTypes::GeoDataModelType; 0071 } 0072 0073 EnumGeometryId GeoDataModel::geometryId() const 0074 { 0075 return GeoDataModelId; 0076 } 0077 0078 GeoDataGeometry *GeoDataModel::copy() const 0079 { 0080 return new GeoDataModel(*this); 0081 } 0082 0083 0084 bool GeoDataModel::operator==( const GeoDataModel &other ) const 0085 { 0086 Q_D(const GeoDataModel); 0087 const GeoDataModelPrivate *other_d = other.d_func(); 0088 0089 return equals(other) && 0090 d->m_coordinates == other_d->m_coordinates && 0091 d->m_scale == other_d->m_scale && 0092 d->m_orientation == other_d->m_orientation && 0093 d->m_location == other_d->m_location && 0094 d->m_link == other_d->m_link && 0095 d->m_map == other_d->m_map && 0096 d->m_targetHref == other_d->m_targetHref && 0097 d->m_sourceHref == other_d->m_sourceHref; 0098 } 0099 0100 bool GeoDataModel::operator!=( const GeoDataModel &other ) const 0101 { 0102 return !this->operator==( other ); 0103 } 0104 0105 GeoDataModel::~GeoDataModel() 0106 { 0107 } 0108 0109 const GeoDataCoordinates &GeoDataModel::coordinates() const 0110 { 0111 Q_D(const GeoDataModel); 0112 return d->m_coordinates; 0113 } 0114 0115 GeoDataCoordinates &GeoDataModel::coordinates() 0116 { 0117 detach(); 0118 0119 Q_D(GeoDataModel); 0120 return d->m_coordinates; 0121 } 0122 0123 const GeoDataLocation &GeoDataModel::location() const 0124 { 0125 Q_D(const GeoDataModel); 0126 return d->m_location; 0127 } 0128 0129 GeoDataLocation &GeoDataModel::location() 0130 { 0131 detach(); 0132 0133 Q_D(GeoDataModel); 0134 return d->m_location; 0135 } 0136 0137 void GeoDataModel::setCoordinates(const GeoDataCoordinates &coordinates) 0138 { 0139 detach(); 0140 0141 Q_D(GeoDataModel); 0142 d->m_coordinates = coordinates; 0143 } 0144 0145 void GeoDataModel::setLocation(const GeoDataLocation &location) 0146 { 0147 detach(); 0148 0149 Q_D(GeoDataModel); 0150 d->m_location = location; 0151 } 0152 0153 const GeoDataLink &GeoDataModel::link() const 0154 { 0155 Q_D(const GeoDataModel); 0156 return d->m_link; 0157 } 0158 0159 GeoDataLink &GeoDataModel::link() 0160 { 0161 detach(); 0162 0163 Q_D(GeoDataModel); 0164 return d->m_link; 0165 } 0166 0167 void GeoDataModel::setLink( const GeoDataLink &link ) 0168 { 0169 detach(); 0170 0171 Q_D(GeoDataModel); 0172 d->m_link = link; 0173 } 0174 0175 const GeoDataScale &GeoDataModel::scale() const 0176 { 0177 Q_D(const GeoDataModel); 0178 return d->m_scale; 0179 } 0180 0181 GeoDataScale &GeoDataModel::scale() 0182 { 0183 detach(); 0184 0185 Q_D(GeoDataModel); 0186 return d->m_scale; 0187 } 0188 0189 void GeoDataModel::setScale(const GeoDataScale &scale) 0190 { 0191 detach(); 0192 0193 Q_D(GeoDataModel); 0194 d->m_scale = scale; 0195 } 0196 0197 const GeoDataOrientation &GeoDataModel::orientation() const 0198 { 0199 Q_D(const GeoDataModel); 0200 return d->m_orientation; 0201 } 0202 0203 GeoDataOrientation &GeoDataModel::orientation() 0204 { 0205 detach(); 0206 0207 Q_D(GeoDataModel); 0208 return d->m_orientation; 0209 } 0210 0211 void GeoDataModel::setOrientation(const GeoDataOrientation &orientation) 0212 { 0213 detach(); 0214 0215 Q_D(GeoDataModel); 0216 d->m_orientation = orientation; 0217 } 0218 0219 const GeoDataResourceMap &GeoDataModel::resourceMap() const 0220 { 0221 Q_D(const GeoDataModel); 0222 return d->m_map; 0223 } 0224 0225 GeoDataResourceMap &GeoDataModel::resourceMap() 0226 { 0227 detach(); 0228 0229 Q_D(GeoDataModel); 0230 return d->m_map; 0231 } 0232 0233 void GeoDataModel::setResourceMap(const GeoDataResourceMap &map) 0234 { 0235 detach(); 0236 0237 Q_D(GeoDataModel); 0238 d->m_map = map; 0239 } 0240 0241 QString GeoDataModel::targetHref() const 0242 { 0243 Q_D(const GeoDataModel); 0244 return d->m_map.targetHref(); 0245 } 0246 0247 void GeoDataModel::setTargetHref(const QString &targetHref) 0248 { 0249 detach(); 0250 0251 Q_D(GeoDataModel); 0252 d->m_map.setTargetHref( targetHref ); 0253 } 0254 0255 QString GeoDataModel::sourceHref() const 0256 { 0257 Q_D(const GeoDataModel); 0258 return d->m_map.sourceHref(); 0259 } 0260 0261 void GeoDataModel::setSourceHref(const QString &sourceHref) 0262 { 0263 detach(); 0264 0265 Q_D(GeoDataModel); 0266 d->m_map.setSourceHref( sourceHref ); 0267 } 0268 0269 }