File indexing completed on 2025-01-05 03:58:59
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2004-2007 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org> 0005 // SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de> 0006 // 0007 0008 0009 #include "GeoDataPoint.h" 0010 #include "GeoDataPoint_p.h" 0011 0012 0013 #include "digikam_debug.h" 0014 #include "MarbleGlobal.h" 0015 0016 #include "GeoDataTypes.h" 0017 #include "GeoDataLatLonAltBox.h" 0018 0019 0020 namespace Marble 0021 { 0022 0023 GeoDataPoint::GeoDataPoint( qreal lon, qreal lat, qreal alt, 0024 GeoDataCoordinates::Unit unit ) 0025 : GeoDataGeometry( new GeoDataPointPrivate ) 0026 { 0027 Q_D(GeoDataPoint); 0028 d->m_coordinates = GeoDataCoordinates(lon, lat, alt, unit); 0029 d->m_latLonAltBox = GeoDataLatLonAltBox(d->m_coordinates); 0030 } 0031 0032 GeoDataPoint::GeoDataPoint( const GeoDataPoint& other ) 0033 : GeoDataGeometry( other ) 0034 { 0035 Q_D(GeoDataPoint); 0036 const GeoDataPointPrivate * const otherD = other.d_func(); 0037 0038 d->m_coordinates = otherD->m_coordinates; 0039 d->m_latLonAltBox = otherD->m_latLonAltBox; 0040 } 0041 0042 GeoDataPoint::GeoDataPoint( const GeoDataCoordinates& other ) 0043 : GeoDataGeometry ( new GeoDataPointPrivate ) 0044 { 0045 Q_D(GeoDataPoint); 0046 d->m_coordinates = other; 0047 d->m_latLonAltBox = GeoDataLatLonAltBox(d->m_coordinates); 0048 } 0049 0050 GeoDataPoint::GeoDataPoint() 0051 : GeoDataGeometry( new GeoDataPointPrivate ) 0052 { 0053 // nothing to do 0054 } 0055 0056 GeoDataPoint::~GeoDataPoint() 0057 { 0058 // nothing to do 0059 } 0060 0061 EnumGeometryId GeoDataPoint::geometryId() const 0062 { 0063 return GeoDataPointId; 0064 } 0065 0066 GeoDataGeometry *GeoDataPoint::copy() const 0067 { 0068 return new GeoDataPoint(*this); 0069 } 0070 0071 bool GeoDataPoint::operator==( const GeoDataPoint &other ) const 0072 { 0073 return equals(other) && 0074 coordinates() == other.coordinates(); 0075 } 0076 0077 bool GeoDataPoint::operator!=( const GeoDataPoint &other ) const 0078 { 0079 return !this->operator==(other); 0080 } 0081 0082 void GeoDataPoint::setCoordinates( const GeoDataCoordinates &coordinates ) 0083 { 0084 detach(); 0085 0086 Q_D(GeoDataPoint); 0087 d->m_coordinates = coordinates; 0088 d->m_latLonAltBox = GeoDataLatLonAltBox(d->m_coordinates); 0089 } 0090 0091 const GeoDataCoordinates &GeoDataPoint::coordinates() const 0092 { 0093 Q_D(const GeoDataPoint); 0094 return d->m_coordinates; 0095 } 0096 0097 const char* GeoDataPoint::nodeType() const 0098 { 0099 return GeoDataTypes::GeoDataPointType; 0100 } 0101 0102 void GeoDataPoint::detach() 0103 { 0104 GeoDataGeometry::detach(); 0105 } 0106 0107 void GeoDataPoint::pack( QDataStream& stream ) const 0108 { 0109 Q_D(const GeoDataPoint); 0110 d->m_coordinates.pack(stream); 0111 // TODO: what about m_latLonAltBox and base class? 0112 } 0113 0114 void GeoDataPoint::unpack( QDataStream& stream ) 0115 { 0116 Q_D(GeoDataPoint); 0117 d->m_coordinates.unpack(stream); 0118 // TODO: what about m_latLonAltBox and base class? 0119 } 0120 0121 }