~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef IFEATURE_H
#define IFEATURE_H

#include <QString>
#include <QDateTime>
#include <QPair>
#include <QMetaType>

#define TECHNICAL_TAGS "created_by#source"
class QPainterPath;

class IFeature
{
public:
    typedef enum {
        Uninitialized       = 0x00,
        Point				= 0x01,
        LineString			= 0x02,
        Polygon             = 0x04,
        OsmRelation			= 0x08,
        GpxSegment			= 0x10,
        Conflict            = 0x20,
        Import              = 0x40,
        Special             = 0x80,
        All					= 0xff
    } FeatureType;

    struct FId {
        FId() : type(IFeature::Uninitialized), numId(0) {}
        FId(char a, qint64 b) : type(a), numId(b) {}

        bool operator==(const FId& R) const
        {
            return ((type == R.type) && (numId == R.numId));
        }
        unsigned char type;
        qint64 numId;
    };

public:
    virtual char getType() const = 0;

    virtual QString xmlId() const = 0;
    virtual const QDateTime& time() const = 0;
    virtual int versionNumber() const = 0;
    virtual const QString& user() const = 0;

    virtual int sizeParents() const = 0;
    virtual IFeature* getParent(int i) = 0;
    virtual const IFeature* getParent(int i) const = 0;

    virtual bool hasPainter(double PixelPerM) const = 0;

    /** Give the id of the feature.
     *  If the feature has no id, a random id is generated
     * @return the id of the current feature
     */
    virtual const IFeature::FId& id() const = 0;

    /** check if the feature is logically deleted
     * @return true if logically deleted
     */
    virtual bool isDeleted() const = 0;

    /** @return the number of tags for the current object
         */
    virtual int tagSize() const = 0;

    /** if a tag with the key "k" exists, return its index.
         * if the key doesn't exist, return the number of tags
         * @return index of tag
         */
    virtual int findKey(const QString& k) const = 0;

    /** return the value of the tag at the position "i".
         * position start at 0.
         * Be carefull: no verification is made on i.
         * @return the value
         */
    virtual QString tagValue(int i) const = 0;

    /** return the value of the tag with the key "k".
         * if such a tag doesn't exists, return Default.
         * @return value or Default
         */
    virtual QString tagValue(const QString& k, const QString& Default) const = 0;

    /** return the value of the tag at the position "i".
         * position start at 0.
         * Be carefull: no verification is made on i.
         * @return the value
        */
    virtual QString tagKey(int i) const = 0;


    /** check if the feature has been uploaded
     * @return true if uploaded
     */
    virtual bool isUploaded() const = 0;

    /** check if the dirty status of the feature
     * @return true if the feature is dirty
     */
    virtual bool isDirty() const = 0;

    /** check if the feature is visible
     * @return true if visible
     */
    virtual bool isVisible() = 0;

    /** check if the feature is read-only
     * @return true if is read-only
     */
    virtual bool isReadonly() = 0;

    virtual const QPainterPath& getPath() const = 0;
};

Q_DECLARE_METATYPE(IFeature::FId)

#endif // IFEATURE_H