1
#ifndef MERKAARTOR_ROAD_H_
2
#define MERKAARTOR_ROAD_H_
6
#include "Maps/MapDocument.h"
7
#include "Maps/MapFeature.h"
8
#include "Maps/MapLayer.h"
11
#include <ggl/ggl.hpp>
16
class QProgressDialog;
18
class Road : public MapFeature
24
Road(const Road& other);
28
virtual QString getClass() const {return "Road";}
29
virtual MapFeature::FeatureType getType() const {return MapFeature::Nodes;}
30
virtual void updateMeta();
32
virtual CoordBox boundingBox() const;
33
virtual void draw(QPainter& P, MapView* theView);
34
virtual void drawFocus(QPainter& P, MapView* theView, bool solid=true);
35
virtual void drawHover(QPainter& P, MapView* theView, bool solid=true);
36
virtual void drawHighlight(QPainter& P, MapView* theView, bool solid=true);
37
virtual double pixelDistance(const QPointF& Target, double ClearEndDistance, const Projection& theProjection, const QTransform& theTransform) const;
38
virtual void cascadedRemoveIfUsing(MapDocument* theDocument, MapFeature* aFeature, CommandList* theList, const QList<MapFeature*>& Alternatives);
39
virtual bool notEverythingDownloaded();
40
virtual QString description() const;
41
virtual RenderPriority renderPriority();
42
virtual RenderPriority getRenderPriority();
44
virtual void add(TrackPoint* Pt);
45
virtual void add(TrackPoint* Pt, int Idx);
46
virtual void remove(int Idx);
47
virtual void remove(MapFeature* F);
48
virtual int size() const;
49
virtual int find(MapFeature* Pt) const;
50
virtual MapFeature* get(int idx);
51
virtual const MapFeature* get(int Idx) const;
52
virtual bool isNull() const;
54
const QList<Coord>& smoothed() const;
56
TrackPoint* getNode(int idx);
57
const TrackPoint* getNode(int idx) const;
58
const std::vector<TrackPointPtr>& getNodes() const;
60
bool isNodeAtEnd(TrackPoint* node);
62
/** Set the tag "key=value" to the current object
63
* If a tag with the same key exist, it is replaced
64
* Otherwise the tag is added at the end
65
* @param key the key of the tag
66
* @param value the value corresponding to the key
68
virtual void setTag(const QString& key, const QString& value, bool addToTagList=true);
70
/** Set the tag "key=value" at the position index
71
* If a tag with the same key exist, it is replaced
72
* Otherwise the tag is added at the index position
73
* @param index the place for the given tag. Start at 0.
74
* @param key the key of the tag
75
* @param value the value corresponding to the key
77
virtual void setTag(int index, const QString& key, const QString& value, bool addToTagList=true);
79
/** remove all the tags for the curent feature
81
virtual void clearTags();
83
/** remove the tag with the key "k".
84
* if no corresponding tag, don't do anything
86
virtual void clearTag(const QString& k);
88
virtual void partChanged(MapFeature* F, int ChangeId);
89
virtual void setLayer(MapLayer* aLayer);
93
bool isClosed() const;
97
virtual bool deleteChildren(MapDocument* theDocument, CommandList* theList);
99
QPainterPath getPath();
100
void buildPath(Projection const &theProjection, const QTransform& theTransform, const QRectF& clipRect);
102
virtual bool toGPX(QDomElement xParent, QProgressDialog & progress, bool forExport=false);
103
virtual QString toXML(int lvl=0, QProgressDialog * progress=NULL);
104
virtual bool toXML(QDomElement xParent, QProgressDialog & progress);
105
static Road* fromXML(MapDocument* d, MapLayer* L, const QDomElement e);
107
virtual QString toHtml();
109
virtual void toBinary(QDataStream& ds, QHash <QString, quint64>& theIndex);
110
static Road* fromBinary(MapDocument* d, OsbMapLayer* L, QDataStream& ds, qint8 c, qint64 id);
112
bool isExtrimity(TrackPoint* node);
113
static Road * GetSingleParentRoad(MapFeature * mapFeature);
114
static Road * GetSingleParentRoadInner(MapFeature * mapFeature);
120
Q_DECLARE_METATYPE( Road * );
122
MapFeature::TrafficDirectionType trafficDirection(const Road* R);
123
int findSnapPointIndex(const Road* R, Coord& P);