Skip to content

Commit

Permalink
Delimited text fix compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrook committed Apr 8, 2013
1 parent ab7b993 commit 0102eba
Show file tree
Hide file tree
Showing 11 changed files with 1,670 additions and 953 deletions.
1 change: 1 addition & 0 deletions src/providers/delimitedtext/CMakeLists.txt
Expand Up @@ -5,6 +5,7 @@
SET (DTEXT_SRCS
qgsdelimitedtextfeatureiterator.cpp
qgsdelimitedtextprovider.cpp
qgsdelimitedtextfile.cpp
qgsdelimitedtextsourceselect.cpp
)

Expand Down
26 changes: 10 additions & 16 deletions src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp
Expand Up @@ -13,8 +13,8 @@
* *
***************************************************************************/
#include "qgsdelimitedtextfeatureiterator.h"

#include "qgsdelimitedtextprovider.h"
#include "qgsdelimitedtextfile.h"

#include "qgsgeometry.h"
#include "qgsmessagelog.h"
Expand Down Expand Up @@ -49,14 +49,12 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )
if ( mClosed )
return false;

while ( !P->mStream->atEnd() )
QStringList tokens;
while ( true )
{
QString line = P->readLine( P->mStream ); // Default local 8 bit encoding
if ( line.isEmpty() )
continue;

// lex the tokens from the current data line
QStringList tokens = P->splitLine( line );
QgsDelimitedTextFile::Status status = P->mFile->nextRecord( tokens );
if( status == QgsDelimitedTextFile::RecordEOF ) break;
if( status != QgsDelimitedTextFile::RecordOk ) continue;

while ( tokens.size() < P->mFieldCount )
tokens.append( QString::null );
Expand All @@ -74,7 +72,8 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )

if ( !geom && P->mWkbType != QGis::WKBNoGeometry )
{
P->mInvalidLines << line;
// Already dealt with invalid lines in provider - no need to repeat
// P->mInvalidLines << line;
continue;
}

Expand Down Expand Up @@ -114,7 +113,7 @@ bool QgsDelimitedTextFeatureIterator::nextFeature( QgsFeature& feature )

// End of the file. If there are any lines that couldn't be
// loaded, display them now.
P->handleInvalidLines();
// P->handleInvalidLines();

close();
return false;
Expand All @@ -128,11 +127,7 @@ bool QgsDelimitedTextFeatureIterator::rewind()
// Reset feature id to 0
mFid = 0;
// Skip to first data record
P->mStream->seek( 0 );
int n = P->mFirstDataLine - 1;
while ( n-- > 0 )
P->readLine( P->mStream );

P->resetStream();
return true;
}

Expand All @@ -143,7 +138,6 @@ bool QgsDelimitedTextFeatureIterator::close()

// tell provider that this iterator is not active anymore
P->mActiveIterator = 0;

mClosed = true;
return true;
}
Expand Down

0 comments on commit 0102eba

Please sign in to comment.