This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathqgsvirtuallayerdefinition.h
104 lines (81 loc) · 3.75 KB
/
qgsvirtuallayerdefinition.h
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
/***************************************************************************
qgsvirtuallayerdefinition.h
begin : Feb, 2015
copyright : (C) 2015 Hugo Mercier, Oslandia
email : hugo dot mercier at oslandia dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSVIRTUALLAYERDEFINITION_H
#define QGSVIRTUALLAYERDEFINITION_H
#include <qgsfield.h>
#include <qgis.h>
class QgsVirtualLayerDefinition
{
public:
class SourceLayer
{
public:
SourceLayer( const QString& name, const QString& ref ) : mName(name), mRef(ref) {}
SourceLayer( const QString& name, const QString& source, const QString& provider, const QString& encoding )
: mName(name), mSource(source), mProvider(provider), mEncoding(encoding) {}
bool isReferenced() const { return !mRef.isEmpty(); }
QString reference() const { return mRef; }
QString name() const { return mName; }
QString provider() const { return mProvider; }
QString source() const { return mSource; }
QString encoding() const { return mEncoding; }
private:
QString mName;
QString mSource;
QString mProvider;
QString mRef;
QString mEncoding;
};
QgsVirtualLayerDefinition( const QString& uri = "" ) : mUri(uri) {}
QgsVirtualLayerDefinition( const QUrl& );
void fromUrl( const QUrl& );
void addSource( const QString& name, const QString ref )
{
mSourceLayers.append( SourceLayer(name, ref) );
}
void addSource( const QString& name, const QString source, const QString& provider, const QString& encoding )
{
mSourceLayers.append( SourceLayer(name, source, provider, encoding) );
}
const QList<SourceLayer>& sourceLayers() const { return mSourceLayers; }
bool hasSourceLayer( QString name ) const;
bool hasReferencedLayers() const;
QString query() const { return mQuery; }
void setQuery( const QString& query ) { mQuery = query; }
QString uri() const { return mUri; }
void setURI( const QString& uri ) { mUri = uri; }
QString uid() const { return mUid; }
void setUid( const QString& uid ) { mUid = uid; }
QString geometryField() const { return mGeometryField; }
void setGeometryField( const QString& geometryField ) { mGeometryField = geometryField; }
QGis::WkbType geometryWkbType() const { return mGeometryWkbType; }
void setGeometryWkbType( QGis::WkbType t ) { mGeometryWkbType = t; }
long geometrySrid() const { return mGeometrySrid; }
void setGeometrySrid( long srid ) { mGeometrySrid = srid; }
QgsFields overridenFields() const { return mOverridenFields; }
void setOverridenFields( const QgsFields& fields ) { mOverridenFields = fields; }
private:
QList<SourceLayer> mSourceLayers;
QString mQuery;
QString mUid;
QString mGeometryField;
QString mUri;
QgsFields mOverridenFields;
QGis::WkbType mGeometryWkbType;
long mGeometrySrid;
};
QGis::WkbType geometry_type_to_wkb_type( const QString& wkb_str );
QgsVirtualLayerDefinition virtualLayerDefinitionFromSqlite( const QString& path );
#endif