Skip to content
Permalink
Browse files
Ported r6511 to trunk
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6512 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Feb 3, 2007
1 parent 62b5121 commit 2a42ccb4270b8f6637eb1784126f3992707acc32
Showing with 19 additions and 4 deletions.
  1. +19 −4 src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
@@ -41,6 +41,7 @@
#include "qgsrect.h"
#include "qgsspatialrefsys.h"
#include "qgis.h"
#include "qgslogger.h"

#ifdef WIN32
#define QGISEXTERN extern "C" __declspec( dllexport )
@@ -180,6 +181,12 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider(QString uri)
// split the line on the delimiter
QStringList parts =
QStringList::split(mDelimiter, line, true);

// Skip malformed lines silently. Report line number with getNextFeature()
if ( (parts.size() <= fieldPositions[mXField]) || (parts.size() <= fieldPositions[mYField]) )
{
continue;
}
//if(parts.size() == attributeFields.size())
//{
// // we can populate attributes if required
@@ -338,24 +345,32 @@ QgsDelimitedTextProvider::getNextFeature_( QgsFeature & feature,
feature.setValid( false );
while ( ! mStream->atEnd() )
{
double x = 0.0;
double y = 0.0;
QString line = mStream->readLine(); // Default local 8 bit encoding
// lex the tokens from the current data line
QStringList tokens = QStringList::split(mDelimiter, line, true);

bool xOk = false;
bool yOk = false;

int xFieldPos = fieldPositions[mXField];
int yFieldPos = fieldPositions[mYField];
// Skip indexing malformed lines.
if ( ! ((tokens.size() <= fieldPositions[mXField]) || (tokens.size() <= fieldPositions[mXField])) )
{

int xFieldPos = fieldPositions[mXField];
int yFieldPos = fieldPositions[mYField];

double x = tokens[xFieldPos].toDouble( &xOk );
double y = tokens[yFieldPos].toDouble( &yOk );
x = tokens[xFieldPos].toDouble( &xOk );
y = tokens[yFieldPos].toDouble( &yOk );

}
if (! (xOk && yOk))
{
// Accumulate any lines that weren't ok, to report on them
// later, and look at the next line in the file, but only if
// we need to.
QgsDebugMsg("Malformed line : " + line);
if (mShowInvalidLines)
mInvalidLines << line;

0 comments on commit 2a42ccb

Please sign in to comment.