29
28
class QDomDocument;
34
33
\class QgsGPXProvider
35
34
\brief Data provider for GPX (GPS eXchange) files
36
35
* This provider adds the ability to load GPX files as vector layers.
39
class QgsGPXProvider : public QgsVectorDataProvider {
41
QgsGPXProvider(QString const & uri = "");
42
virtual ~QgsGPXProvider();
45
* Returns the permanent storage type for this layer as a friendly name.
47
QString storageType();
49
/** Used to ask the layer for its projection as a WKT string. Implements
50
virtual method of same name in QgsDataProvider. */
51
QString getProjectionWKT();
53
* Get the first feature resulting from a select operation
56
QgsFeature * getFirstFeature(bool fetchAttributes=false);
58
* Get the next feature resutling from a select operation
61
QgsFeature * getNextFeature(bool fetchAttributes=false);
62
bool getNextFeature(QgsFeature &feature, bool fetchAttributes=false);
63
QgsFeature * getNextFeature(std::list<int> const & attlist, int featureQueueSize = 1);
65
/** Get the feature type. This corresponds to
72
* as defined in qgis.h
73
* This provider will always return WKBPoint
75
int geometryType() const;
77
* Get the number of features in the layer
79
long featureCount() const;
81
* Get the number of fields in the layer
83
int fieldCount() const;
85
* Select features based on a bounding rectangle. Features can be retrieved
86
* with calls to getFirstFeature and getNextFeature.
87
* @param mbr QgsRect containing the extent to use in selecting features
89
void select(QgsRect *mbr, bool useIntersect=false);
91
* Set the data source specification. This may be a path or database
93
* @uri data source specification
95
void setDataSourceUri(QString uri);
98
* Get the data source specification. This may be a path or database
100
* @return data source specification
102
QString getDataSourceUri();
105
* Identify features within the search radius specified by rect
106
* @param rect Bounding rectangle of search radius
107
* @return std::vector containing QgsFeature objects that intersect rect
109
virtual std::vector<QgsFeature>& identify(QgsRect *rect);
111
/** Return the extent for this data layer
113
virtual QgsRect * extent();
116
* Get the field information for the layer
118
std::vector<QgsField> const & fields() const;
120
/* Reset the layer (ie move the file pointer to the head
125
/**Returns the minimum value of an attribute
126
@param position the number of the attribute*/
127
QString minValue(int position);
129
/**Returns the maximum value of an attribute
130
@param position the number of the attribute*/
131
QString maxValue(int position);
133
/**Returns true if this is a valid delimited file
137
/**Adds a list of features
138
@return true in case of success and false in case of failure*/
139
bool addFeatures(std::list<QgsFeature*> flist);
141
bool deleteFeatures(std::list<int> const & id);
143
bool changeAttributeValues(std::map<int,std::map<QString,QString> > const &
146
void changeAttributeValues(GPSObject& obj,
147
const std::map<QString, QString>& attrs);
149
/** Adds one feature (used by addFeatures()) */
150
bool addFeature(QgsFeature* f);
152
/**Returns the default value for attribute @c attr for feature @c f. */
153
QString getDefaultValue(const QString& attr, QgsFeature* f);
156
* Check to see if the point is withn the selection
158
* @param x X value of point
159
* @param y Y value of point
160
* @return True if point is within the rectangle
162
bool boundsCheck(double x, double y);
164
int capabilities() const {
165
return AddFeatures | DeleteFeatures | ChangeAttributeValues;
168
QgsDataSourceURI *getURI()
173
/** return the number of layers for the current data source
177
Should this be subLayerCount() instead?
179
size_t layerCount() const;
182
/** return a provider name
184
Essentially just returns the provider key. Should be used to build file
185
dialogs so that providers can be shown with their supported types. Thus
186
if more than one provider supports a given format, the user is able to
187
select a specific provider to open that file.
191
Instead of being pure virtual, might be better to generalize this
192
behavior and presume that none of the sub-classes are going to do
193
anything strange with regards to their name or description?
196
QString name() const;
199
/** return description
201
Return a terse string describing what the provider is.
205
Instead of being pure virtual, might be better to generalize this
206
behavior and presume that none of the sub-classes are going to do
207
anything strange with regards to their name or description?
210
QString description() const;
215
/** Internal function used by the other getNextFeature() functions. */
216
bool getNextFeature(QgsFeature* feature, std::list<int> const & attlist);
220
void fillMinMaxCash();
222
std::vector<QgsField> attributeFields;
223
std::list<int> mAllAttributes;
224
//! Map to store field position by name
225
std::map<QString, int> fieldPositions;
229
enum { WaypointType, RouteType, TrackType } mFeatureType;
230
enum Attribute { NameAttr = 0, EleAttr, SymAttr, NumAttr,
231
CmtAttr, DscAttr, SrcAttr, URLAttr, URLNameAttr };
232
static const char* attr[];
233
//! Current selection rectangle
234
QgsRect *mSelectionRectangle;
237
long mNumberFeatures;
239
//! Current waypoint iterator
240
GPSData::WaypointIterator mWptIter;
241
//! Current route iterator
242
GPSData::RouteIterator mRteIter;
243
//! Current track iterator
244
GPSData::TrackIterator mTrkIter;
246
/**Flag indicating, if the minmaxcache should be renewed (true) or not (false)*/
247
bool mMinMaxCacheDirty;
248
/**Matrix storing the minimum and maximum values*/
249
double** mMinMaxCache;
250
/**Fills the cash and sets minmaxcachedirty to false*/
251
void mFillMinMaxCash();
38
class QgsGPXProvider : public QgsVectorDataProvider
44
QgsGPXProvider( QString uri = QString() );
45
virtual ~QgsGPXProvider();
47
/* Functions inherited from QgsVectorDataProvider */
50
* Returns the permanent storage type for this layer as a friendly name.
52
virtual QString storageType() const;
54
/** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
55
* @param fetchAttributes list of attributes which should be fetched
56
* @param rect spatial filter
57
* @param fetchGeometry true if the feature geometry should be fetched
58
* @param useIntersect true if an accurate intersection test should be used,
59
* false if a test based on bounding box is sufficient
61
virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
62
QgsRectangle rect = QgsRectangle(),
63
bool fetchGeometry = true,
64
bool useIntersect = false );
67
* Get the next feature resulting from a select operation.
68
* @param feature feature which will receive data from the provider
69
* @return true when there was a feature to fetch, false when end was hit
71
virtual bool nextFeature( QgsFeature& feature );
75
* @return int representing the feature type
77
virtual QGis::WkbType geometryType() const;
80
* Number of features in the layer
81
* @return long containing number of features
83
virtual long featureCount() const;
86
* Get the number of fields in the layer
88
virtual uint fieldCount() const;
91
* Get the field information for the layer
93
virtual const QgsFieldMap & fields() const;
95
/** Restart reading features from previous select operation */
96
virtual void rewind();
99
* Adds a list of features
100
* @return true in case of success and false in case of failure
102
virtual bool addFeatures( QgsFeatureList & flist );
106
* @param id list containing feature ids to delete
107
* @return true in case of success and false in case of failure
109
virtual bool deleteFeatures( const QgsFeatureIds & id );
112
* Changes attribute values of existing features.
113
* @param attr_map a map containing changed attributes
114
* @return true in case of success and false in case of failure
116
virtual bool changeAttributeValues( const QgsChangedAttributesMap & attr_map );
118
virtual int capabilities() const;
121
* Returns the default value for field specified by @c fieldId
123
virtual QVariant defaultValue( int fieldId );
126
/* Functions inherited from QgsDataProvider */
128
/** Return the extent for this data layer
130
virtual QgsRectangle extent();
132
/**Returns true if this is a valid delimited file
134
virtual bool isValid();
136
/** return a provider name */
137
virtual QString name() const;
139
/** return description */
140
virtual QString description() const;
142
virtual QgsCoordinateReferenceSystem crs();
147
void changeAttributeValues( QgsGPSObject& obj,
148
const QgsAttributeMap& attrs );
150
/** Adds one feature (used by addFeatures()) */
151
bool addFeature( QgsFeature& f );
154
* Check to see if the point is withn the selection
156
* @param x X value of point
157
* @param y Y value of point
158
* @return True if point is within the rectangle
160
bool boundsCheck( double x, double y );
168
QgsFieldMap attributeFields;
172
enum { WaypointType, RouteType, TrackType } mFeatureType;
173
enum Attribute { NameAttr = 0, EleAttr, SymAttr, NumAttr,
174
CmtAttr, DscAttr, SrcAttr, URLAttr, URLNameAttr
176
static const char* attr[];
177
//! Current selection rectangle
178
QgsRectangle *mSelectionRectangle;
180
long mNumberFeatures;
182
//! Current waypoint iterator
183
QgsGPSData::WaypointIterator mWptIter;
184
//! Current route iterator
185
QgsGPSData::RouteIterator mRteIter;
186
//! Current track iterator
187
QgsGPSData::TrackIterator mTrkIter;