Skip to content

Commit

Permalink
Merge pull request #591 from ccrook/delimited_text_to_core
Browse files Browse the repository at this point in the history
Delimited text to core
  • Loading branch information
timlinux committed May 17, 2013
2 parents 957c4f1 + 198cc39 commit 91f3cea
Show file tree
Hide file tree
Showing 30 changed files with 982 additions and 1,519 deletions.
Binary file removed doc/plugins/delimited_text/dialog.png
Binary file not shown.
Binary file removed doc/plugins/delimited_text/ellipsis.png
Binary file not shown.
Binary file removed doc/plugins/delimited_text/file_selected.png
Binary file not shown.
Binary file removed doc/plugins/delimited_text/file_selected1.png
Binary file not shown.
Binary file removed doc/plugins/delimited_text/file_selected2.png
Binary file not shown.
Binary file removed doc/plugins/delimited_text/file_selected3.png
Binary file not shown.
70 changes: 0 additions & 70 deletions doc/plugins/delimited_text/index.html

This file was deleted.

Binary file removed doc/plugins/delimited_text/layer_added.png
Binary file not shown.
Binary file removed doc/plugins/delimited_text/plugin_manager.png
Binary file not shown.
Binary file removed doc/plugins/delimited_text/toolbar_icon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion images/images.qrc
Expand Up @@ -140,6 +140,7 @@
<file>themes/default/mActionAddWcsLayer.png</file>
<file>themes/default/mActionAddWfsLayer.png</file>
<file>themes/default/mActionAddWmsLayer.png</file>
<file>themes/default/mActionAddDelimitedTextLayer.png</file>
<file>themes/default/mActionAlignBottom.png</file>
<file>themes/default/mActionAlignHCenter.png</file>
<file>themes/default/mActionAlignLeft.png</file>
Expand Down Expand Up @@ -360,7 +361,6 @@
<file>themes/default/plugin.png</file>
<file>themes/default/plugins/coordinate_capture/coordinate_capture.png</file>
<file>themes/default/plugins/copyright_label.png</file>
<file>themes/default/plugins/delimited_text.png</file>
<file>themes/default/plugins/dxf2shp_converter.png</file>
<file>themes/default/plugins/gps_importer.png</file>
<file>themes/default/plugins/gps_importer/create_gpx.png</file>
Expand Down
69 changes: 41 additions & 28 deletions resources/context_help/QgsDelimitedTextSourceSelect-en_US
Expand Up @@ -103,6 +103,19 @@ It is safer to use an explicit coding if the QGIS project needs to be portable.
&quot;Point&quot; includes POINT and MULTIPOINT WKT types, &quot;Line&quot; includes LINESTRING and
MULTLINESTRING WKT types, and &quot;Polygon&quot; includes POLYGON and MULTIPOLYGON WKT types.
</ul>
<h5>Layer settings</h5>
<p>Layer settings control the way the layer is managed in QGIS. The options available are:</p>
<ul>
<li>Use spatial index. Create a spatial index to improve the performance of displaying and selecting spatial objects.
This option may be useful for files larger than a few megabytes in size.</li>
<li>Use subset index. Create an index if a subset of records is being used (either by explicitly setting a subset string
from the layer properties dialog, or an implicit subset of features for which the geometry is valid in files
for which all not geometries are valid). The index will only be created when a subset is defined.</li>
<li>Watch file. If this options is selected QGIS will watch the file for changes by other applications, and
reload the file when it is changed. The map will not be updated until refreshed by the user, but indexes and
extents will be reloaded. This option should be selected if indexes are used and it is likely that another
application will change the file. </li>
</ul>

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


Expand Down Expand Up @@ -197,10 +210,10 @@ are interpreted.

<h4><a name="example">Example of a text file with X,Y point coordinates</a></h4>
<pre>
X;Y;ELEV<br />
-300120;7689960;13<br />
-654360;7562040;52<br />
1640;7512840;3<br />
X;Y;ELEV
-300120;7689960;13
-654360;7562040;52
1640;7512840;3
</pre>
<p>This file:</p>
<ul>
Expand All @@ -211,12 +224,12 @@ X;Y;ELEV<br />
</ul>
<h4><a name="wkt_example">Example of a text file with WKT geometries</a></h4>
<pre>
id|wkt<br />
1|POINT(172.0702250 -43.6031036)<br />
2|POINT(172.0702250 -43.6031036)<br />
3|POINT(172.1543206 -43.5731302)<br />
4|POINT(171.9282585 -43.5493308)<br />
5|POINT(171.8827359 -43.5875983)<br />
id|wkt
1|POINT(172.0702250 -43.6031036)
2|POINT(172.0702250 -43.6031036)
3|POINT(172.1543206 -43.5731302)
4|POINT(171.9282585 -43.5493308)
5|POINT(171.8827359 -43.5875983)
</pre>
<p>This file:</p>
<ul>
Expand All @@ -230,20 +243,20 @@ id|wkt<br />
The pattern is:
</p>
<pre>
from PyQt4.QtCore import QUrl, QString<br />
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry<br />
<br />
# Define the data source<br />
filename="test.csv"<br />
uri=QUrl.fromLocalFile(filename)<br />
uri.addQueryItem("type","csv")<br />
uri.addQueryItem("delimiter","|")<br />
uri.addQueryItem("wktField","wkt")<br />
# ... other delimited text parameters<br />
layer=QgsVectorLayer(QString(uri.toEncoded()),"Test CSV layer","delimitedtext")<br />
# Add the layer to the map<br />
if layer.isValid():<br />
QgsMapLayerRegistry.instance().addMapLayer( layer )<br />
from PyQt4.QtCore import QUrl, QString
from qgis.core import QgsVectorLayer, QgsMapLayerRegistry

# Define the data source
filename="test.csv"
uri=QUrl.fromLocalFile(filename)
uri.addQueryItem("type","csv")
uri.addQueryItem("delimiter","|")
uri.addQueryItem("wktField","wkt")
# ... other delimited text parameters
layer=QgsVectorLayer(QString(uri.toEncoded()),"Test CSV layer","delimitedtext")
# Add the layer to the map
if layer.isValid():
QgsMapLayerRegistry.instance().addMapLayer( layer )
</pre>
<p>This could be used to load the second example file above.</p>
<p>The configuration of the delimited text layer is defined by adding query items to the uri.
Expand Down Expand Up @@ -275,9 +288,9 @@ The following options can be added
<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
specified then a dialog box may request this information from the user
when the layer is loaded (depending on QGIS CRS settings).</li>
<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>
<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>
<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>
<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>
<li><tt>watchFile=(yes|no)</tt> specifies whether the provider should use a file system watcher to monitor for changes to the file.</li>
<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>
</ul>

Expand Down
26 changes: 26 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -981,6 +981,7 @@ void QgisApp::createActions()
connect( mActionAddWmsLayer, SIGNAL( triggered() ), this, SLOT( addWmsLayer() ) );
connect( mActionAddWcsLayer, SIGNAL( triggered() ), this, SLOT( addWcsLayer() ) );
connect( mActionAddWfsLayer, SIGNAL( triggered() ), this, SLOT( addWfsLayer() ) );
connect( mActionAddDelimitedText, SIGNAL( triggered()), this, SLOT(addDelimitedTextLayer()));
connect( mActionOpenTable, SIGNAL( triggered() ), this, SLOT( attributeTable() ) );
connect( mActionOpenFieldCalc, SIGNAL( triggered() ), this, SLOT( fieldCalculator() ) );
connect( mActionToggleEditing, SIGNAL( triggered() ), this, SLOT( toggleEditing() ) );
Expand Down Expand Up @@ -2973,6 +2974,31 @@ void QgisApp::addSpatiaLiteLayer()
delete dbs;
} // QgisApp::addSpatiaLiteLayer()

void QgisApp::addDelimitedTextLayer()
{
if ( mMapCanvas && mMapCanvas->isDrawing() )
{
return;
}

// show the Delimited text dialog
QDialog *dts = dynamic_cast<QDialog*>( QgsProviderRegistry::instance()->selectWidget( "delimitedtext", this ) );
if ( !dts )
{
QMessageBox::warning( this, tr( "DelimitedText" ), tr( "Cannot get Delimited Text select dialog from provider." ) );
return;
}
connect( dts, SIGNAL( addVectorLayer( QString, QString, QString ) ),
this, SLOT( addSelectedVectorLayer( QString, QString, QString ) ) );
dts->exec();
delete dts;
} // QgisApp::addDelimitedTextLayer()

void QgisApp::addSelectedVectorLayer( QString uri, QString layerName, QString provider )
{
addVectorLayer( uri, layerName, provider );
} // QgisApp:addSelectedVectorLayer

void QgisApp::addMssqlLayer()
{
#ifdef HAVE_MSSQL
Expand Down
6 changes: 5 additions & 1 deletion src/app/qgisapp.h
Expand Up @@ -115,7 +115,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
*/
QgsVectorLayer* addVectorLayer( QString vectorLayerPath, QString baseName, QString providerKey );

/** \brief overloaded vesion of the privat addLayer method that takes a list of
/** \brief overloaded version of the private addLayer method that takes a list of
* file names instead of prompting user with a dialog.
@param enc encoding type for the layer
@param dataSourceType type of ogr datasource
Expand Down Expand Up @@ -626,6 +626,10 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
void addDatabaseLayers( QStringList const & layerPathList, QString const & providerKey );
//! Add a SpatiaLite layer to the map
void addSpatiaLiteLayer();
//! Add a Delimited Text layer to the map
void addDelimitedTextLayer();
//! Add a vector layer defined by uri, layer name, data source uri
void addSelectedVectorLayer(QString uri, QString layerName, QString provider );
//#ifdef HAVE_MSSQL
//! Add a MSSQL layer to the map
void addMssqlLayer();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.h
Expand Up @@ -384,7 +384,7 @@ struct CORE_EXPORT QgsVectorJoinInfo
*
* Determines whether the provider generates a spatial index. The default is no.
*
* -useWatcher=(yes|no)
* -watchFile=(yes|no)
*
* Defines whether the file will be monitored for changes. The default is
* to monitor for changes.
Expand Down
1 change: 0 additions & 1 deletion src/plugins/CMakeLists.txt
Expand Up @@ -2,7 +2,6 @@
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QGIS_OUTPUT_DIRECTORY}/${QGIS_PLUGIN_SUBDIR})

ADD_SUBDIRECTORY(delimited_text)
ADD_SUBDIRECTORY(diagram_overlay)
ADD_SUBDIRECTORY(interpolation)
ADD_SUBDIRECTORY(oracle_raster)
Expand Down
39 changes: 0 additions & 39 deletions src/plugins/delimited_text/CMakeLists.txt

This file was deleted.

0 comments on commit 91f3cea

Please sign in to comment.