Skip to content
Permalink
Browse files

Merge pull request #540 from ccrook/delimited_text_bug_fixes

More delimited text bug fixes
  • Loading branch information
timlinux committed Apr 23, 2013
2 parents 6d046fc + 20d40bf commit 91685e76ddfe95ae756078364d69a0ed76a75164

Large diffs are not rendered by default.

@@ -160,7 +160,7 @@ struct CORE_EXPORT QgsVectorJoinInfo
* QgsVectorLayer *scratchLayer = new QgsVectorLayer(uri, "Scratch point layer", "memory");
* \endcode
*
* The main data providers supported by QGis are listed below.
* The main data providers supported by QGIS are listed below.
*
* \section providers Vector data providers
*
@@ -310,15 +310,6 @@ struct CORE_EXPORT QgsVectorJoinInfo
*
* Defines the characters used to escape delimiter, quote, and newline characters.
*
* - skipEmptyFields=(yes|no)
*
* If yes then empty fields will be discarded (eqivalent to concatenating consecutive
* delimiters)
*
* - trimFields=(yes|no)
*
* If yes then leading and trailing whitespace will be removed from fields
*
* - skipLines=n
*
* Defines the number of lines to ignore at the beginning of the file (default 0)
@@ -328,17 +319,31 @@ struct CORE_EXPORT QgsVectorJoinInfo
* Defines whether the first record in the file (after skipped lines) contains
* column names (default yes)
*
* - xField=column yField=column
* - trimFields=(yes|no)
*
* Defines the name of the columns holding the x and y coordinates for XY point geometries.
* If the useHeader is no (ie there are no column names), then this is the column
* number (with the first column as 1).
* If yes then leading and trailing whitespace will be removed from fields
*
* - skipEmptyFields=(yes|no)
*
* If yes then empty fields will be discarded (eqivalent to concatenating consecutive
* delimiters)
*
* - maxFields=#
*
* Specifies the maximum number of fields to load for each record. Additional
* fields will be discarded. Default is 0 - load all fields.
*
* - decimalPoint=c
*
* Defines a character that is used as a decimal point in the numeric columns
* The default is '.'.
*
* - xField=column yField=column
*
* Defines the name of the columns holding the x and y coordinates for XY point geometries.
* If the useHeader is no (ie there are no column names), then this is the column
* number (with the first column as 1).
*
* - xyDms=(yes|no)
*
* If yes then the X and Y coordinates are interpreted as
@@ -353,7 +358,7 @@ struct CORE_EXPORT QgsVectorJoinInfo
*
* - geomType=(point|line|polygon|none)
*
* Defines the geometry type for WKT type geometries. QGis will only display one
* Defines the geometry type for WKT type geometries. QGIS will only display one
* type of geometry for the layer - any others will be ignored when the file is
* loaded. By default the provider uses the type of the first geometry in the file.
* Use geomType to override this type.
@@ -383,8 +388,6 @@ struct CORE_EXPORT QgsVectorJoinInfo
*
* Provider to display vector data in a GRASS GIS layer.
*
*
*
*/


@@ -53,8 +53,10 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )
while ( true )
{
QgsDelimitedTextFile::Status status = P->mFile->nextRecord( tokens );
int fid = P->mFile->recordLineNumber();
if ( status == QgsDelimitedTextFile::RecordEOF ) break;
if ( status != QgsDelimitedTextFile::RecordOk ) continue;
if ( P->recordIsEmpty( tokens ) ) continue;

while ( tokens.size() < P->mFieldCount )
tokens.append( QString::null );
@@ -80,13 +82,11 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )
continue;
}

mFid++;

// At this point the current feature values are valid

feature.setValid( true );
feature.setFields( &P->attributeFields ); // allow name-based attribute lookups
feature.setFeatureId( mFid );
feature.setFeatureId( fid );
feature.initAttributes( P->attributeFields.count() );

if ( geom )
@@ -127,8 +127,6 @@ bool QgsDelimitedTextFeatureIterator::rewind()
if ( mClosed )
return false;

// Reset feature id to 0
mFid = 0;
// Skip to first data record
P->resetStream();
return true;
@@ -38,9 +38,6 @@ class QgsDelimitedTextFeatureIterator : public QgsAbstractFeatureIterator
protected:
QgsDelimitedTextProvider* P;

//! Feature id
long mFid;

QgsGeometry* loadGeometryWkt( const QStringList& tokens );
QgsGeometry* loadGeometryXY( const QStringList& tokens );

0 comments on commit 91685e7

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