Skip to content

Commit 91f3cea

Browse files
committed
Merge pull request #591 from ccrook/delimited_text_to_core
Delimited text to core
2 parents 957c4f1 + 198cc39 commit 91f3cea

30 files changed

+982
-1519
lines changed

doc/plugins/delimited_text/dialog.png

-111 KB
Binary file not shown.
-292 Bytes
Binary file not shown.
-112 KB
Binary file not shown.
-110 KB
Binary file not shown.
-111 KB
Binary file not shown.
-115 KB
Binary file not shown.

doc/plugins/delimited_text/index.html

-70
This file was deleted.
-32.7 KB
Binary file not shown.
-20.9 KB
Binary file not shown.
-549 Bytes
Binary file not shown.

images/images.qrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
<file>themes/default/mActionAddWcsLayer.png</file>
141141
<file>themes/default/mActionAddWfsLayer.png</file>
142142
<file>themes/default/mActionAddWmsLayer.png</file>
143+
<file>themes/default/mActionAddDelimitedTextLayer.png</file>
143144
<file>themes/default/mActionAlignBottom.png</file>
144145
<file>themes/default/mActionAlignHCenter.png</file>
145146
<file>themes/default/mActionAlignLeft.png</file>
@@ -360,7 +361,6 @@
360361
<file>themes/default/plugin.png</file>
361362
<file>themes/default/plugins/coordinate_capture/coordinate_capture.png</file>
362363
<file>themes/default/plugins/copyright_label.png</file>
363-
<file>themes/default/plugins/delimited_text.png</file>
364364
<file>themes/default/plugins/dxf2shp_converter.png</file>
365365
<file>themes/default/plugins/gps_importer.png</file>
366366
<file>themes/default/plugins/gps_importer/create_gpx.png</file>

resources/context_help/QgsDelimitedTextSourceSelect-en_US

+41-28
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ It is safer to use an explicit coding if the QGIS project needs to be portable.
103103
&quot;Point&quot; includes POINT and MULTIPOINT WKT types, &quot;Line&quot; includes LINESTRING and
104104
MULTLINESTRING WKT types, and &quot;Polygon&quot; includes POLYGON and MULTIPOLYGON WKT types.
105105
</ul>
106+
<h5>Layer settings</h5>
107+
<p>Layer settings control the way the layer is managed in QGIS. The options available are:</p>
108+
<ul>
109+
<li>Use spatial index. Create a spatial index to improve the performance of displaying and selecting spatial objects.
110+
This option may be useful for files larger than a few megabytes in size.</li>
111+
<li>Use subset index. Create an index if a subset of records is being used (either by explicitly setting a subset string
112+
from the layer properties dialog, or an implicit subset of features for which the geometry is valid in files
113+
for which all not geometries are valid). The index will only be created when a subset is defined.</li>
114+
<li>Watch file. If this options is selected QGIS will watch the file for changes by other applications, and
115+
reload the file when it is changed. The map will not be updated until refreshed by the user, but indexes and
116+
extents will be reloaded. This option should be selected if indexes are used and it is likely that another
117+
application will change the file. </li>
118+
</ul>
106119

107120
<h4><a name="csv">How the delimiter, quote, and escape characters work</a></h4>
108121
<p>Records are split into fields using three character sets:
@@ -146,10 +159,10 @@ is invalid if it does not have capture groups. As an example this can be used a
146159
unintuitive) means of loading data with fixed width fields. For example the
147160
expression
148161
<pre>
149-
^(.{5})(.{10})(.{20})(.{20}).*
162+
^(.{5})(.{10})(.{20})(.{20})
150163
</pre>
151164
<p>will extract four fields of widths 5, 10, 20, and 20 characters from each line.
152-
Lines less than 45 characters long will be discarded.
165+
Lines less than 55 characters long will be discarded.
153166
</p>
154167

155168

@@ -197,10 +210,10 @@ are interpreted.
197210

198211
<h4><a name="example">Example of a text file with X,Y point coordinates</a></h4>
199212
<pre>
200-
X;Y;ELEV<br />
201-
-300120;7689960;13<br />
202-
-654360;7562040;52<br />
203-
1640;7512840;3<br />
213+
X;Y;ELEV
214+
-300120;7689960;13
215+
-654360;7562040;52
216+
1640;7512840;3
204217
</pre>
205218
<p>This file:</p>
206219
<ul>
@@ -211,12 +224,12 @@ X;Y;ELEV<br />
211224
</ul>
212225
<h4><a name="wkt_example">Example of a text file with WKT geometries</a></h4>
213226
<pre>
214-
id|wkt<br />
215-
1|POINT(172.0702250 -43.6031036)<br />
216-
2|POINT(172.0702250 -43.6031036)<br />
217-
3|POINT(172.1543206 -43.5731302)<br />
218-
4|POINT(171.9282585 -43.5493308)<br />
219-
5|POINT(171.8827359 -43.5875983)<br />
227+
id|wkt
228+
1|POINT(172.0702250 -43.6031036)
229+
2|POINT(172.0702250 -43.6031036)
230+
3|POINT(172.1543206 -43.5731302)
231+
4|POINT(171.9282585 -43.5493308)
232+
5|POINT(171.8827359 -43.5875983)
220233
</pre>
221234
<p>This file:</p>
222235
<ul>
@@ -230,20 +243,20 @@ id|wkt<br />
230243
The pattern is:
231244
</p>
232245
<pre>
233-
from PyQt4.QtCore import QUrl, QString<br />
234-
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry<br />
235-
<br />
236-
# Define the data source<br />
237-
filename="test.csv"<br />
238-
uri=QUrl.fromLocalFile(filename)<br />
239-
uri.addQueryItem("type","csv")<br />
240-
uri.addQueryItem("delimiter","|")<br />
241-
uri.addQueryItem("wktField","wkt")<br />
242-
# ... other delimited text parameters<br />
243-
layer=QgsVectorLayer(QString(uri.toEncoded()),"Test CSV layer","delimitedtext")<br />
244-
# Add the layer to the map<br />
245-
if layer.isValid():<br />
246-
QgsMapLayerRegistry.instance().addMapLayer( layer )<br />
246+
from PyQt4.QtCore import QUrl, QString
247+
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry
248+
249+
# Define the data source
250+
filename="test.csv"
251+
uri=QUrl.fromLocalFile(filename)
252+
uri.addQueryItem("type","csv")
253+
uri.addQueryItem("delimiter","|")
254+
uri.addQueryItem("wktField","wkt")
255+
# ... other delimited text parameters
256+
layer=QgsVectorLayer(QString(uri.toEncoded()),"Test CSV layer","delimitedtext")
257+
# Add the layer to the map
258+
if layer.isValid():
259+
QgsMapLayerRegistry.instance().addMapLayer( layer )
247260
</pre>
248261
<p>This could be used to load the second example file above.</p>
249262
<p>The configuration of the delimited text layer is defined by adding query items to the uri.
@@ -275,9 +288,9 @@ The following options can be added
275288
<li><tt>crs=...</tt> specifies the coordinate system to use for the vector layer, in a format accepted by QgsCoordinateReferenceSystem.createFromString (for example &quot;EPSG:4167&quot;). If this is not
276289
specified then a dialog box may request this information from the user
277290
when the layer is loaded (depending on QGIS CRS settings).</li>
278-
<li><tt>subsetIndex=(yes|no)</tt> specifies whether the provider should build an index to define subset during the initial file scan. The index will apply both for explicitly defined subsets, and for the implicit subset of features for which the geometry definition is valid. By default the subset index is built if it is applicable. This option is not available from the GUI.</li>
291+
<li><tt>subsetIndex=(yes|no)</tt> specifies whether the provider should build an index to define subset during the initial file scan. The index will apply both for explicitly defined subsets, and for the implicit subset of features for which the geometry definition is valid. By default the subset index is built if it is applicable.</li>
279292
<li><tt>spatialIndex=(yes|no)</tt> specifies whether the provider should build a spatial index during the initial file scan. By default the spatial index is not built. </li>
280-
<li><tt>useWatcher=(yes|no)</tt> specifies whether the provider should use a file system watcher to monitor for changes to the file. This option is not available from the GUI</li>
293+
<li><tt>watchFile=(yes|no)</tt> specifies whether the provider should use a file system watcher to monitor for changes to the file.</li>
281294
<li><tt>quiet=(yes|no)</tt> specifies whether errors encountered loading the layer are presented in a dialog box (they will be written to the QGIS log in any case). The default is no. This option is not available from the GUI</li>
282295
</ul>
283296

src/app/qgisapp.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ void QgisApp::createActions()
981981
connect( mActionAddWmsLayer, SIGNAL( triggered() ), this, SLOT( addWmsLayer() ) );
982982
connect( mActionAddWcsLayer, SIGNAL( triggered() ), this, SLOT( addWcsLayer() ) );
983983
connect( mActionAddWfsLayer, SIGNAL( triggered() ), this, SLOT( addWfsLayer() ) );
984+
connect( mActionAddDelimitedText, SIGNAL( triggered()), this, SLOT(addDelimitedTextLayer()));
984985
connect( mActionOpenTable, SIGNAL( triggered() ), this, SLOT( attributeTable() ) );
985986
connect( mActionOpenFieldCalc, SIGNAL( triggered() ), this, SLOT( fieldCalculator() ) );
986987
connect( mActionToggleEditing, SIGNAL( triggered() ), this, SLOT( toggleEditing() ) );
@@ -2973,6 +2974,31 @@ void QgisApp::addSpatiaLiteLayer()
29732974
delete dbs;
29742975
} // QgisApp::addSpatiaLiteLayer()
29752976

2977+
void QgisApp::addDelimitedTextLayer()
2978+
{
2979+
if ( mMapCanvas && mMapCanvas->isDrawing() )
2980+
{
2981+
return;
2982+
}
2983+
2984+
// show the Delimited text dialog
2985+
QDialog *dts = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "delimitedtext", this ) );
2986+
if ( !dts )
2987+
{
2988+
QMessageBox::warning( this, tr( "DelimitedText" ), tr( "Cannot get Delimited Text select dialog from provider." ) );
2989+
return;
2990+
}
2991+
connect( dts, SIGNAL( addVectorLayer( QString, QString, QString ) ),
2992+
this, SLOT( addSelectedVectorLayer( QString, QString, QString ) ) );
2993+
dts->exec();
2994+
delete dts;
2995+
} // QgisApp::addDelimitedTextLayer()
2996+
2997+
void QgisApp::addSelectedVectorLayer( QString uri, QString layerName, QString provider )
2998+
{
2999+
addVectorLayer( uri, layerName, provider );
3000+
} // QgisApp:addSelectedVectorLayer
3001+
29763002
void QgisApp::addMssqlLayer()
29773003
{
29783004
#ifdef HAVE_MSSQL

src/app/qgisapp.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
115115
*/
116116
QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey );
117117

118-
/** \brief overloaded vesion of the privat addLayer method that takes a list of
118+
/** \brief overloaded version of the private addLayer method that takes a list of
119119
* file names instead of prompting user with a dialog.
120120
@param enc encoding type for the layer
121121
@param dataSourceType type of ogr datasource
@@ -626,6 +626,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
626626
void addDatabaseLayers( QStringList const & layerPathList, QString const & providerKey );
627627
//! Add a SpatiaLite layer to the map
628628
void addSpatiaLiteLayer();
629+
//! Add a Delimited Text layer to the map
630+
void addDelimitedTextLayer();
631+
//! Add a vector layer defined by uri, layer name, data source uri
632+
void addSelectedVectorLayer(QString uri, QString layerName, QString provider );
629633
//#ifdef HAVE_MSSQL
630634
//! Add a MSSQL layer to the map
631635
void addMssqlLayer();

src/core/qgsvectorlayer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ struct CORE_EXPORT QgsVectorJoinInfo
384384
*
385385
* Determines whether the provider generates a spatial index. The default is no.
386386
*
387-
* -useWatcher=(yes|no)
387+
* -watchFile=(yes|no)
388388
*
389389
* Defines whether the file will be monitored for changes. The default is
390390
* to monitor for changes.

src/plugins/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})
33
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})
44

5-
ADD_SUBDIRECTORY(delimited_text)
65
ADD_SUBDIRECTORY(diagram_overlay)
76
ADD_SUBDIRECTORY(interpolation)
87
ADD_SUBDIRECTORY(oracle_raster)

src/plugins/delimited_text/CMakeLists.txt

-39
This file was deleted.

0 commit comments

Comments
 (0)