File indexing completed on 2025-01-05 03:58:59
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Patrick Spendrin <ps_ml@gmx.de> 0004 // 0005 0006 #ifndef MARBLE_GEODATAPLACEMARKPRIVATE_H 0007 #define MARBLE_GEODATAPLACEMARKPRIVATE_H 0008 0009 #include "GeoDataFeature_p.h" 0010 0011 #include "GeoDataPoint.h" 0012 #include "GeoDataLinearRing.h" 0013 #include "GeoDataPolygon.h" 0014 #include "GeoDataMultiTrack.h" 0015 #include "GeoDataTrack.h" 0016 #include "GeoDataTypes.h" 0017 #include "GeoDataMultiGeometry.h" 0018 #include "OsmPlacemarkData.h" 0019 0020 namespace Marble 0021 { 0022 0023 class GeoDataPlacemarkExtendedData 0024 { 0025 public: 0026 GeoDataPlacemarkExtendedData() : 0027 m_area( -1.0 ), 0028 m_isBalloonVisible( false ) 0029 { 0030 // nothing to do 0031 } 0032 GeoDataPlacemarkExtendedData & operator=(const GeoDataPlacemarkExtendedData &other) 0033 { 0034 m_countrycode = other.m_countrycode; 0035 m_area = other.m_area; 0036 m_state = other.m_state; 0037 m_isBalloonVisible = other.m_isBalloonVisible; 0038 return *this; 0039 } 0040 0041 bool operator==(const GeoDataPlacemarkExtendedData &other) const 0042 { 0043 return m_countrycode == other.m_countrycode && 0044 m_area == other.m_area && 0045 m_state == other.m_state; 0046 } 0047 0048 bool operator!=(const GeoDataPlacemarkExtendedData &other) const 0049 { 0050 return !(*this == other); 0051 } 0052 0053 QString m_countrycode; // Country code. 0054 qreal m_area; // Area in square kilometer 0055 QString m_state; // State 0056 bool m_isBalloonVisible; //Visibility of balloon 0057 }; 0058 0059 class GeoDataPlacemarkPrivate : public GeoDataFeaturePrivate 0060 { 0061 Q_DECLARE_TR_FUNCTIONS(GeoDataPlacemark) 0062 0063 public: 0064 GeoDataPlacemarkPrivate() : 0065 m_geometry(new GeoDataPoint), 0066 m_population( -1 ), 0067 m_placemarkExtendedData(nullptr), 0068 m_visualCategory(GeoDataPlacemark::Default), 0069 m_osmPlacemarkData(nullptr) 0070 { 0071 } 0072 0073 GeoDataPlacemarkPrivate(const GeoDataPlacemarkPrivate& other) 0074 : GeoDataFeaturePrivate(other), 0075 m_geometry(other.m_geometry->copy()), 0076 m_population(other.m_population), 0077 m_placemarkExtendedData(nullptr), 0078 m_visualCategory(other.m_visualCategory), 0079 m_osmPlacemarkData(nullptr) 0080 { 0081 if (other.m_placemarkExtendedData) { 0082 m_placemarkExtendedData = new GeoDataPlacemarkExtendedData(*other.m_placemarkExtendedData); 0083 } 0084 if (other.m_osmPlacemarkData) { 0085 m_osmPlacemarkData = new OsmPlacemarkData(*other.m_osmPlacemarkData); 0086 } 0087 } 0088 0089 ~GeoDataPlacemarkPrivate() override 0090 { 0091 delete m_geometry; 0092 delete m_placemarkExtendedData; 0093 delete m_osmPlacemarkData; 0094 } 0095 0096 GeoDataPlacemarkPrivate& operator=( const GeoDataPlacemarkPrivate& other ) 0097 { 0098 if ( this == &other ) { 0099 return *this; 0100 } 0101 0102 GeoDataFeaturePrivate::operator=( other ); 0103 0104 m_population = other.m_population; 0105 m_visualCategory = other.m_visualCategory; 0106 0107 delete m_geometry; 0108 m_geometry = other.m_geometry->copy(); 0109 // TODO: why not set parent here to geometry? 0110 0111 delete m_placemarkExtendedData; 0112 if (other.m_placemarkExtendedData) { 0113 m_placemarkExtendedData = new GeoDataPlacemarkExtendedData(*other.m_placemarkExtendedData); 0114 } else { 0115 m_placemarkExtendedData = nullptr; 0116 } 0117 0118 delete m_osmPlacemarkData; 0119 if (other.m_osmPlacemarkData) { 0120 m_osmPlacemarkData = new OsmPlacemarkData(*other.m_osmPlacemarkData); 0121 } else { 0122 m_osmPlacemarkData = nullptr; 0123 } 0124 0125 return *this; 0126 } 0127 0128 EnumFeatureId featureId() const override 0129 { 0130 return GeoDataPlacemarkId; 0131 } 0132 0133 GeoDataPlacemarkExtendedData & placemarkExtendedData() 0134 { 0135 if (!m_placemarkExtendedData) { 0136 m_placemarkExtendedData = new GeoDataPlacemarkExtendedData; 0137 } 0138 0139 return *m_placemarkExtendedData; 0140 } 0141 0142 const GeoDataPlacemarkExtendedData & placemarkExtendedData() const 0143 { 0144 return m_placemarkExtendedData ? *m_placemarkExtendedData : s_nullPlacemarkExtendedData; 0145 } 0146 0147 OsmPlacemarkData & osmPlacemarkData() 0148 { 0149 if (!m_osmPlacemarkData) { 0150 m_osmPlacemarkData = new OsmPlacemarkData; 0151 } 0152 return *m_osmPlacemarkData; 0153 } 0154 0155 const OsmPlacemarkData & osmPlacemarkData() const 0156 { 0157 return m_osmPlacemarkData ? *m_osmPlacemarkData : s_nullOsmPlacemarkData; 0158 } 0159 0160 // Data for a Placemark in addition to those in GeoDataFeature. 0161 GeoDataGeometry *m_geometry; // any GeoDataGeometry entry like locations 0162 qint64 m_population; // population in number of inhabitants 0163 GeoDataPlacemarkExtendedData *m_placemarkExtendedData; 0164 GeoDataPlacemark::GeoDataVisualCategory m_visualCategory; // the visual category 0165 0166 OsmPlacemarkData* m_osmPlacemarkData; 0167 static const OsmPlacemarkData s_nullOsmPlacemarkData; 0168 static const GeoDataPlacemarkExtendedData s_nullPlacemarkExtendedData; 0169 }; 0170 0171 } // namespace Marble 0172 0173 #endif