mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Fix to handling of double precision values, and improved test cases for this
This commit is contained in:
parent
8cbf901b6a
commit
7a47be23a7
@ -1212,7 +1212,7 @@ void QgsDelimitedTextProvider::fetchAttribute( QgsFeature& feature, int fieldIdx
|
|||||||
}
|
}
|
||||||
case QVariant::Double:
|
case QVariant::Double:
|
||||||
{
|
{
|
||||||
int dvalue;
|
double dvalue;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
if ( ! value.isEmpty() )
|
if ( ! value.isEmpty() )
|
||||||
{
|
{
|
||||||
@ -1222,7 +1222,7 @@ void QgsDelimitedTextProvider::fetchAttribute( QgsFeature& feature, int fieldIdx
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dvalue = QVariant( QString( value ).replace( mDecimalPoint, "." ) ).toDouble( &ok );
|
dvalue = QString(value).replace( mDecimalPoint, "." ).toDouble( &ok );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ok )
|
if ( ok )
|
||||||
|
@ -392,10 +392,10 @@ def test_010_read_coordinates():
|
|||||||
2L: {
|
2L: {
|
||||||
'id': u'1',
|
'id': u'1',
|
||||||
'description': u'Basic point',
|
'description': u'Basic point',
|
||||||
'geom_x': u'10',
|
'geom_x': u'10.5',
|
||||||
'geom_y': u'20',
|
'geom_y': u'20.82',
|
||||||
'#fid': 2L,
|
'#fid': 2L,
|
||||||
'#geometry': 'POINT(10.0 20.0)',
|
'#geometry': 'POINT(10.5 20.82)',
|
||||||
},
|
},
|
||||||
3L: {
|
3L: {
|
||||||
'id': u'2',
|
'id': u'2',
|
||||||
@ -779,8 +779,8 @@ def test_016_decimal_point():
|
|||||||
'id': u'2',
|
'id': u'2',
|
||||||
'description': u'Comma as decimal point 2',
|
'description': u'Comma as decimal point 2',
|
||||||
'geom_x': u'12',
|
'geom_x': u'12',
|
||||||
'geom_y': u'25',
|
'geom_y': u'25.003',
|
||||||
'other': u'-38',
|
'other': u'-38.55',
|
||||||
'text field': u'Plain text field',
|
'text field': u'Plain text field',
|
||||||
'#fid': 3L,
|
'#fid': 3L,
|
||||||
'#geometry': 'POINT(12.0 25.003)',
|
'#geometry': 'POINT(12.0 25.003)',
|
||||||
@ -2071,7 +2071,7 @@ def test_034_csvt_file():
|
|||||||
'id': u'1',
|
'id': u'1',
|
||||||
'description': u'Test csvt 1',
|
'description': u'Test csvt 1',
|
||||||
'f1': u'1',
|
'f1': u'1',
|
||||||
'f2': u'1',
|
'f2': u'1.2',
|
||||||
'f3': u'01',
|
'f3': u'01',
|
||||||
'f4': u'text',
|
'f4': u'text',
|
||||||
'f5': u'times',
|
'f5': u'times',
|
||||||
@ -2082,7 +2082,7 @@ def test_034_csvt_file():
|
|||||||
'id': u'2',
|
'id': u'2',
|
||||||
'description': u'Test csvt 2',
|
'description': u'Test csvt 2',
|
||||||
'f1': u'3',
|
'f1': u'3',
|
||||||
'f2': u'1',
|
'f2': u'1.5',
|
||||||
'f3': u'99',
|
'f3': u'99',
|
||||||
'f4': u'23.5',
|
'f4': u'23.5',
|
||||||
'f5': u'80',
|
'f5': u'80',
|
||||||
@ -2104,7 +2104,7 @@ def test_035_csvt_file2():
|
|||||||
'id': u'1',
|
'id': u'1',
|
||||||
'description': u'Test csvt 1',
|
'description': u'Test csvt 1',
|
||||||
'f1': u'1',
|
'f1': u'1',
|
||||||
'f2': u'1',
|
'f2': u'1.2',
|
||||||
'f3': u'1',
|
'f3': u'1',
|
||||||
'f4': u'text',
|
'f4': u'text',
|
||||||
'f5': u'0',
|
'f5': u'0',
|
||||||
@ -2115,7 +2115,7 @@ def test_035_csvt_file2():
|
|||||||
'id': u'2',
|
'id': u'2',
|
||||||
'description': u'Test csvt 2',
|
'description': u'Test csvt 2',
|
||||||
'f1': u'3',
|
'f1': u'3',
|
||||||
'f2': u'1',
|
'f2': u'1.5',
|
||||||
'f3': u'99',
|
'f3': u'99',
|
||||||
'f4': u'23.5',
|
'f4': u'23.5',
|
||||||
'f5': u'80',
|
'f5': u'80',
|
||||||
@ -2137,7 +2137,7 @@ def test_036_csvt_file_invalid_types():
|
|||||||
'id': u'1',
|
'id': u'1',
|
||||||
'description': u'Test csvt 1',
|
'description': u'Test csvt 1',
|
||||||
'f1': u'1',
|
'f1': u'1',
|
||||||
'f2': u'1',
|
'f2': u'1.2',
|
||||||
'f3': u'1',
|
'f3': u'1',
|
||||||
'f4': u'text',
|
'f4': u'text',
|
||||||
'f5': u'times',
|
'f5': u'times',
|
||||||
@ -2148,7 +2148,7 @@ def test_036_csvt_file_invalid_types():
|
|||||||
'id': u'2',
|
'id': u'2',
|
||||||
'description': u'Test csvt 2',
|
'description': u'Test csvt 2',
|
||||||
'f1': u'3',
|
'f1': u'3',
|
||||||
'f2': u'1',
|
'f2': u'1.5',
|
||||||
'f3': u'99',
|
'f3': u'99',
|
||||||
'f4': u'23.5',
|
'f4': u'23.5',
|
||||||
'f5': u'80',
|
'f5': u'80',
|
||||||
@ -2172,7 +2172,7 @@ def test_037_csvt_file_invalid_file():
|
|||||||
'id': u'1',
|
'id': u'1',
|
||||||
'description': u'Test csvt 1',
|
'description': u'Test csvt 1',
|
||||||
'f1': u'1',
|
'f1': u'1',
|
||||||
'f2': u'1',
|
'f2': u'1.2',
|
||||||
'f3': u'1',
|
'f3': u'1',
|
||||||
'f4': u'text',
|
'f4': u'text',
|
||||||
'f5': u'times',
|
'f5': u'times',
|
||||||
@ -2183,7 +2183,7 @@ def test_037_csvt_file_invalid_file():
|
|||||||
'id': u'2',
|
'id': u'2',
|
||||||
'description': u'Test csvt 2',
|
'description': u'Test csvt 2',
|
||||||
'f1': u'3',
|
'f1': u'3',
|
||||||
'f2': u'1',
|
'f2': u'1.5',
|
||||||
'f3': u'99',
|
'f3': u'99',
|
||||||
'f4': u'23.5',
|
'f4': u'23.5',
|
||||||
'f5': u'80',
|
'f5': u'80',
|
||||||
|
2
tests/testdata/delimitedtext/testpt.csv
vendored
2
tests/testdata/delimitedtext/testpt.csv
vendored
@ -1,5 +1,5 @@
|
|||||||
id,description,geom_x,geom_y
|
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
|
2,Integer point,11,22
|
||||||
3,Invalid coordinate format,ten,20.0
|
3,Invalid coordinate format,ten,20.0
|
||||||
4,Final point,13.0,23.0
|
4,Final point,13.0,23.0
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user