libosmscout 1.1.1
Loading...
Searching...
No Matches
OverlayObject.h
Go to the documentation of this file.
1#ifndef OSMSCOUT_CLIENT_QT_OVERLAYOBJECT_H
2#define OSMSCOUT_CLIENT_QT_OVERLAYOBJECT_H
3
4/*
5 OSMScout - a Qt backend for libosmscout and libosmscout-map
6
7 Copyright (C) 2017 Lukáš Karas
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <QObject>
25#include <QMutex>
26#include <QMutexLocker>
27
28#include <osmscout/Way.h>
29#include <osmscout/Area.h>
30#include <osmscout/Node.h>
34
35#include <optional>
36
37namespace osmscout {
38
46{
47 Q_OBJECT
48 Q_PROPERTY(QString type READ getTypeName WRITE setTypeName)
49 Q_PROPERTY(int size READ getSize)
50 Q_PROPERTY(QString objectType READ getObjectTypeStr)
51 Q_PROPERTY(qint8 layer READ getLayer WRITE setLayer)
52 Q_PROPERTY(QString name READ getName WRITE setName)
53 Q_PROPERTY(QString color READ getColor WRITE setColor)
55
56protected:
57 QString typeName;
58 std::vector<osmscout::Point> nodes;
60 mutable osmscout::GeoBox box;
61 int8_t layer{std::numeric_limits<int8_t>::max()};
62 QString name;
63 QString color;
64 mutable QMutex lock;
65 std::optional<osmscout::Color> colorValue;
66
67public slots:
68 void clear();
69 void addPoint(double lat, double lon);
70
71signals:
73
74public:
75 explicit OverlayObject(QObject *parent=Q_NULLPTR);
76
77 explicit OverlayObject(const std::vector<osmscout::Point> &nodes,
78 QString typeName="_route",
79 QObject *parent=Q_NULLPTR);
80
82
83 ~OverlayObject() override;
84
88
89 QString getObjectTypeStr() const {
90 switch (getObjectType()){
92 return "area";
94 return "way";
96 return "node";
97 default:
98 return "none";
99 }
100 }
101
102 QString getTypeName() const
103 {
104 QMutexLocker locker(&lock);
105 return typeName;
106 }
107
108 void setTypeName(const QString &name){
109 QMutexLocker locker(&lock);
111 }
112
113 size_t getSize(){
114 QMutexLocker locker(&lock);
115 return nodes.size();
116 }
117
118 qint8 getLayer() const
119 {
120 QMutexLocker locker(&lock);
121 return layer;
122 }
123
124 void setLayer(qint8 l)
125 {
126 QMutexLocker locker(&lock);
127 layer = l;
128 }
129
130 QString getName() const
131 {
132 QMutexLocker locker(&lock);
133 return name;
134 }
135
136 void setName(const QString &n)
137 {
138 QMutexLocker locker(&lock);
139 name = n;
140 }
141
142 QString getColor() const
143 {
144 QMutexLocker locker(&lock);
145 return color;
146 }
147
148 void setColor(const QString &c);
149 void setColorValue(Color &c);
150
152 osmscout::GeoBox boundingBox() const;
153 std::vector<osmscout::GeoCoord> getCoords() const;
154 std::vector<osmscout::Point> getPoints() const;
155
156protected:
158 osmscout::FeatureValueBuffer &features) const;
159
160 // internal, lock have to be acquired
161 osmscout::GeoBox boundingBoxInternal() const;
162
163 // internal, lock have to be acquired
164 std::vector<SegmentGeoBox> segments() const;
165};
166
167
169{
170Q_OBJECT
171
172public:
173 explicit OverlayArea(QObject *parent=Q_NULLPTR);
174
175 explicit OverlayArea(const std::vector<osmscout::Point> &nodes,
176 QString typeName="_route",
177 QObject *parent=Q_NULLPTR);
178
179 ~OverlayArea() override;
180
183 }
184
186 const osmscout::TypeConfig &typeConfig) const;
187};
188
190{
191Q_OBJECT
192
193public:
194 explicit OverlayWay(QObject *parent=Q_NULLPTR);
195
196 explicit OverlayWay(const std::vector<osmscout::Point> &nodes,
197 QString typeName="_route",
198 QObject *parent=Q_NULLPTR);
199
200 ~OverlayWay() override;
201
204 }
205
207 const osmscout::TypeConfig &typeConfig) const;
208};
209
211{
212Q_OBJECT
213
214public:
215 explicit OverlayNode(QObject *parent=Q_NULLPTR);
216
217 explicit OverlayNode(const std::vector<osmscout::Point> &nodes,
218 QString typeName="_route",
219 QObject *parent=Q_NULLPTR);
220
221 ~OverlayNode() override;
222
225 }
226
228 const osmscout::TypeConfig &typeConfig) const;
229};
230
231
232using OverlayObjectRef = std::shared_ptr<OverlayObject>;
233
234}
235
236#endif /* OSMSCOUT_CLIENT_QT_OVERLAYOBJECT_H */
#define OSMSCOUT_CLIENT_QT_API
Definition ClientQtImportExport.h:45
Definition LocationEntry.h:47
OverlayArea(const std::vector< osmscout::Point > &nodes, QString typeName="_route", QObject *parent=Q_NULLPTR)
bool toArea(osmscout::AreaRef &area, const osmscout::TypeConfig &typeConfig) const
osmscout::RefType getObjectType() const override
Definition OverlayObject.h:181
OverlayArea(QObject *parent=Q_NULLPTR)
OverlayNode(QObject *parent=Q_NULLPTR)
OverlayNode(const std::vector< osmscout::Point > &nodes, QString typeName="_route", QObject *parent=Q_NULLPTR)
bool toNode(osmscout::NodeRef &node, const osmscout::TypeConfig &typeConfig) const
osmscout::RefType getObjectType() const override
Definition OverlayObject.h:223
void setName(const QString &n)
Definition OverlayObject.h:136
std::vector< osmscout::Point > nodes
Definition OverlayObject.h:58
QMutex lock
Definition OverlayObject.h:64
qint8 layer
Definition OverlayObject.h:51
std::vector< osmscout::Point > getPoints() const
QString getObjectTypeStr() const
Definition OverlayObject.h:89
OverlayObject(const std::vector< osmscout::Point > &nodes, QString typeName="_route", QObject *parent=Q_NULLPTR)
void setColor(const QString &c)
OverlayObject(const OverlayObject &o)
LocationEntry * boundingBox
Definition OverlayObject.h:54
void setTypeName(const QString &name)
Definition OverlayObject.h:108
void setupFeatures(const osmscout::TypeInfoRef &type, osmscout::FeatureValueBuffer &features) const
osmscout::GeoBox box
Definition OverlayObject.h:60
void setColorValue(Color &c)
QString typeName
Definition OverlayObject.h:57
qint8 getLayer() const
Definition OverlayObject.h:118
std::vector< SegmentGeoBox > segmentsBoxes
Definition OverlayObject.h:59
virtual osmscout::RefType getObjectType() const
Definition OverlayObject.h:85
QString name
Definition OverlayObject.h:52
QString getTypeName() const
Definition OverlayObject.h:102
std::vector< osmscout::GeoCoord > getCoords() const
QString type
Definition OverlayObject.h:48
QString color
Definition OverlayObject.h:53
int size
Definition OverlayObject.h:49
void addPoint(double lat, double lon)
void setLayer(qint8 l)
Definition OverlayObject.h:124
std::vector< SegmentGeoBox > segments() const
size_t getSize()
Definition OverlayObject.h:113
QString getName() const
Definition OverlayObject.h:130
osmscout::GeoBox boundingBoxInternal() const
QString objectType
Definition OverlayObject.h:50
QString getColor() const
Definition OverlayObject.h:142
OverlayObject(QObject *parent=Q_NULLPTR)
std::optional< osmscout::Color > colorValue
Definition OverlayObject.h:65
LocationEntry * getBBoxAsLocation() const
osmscout::GeoBox boundingBox() const
bool toWay(osmscout::WayRef &way, const osmscout::TypeConfig &typeConfig) const
osmscout::RefType getObjectType() const override
Definition OverlayObject.h:202
~OverlayWay() override
OverlayWay(const std::vector< osmscout::Point > &nodes, QString typeName="_route", QObject *parent=Q_NULLPTR)
OverlayWay(QObject *parent=Q_NULLPTR)
Definition Area.h:39
std::shared_ptr< Way > WayRef
Definition Way.h:213
std::shared_ptr< Area > AreaRef
Definition Area.h:360
RefType
Definition ObjectRef.h:139
@ refNode
Definition ObjectRef.h:141
@ refArea
Definition ObjectRef.h:142
@ refWay
Definition ObjectRef.h:143
@ refNone
Definition ObjectRef.h:140
std::shared_ptr< TypeInfo > TypeInfoRef
Definition TypeConfig.h:61
std::shared_ptr< OverlayObject > OverlayObjectRef
Definition OverlayObject.h:232
std::shared_ptr< Node > NodeRef
Definition Node.h:125
STL namespace.
Definition Geometry.h:1190