Skip to content

Commit fa43c9d

Browse files
author
g_j_m
committed
Fix for ticket #237 (delimited layers don't select properly). Was
caused by changes in recent delimited text provider commits. git-svn-id: http://svn.osgeo.org/qgis/trunk@5701 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 91b1482 commit fa43c9d

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/providers/delimitedtext/qgsdelimitedtextprovider.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,20 +368,25 @@ QgsDelimitedTextProvider::getNextFeature_( QgsFeature & feature,
368368
if (! (xOk && yOk))
369369
{
370370
// Accumulate any lines that weren't ok, to report on them
371-
// later, and look at the next line in the file.
372-
mInvalidLines << line;
371+
// later, and look at the next line in the file, but only if
372+
// we need to.
373+
if (mShowInvalidLines)
374+
mInvalidLines << line;
375+
373376
continue;
374377
}
375378

379+
// Give every valid line in the file an id, even if it's not
380+
// in the current extent or bounds.
381+
++mFid; // increment to next feature ID
382+
376383
if (! boundsCheck(x,y))
377384
continue;
378385

379386
// at this point, one way or another, the current feature values
380387
// are valid
381388
feature.setValid( true );
382389

383-
++mFid; // increment to next feature ID
384-
385390
feature.setFeatureId( mFid );
386391

387392
QByteArray buffer;
@@ -439,7 +444,7 @@ QgsDelimitedTextProvider::getNextFeature_( QgsFeature & feature,
439444
} // ! textStream EOF
440445

441446
// End of the file. If there are any lines that couldn't be
442-
// loaded, display them now, but only once.
447+
// loaded, display them now.
443448

444449
if (mShowInvalidLines && !mInvalidLines.isEmpty())
445450
{
@@ -450,6 +455,8 @@ QgsDelimitedTextProvider::getNextFeature_( QgsFeature & feature,
450455
lineViewer.appendMessage(mInvalidLines.at(i));
451456

452457
lineViewer.exec();
458+
// We no longer need these lines.
459+
mInvalidLines.empty();
453460
}
454461

455462
return false;
@@ -522,7 +529,6 @@ void QgsDelimitedTextProvider::select(QgsRect * rect, bool useIntersect)
522529
reset();
523530
// Reset the feature id to 0
524531
mFid = 0;
525-
526532
}
527533

528534

@@ -700,10 +706,12 @@ bool QgsDelimitedTextProvider::isValid()
700706
*/
701707
bool QgsDelimitedTextProvider::boundsCheck(double x, double y)
702708
{
703-
bool inBounds = (((x < mSelectionRectangle->xMax()) &&
704-
(x > mSelectionRectangle->xMin())) &&
705-
((y < mSelectionRectangle->yMax()) &&
706-
(y > mSelectionRectangle->yMin())));
709+
bool inBounds(true);
710+
if (mSelectionRectangle)
711+
inBounds = (((x < mSelectionRectangle->xMax()) &&
712+
(x > mSelectionRectangle->xMin())) &&
713+
((y < mSelectionRectangle->yMax()) &&
714+
(y > mSelectionRectangle->yMin())));
707715
// QString hit = inBounds?"true":"false";
708716

709717
// std::cerr << "Checking if " << x << ", " << y << " is in " <<

0 commit comments

Comments
 (0)