Skip to content

Commit

Permalink
Merge pull request #540 from ccrook/delimited_text_bug_fixes
Browse files Browse the repository at this point in the history
More delimited text bug fixes
  • Loading branch information
timlinux committed Apr 23, 2013
2 parents 6d046fc + 20d40bf commit 91685e7
Show file tree
Hide file tree
Showing 19 changed files with 1,205 additions and 422 deletions.
165 changes: 136 additions & 29 deletions resources/context_help/QgsDelimitedTextSourceSelect-en_US

Large diffs are not rendered by default.

37 changes: 20 additions & 17 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -383,8 +388,6 @@ struct CORE_EXPORT QgsVectorJoinInfo
*
* Provider to display vector data in a GRASS GIS layer.
*
*
*
*/


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 )
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
Loading

0 comments on commit 91685e7

Please sign in to comment.