Skip to content
Permalink
Browse files

Merge pull request #591 from ccrook/delimited_text_to_core

Delimited text to core
  • Loading branch information
timlinux committed May 17, 2013
2 parents 957c4f1 + 198cc39 commit 91f3ceab26013d6c97a0047c344f5e2570df34c3
Showing with 982 additions and 1,519 deletions.
  1. BIN doc/plugins/delimited_text/dialog.png
  2. BIN doc/plugins/delimited_text/ellipsis.png
  3. BIN doc/plugins/delimited_text/file_selected.png
  4. BIN doc/plugins/delimited_text/file_selected1.png
  5. BIN doc/plugins/delimited_text/file_selected2.png
  6. BIN doc/plugins/delimited_text/file_selected3.png
  7. +0 −70 doc/plugins/delimited_text/index.html
  8. BIN doc/plugins/delimited_text/layer_added.png
  9. BIN doc/plugins/delimited_text/plugin_manager.png
  10. BIN doc/plugins/delimited_text/toolbar_icon.png
  11. +1 −1 images/images.qrc
  12. BIN images/themes/default/{plugins/delimited_text.png → mActionAddDelimitedTextLayer.png}
  13. +41 −28 resources/context_help/QgsDelimitedTextSourceSelect-en_US
  14. +26 −0 src/app/qgisapp.cpp
  15. +5 −1 src/app/qgisapp.h
  16. +1 −1 src/core/qgsvectorlayer.h
  17. +0 −1 src/plugins/CMakeLists.txt
  18. +0 −39 src/plugins/delimited_text/CMakeLists.txt
  19. +0 −125 src/plugins/delimited_text/delimitedText.svg
  20. BIN src/plugins/delimited_text/delimited_text.png
  21. +0 −5 src/plugins/delimited_text/delimited_text.qrc
  22. +0 −229 src/plugins/delimited_text/qgsdelimitedtextplugin.cpp
  23. +0 −97 src/plugins/delimited_text/qgsdelimitedtextplugin.h
  24. +4 −4 src/providers/delimitedtext/qgsdelimitedtextfile.cpp
  25. +28 −4 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  26. +3 −0 src/providers/delimitedtext/qgsdelimitedtextsourceselect.h
  27. +14 −0 src/ui/qgisapp.ui
  28. +856 −911 src/ui/qgsdelimitedtextsourceselectbase.ui
  29. +2 −2 tests/src/python/test_qgsdelimitedtextprovider.py
  30. +1 −1 tests/src/python/test_qgsdelimitedtextprovider_wanted.py
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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>
@@ -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>
@@ -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:
@@ -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>


@@ -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>
@@ -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>
@@ -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.
@@ -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>

@@ -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() ) );
@@ -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
@@ -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
@@ -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();
@@ -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.
@@ -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)

This file was deleted.

0 comments on commit 91f3cea

Please sign in to comment.
You can’t perform that action at this time.