Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix to handling of double precision values, and improved test cases f…
…or this
  • Loading branch information
ccrook committed May 26, 2013
1 parent 8cbf901 commit 7a47be2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Expand Up @@ -1212,7 +1212,7 @@ void QgsDelimitedTextProvider::fetchAttribute( QgsFeature& feature, int fieldIdx
}
case QVariant::Double:
{
int dvalue;
double dvalue;
bool ok = false;
if ( ! value.isEmpty() )
{
Expand All @@ -1222,7 +1222,7 @@ void QgsDelimitedTextProvider::fetchAttribute( QgsFeature& feature, int fieldIdx
}
else
{
dvalue = QVariant( QString( value ).replace( mDecimalPoint, "." ) ).toDouble( &ok );
dvalue = QString(value).replace( mDecimalPoint, "." ).toDouble( &ok );
}
}
if ( ok )
Expand Down
26 changes: 13 additions & 13 deletions tests/src/python/test_qgsdelimitedtextprovider_wanted.py
Expand Up @@ -392,10 +392,10 @@ def test_010_read_coordinates():
2L: {
'id': u'1',
'description': u'Basic point',
'geom_x': u'10',
'geom_y': u'20',
'geom_x': u'10.5',
'geom_y': u'20.82',
'#fid': 2L,
'#geometry': 'POINT(10.0 20.0)',
'#geometry': 'POINT(10.5 20.82)',
},
3L: {
'id': u'2',
Expand Down Expand Up @@ -779,8 +779,8 @@ def test_016_decimal_point():
'id': u'2',
'description': u'Comma as decimal point 2',
'geom_x': u'12',
'geom_y': u'25',
'other': u'-38',
'geom_y': u'25.003',
'other': u'-38.55',
'text field': u'Plain text field',
'#fid': 3L,
'#geometry': 'POINT(12.0 25.003)',
Expand Down Expand Up @@ -2071,7 +2071,7 @@ def test_034_csvt_file():
'id': u'1',
'description': u'Test csvt 1',
'f1': u'1',
'f2': u'1',
'f2': u'1.2',
'f3': u'01',
'f4': u'text',
'f5': u'times',
Expand All @@ -2082,7 +2082,7 @@ def test_034_csvt_file():
'id': u'2',
'description': u'Test csvt 2',
'f1': u'3',
'f2': u'1',
'f2': u'1.5',
'f3': u'99',
'f4': u'23.5',
'f5': u'80',
Expand All @@ -2104,7 +2104,7 @@ def test_035_csvt_file2():
'id': u'1',
'description': u'Test csvt 1',
'f1': u'1',
'f2': u'1',
'f2': u'1.2',
'f3': u'1',
'f4': u'text',
'f5': u'0',
Expand All @@ -2115,7 +2115,7 @@ def test_035_csvt_file2():
'id': u'2',
'description': u'Test csvt 2',
'f1': u'3',
'f2': u'1',
'f2': u'1.5',
'f3': u'99',
'f4': u'23.5',
'f5': u'80',
Expand All @@ -2137,7 +2137,7 @@ def test_036_csvt_file_invalid_types():
'id': u'1',
'description': u'Test csvt 1',
'f1': u'1',
'f2': u'1',
'f2': u'1.2',
'f3': u'1',
'f4': u'text',
'f5': u'times',
Expand All @@ -2148,7 +2148,7 @@ def test_036_csvt_file_invalid_types():
'id': u'2',
'description': u'Test csvt 2',
'f1': u'3',
'f2': u'1',
'f2': u'1.5',
'f3': u'99',
'f4': u'23.5',
'f5': u'80',
Expand All @@ -2172,7 +2172,7 @@ def test_037_csvt_file_invalid_file():
'id': u'1',
'description': u'Test csvt 1',
'f1': u'1',
'f2': u'1',
'f2': u'1.2',
'f3': u'1',
'f4': u'text',
'f5': u'times',
Expand All @@ -2183,7 +2183,7 @@ def test_037_csvt_file_invalid_file():
'id': u'2',
'description': u'Test csvt 2',
'f1': u'3',
'f2': u'1',
'f2': u'1.5',
'f3': u'99',
'f4': u'23.5',
'f5': u'80',
Expand Down
2 changes: 1 addition & 1 deletion tests/testdata/delimitedtext/testpt.csv
@@ -1,5 +1,5 @@
id,description,geom_x,geom_y
1,Basic point,10.0,20.0
1,Basic point,10.5,20.82
2,Integer point,11,22
3,Invalid coordinate format,ten,20.0
4,Final point,13.0,23.0

0 comments on commit 7a47be2

Please sign in to comment.