Skip to content

Commit d6a53e5

Browse files
committedApr 16, 2013
Missed committing files
1 parent 1e8304b commit d6a53e5

File tree

6 files changed

+139
-88
lines changed

6 files changed

+139
-88
lines changed
 

‎src/core/qgsvectorlayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct CORE_EXPORT QgsVectorJoinInfo
336336
*
337337
* - decimalPoint=c
338338
*
339-
* Defines a character that is used as a decimal point in the X and Y columns.
339+
* Defines a character that is used as a decimal point in the numeric columns
340340
* The default is '.'.
341341
*
342342
* - xyDms=(yes|no)

‎src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,16 +216,24 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature& feature, int f
216216
switch ( P->attributeFields[fieldIdx].type() )
217217
{
218218
case QVariant::Int:
219-
if ( !value.isEmpty() )
220-
val = QVariant( value );
221-
else
219+
if ( value.isEmpty() )
222220
val = QVariant( P->attributeFields[fieldIdx].type() );
221+
else
222+
val = QVariant( value );
223223
break;
224224
case QVariant::Double:
225-
if ( !value.isEmpty() )
225+
if ( value.isEmpty() )
226+
{
227+
val = QVariant( P->attributeFields[fieldIdx].type() );
228+
}
229+
else if ( P->mDecimalPoint.isEmpty() )
230+
{
226231
val = QVariant( value.toDouble() );
232+
}
227233
else
228-
val = QVariant( P->attributeFields[fieldIdx].type() );
234+
{
235+
val = QVariant( QString( value ).replace( P->mDecimalPoint, "." ).toDouble() );
236+
}
229237
break;
230238
default:
231239
val = QVariant( value );

‎src/providers/delimitedtext/qgsdelimitedtextprovider.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri )
372372
}
373373
if ( couldBeDouble[fieldPos] )
374374
{
375+
if ( ! mDecimalPoint.isEmpty() )
376+
{
377+
value.replace( mDecimalPoint, "." );
378+
}
375379
value.toDouble( &couldBeDouble[fieldPos] );
376380
}
377381
fieldPos++;

‎src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,14 @@ void QgsDelimitedTextSourceSelect::loadSettings( QString subkey, bool loadGeomSe
262262
cbxUseHeader->setChecked( settings.value( key + "/useHeader", "true" ) != "false" );
263263
cbxTrimFields->setChecked( settings.value( key + "/trimFields", "false" ) == "true" );
264264
cbxSkipEmptyFields->setChecked( settings.value( key + "/skipEmptyFields", "false" ) == "true" );
265+
cbxPointIsComma->setChecked( settings.value( key + "/decimalPoint", "." ).toString().contains( "," ) );
265266

266267
if ( loadGeomSettings )
267268
{
268269
QString geomColumnType = settings.value( key + "/geomColumnType", "xy" ).toString();
269270
if ( geomColumnType == "xy" ) geomTypeXY->setChecked( true );
270271
else if ( geomColumnType == "wkt" ) geomTypeWKT->setChecked( true );
271272
else geomTypeNone->setChecked( true );
272-
cbxPointIsComma->setChecked( settings.value( key + "/decimalPoint", "." ).toString().contains( "," ) );
273273
cbxXyDms->setChecked( settings.value( key + "/xyDms", "false" ) == "true" );
274274
}
275275

@@ -297,13 +297,13 @@ void QgsDelimitedTextSourceSelect::saveSettings( QString subkey, bool saveGeomSe
297297
settings.setValue( key + "/useHeader", cbxUseHeader->isChecked() ? "true" : "false" );
298298
settings.setValue( key + "/trimFields", cbxTrimFields->isChecked() ? "true" : "false" );
299299
settings.setValue( key + "/skipEmptyFields", cbxSkipEmptyFields->isChecked() ? "true" : "false" );
300+
settings.setValue( key + "/decimalPoint", cbxPointIsComma->isChecked() ? "," : "." );
300301
if ( saveGeomSettings )
301302
{
302303
QString geomColumnType = "none";
303304
if ( geomTypeXY->isChecked() ) geomColumnType = "xy";
304305
if ( geomTypeWKT->isChecked() ) geomColumnType = "wkt";
305306
settings.setValue( key + "/geomColumnType", geomColumnType );
306-
settings.setValue( key + "/decimalPoint", cbxPointIsComma->isChecked() ? "," : "." );
307307
settings.setValue( key + "/xyDms", cbxXyDms->isChecked() ? "true" : "false" );
308308
}
309309

‎src/ui/qgsdelimitedtextsourceselectbase.ui

Lines changed: 87 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>658</width>
10-
<height>600</height>
9+
<width>625</width>
10+
<height>524</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -128,38 +128,6 @@
128128
</property>
129129
</widget>
130130
</item>
131-
<item>
132-
<spacer name="hspacer4">
133-
<property name="orientation">
134-
<enum>Qt::Horizontal</enum>
135-
</property>
136-
<property name="sizeHint" stdset="0">
137-
<size>
138-
<width>40</width>
139-
<height>20</height>
140-
</size>
141-
</property>
142-
</spacer>
143-
</item>
144-
<item>
145-
<widget class="QCheckBox" name="cbxPointIsComma">
146-
<property name="enabled">
147-
<bool>true</bool>
148-
</property>
149-
<property name="toolTip">
150-
<string>X and Y coordinates have comma for decimal point</string>
151-
</property>
152-
<property name="statusTip">
153-
<string>X and Y coordinates have comma for decimal point</string>
154-
</property>
155-
<property name="whatsThis">
156-
<string>X and Y coordinates have comma for decimal point</string>
157-
</property>
158-
<property name="text">
159-
<string>Point is comma</string>
160-
</property>
161-
</widget>
162-
</item>
163131
<item>
164132
<widget class="QCheckBox" name="cbxXyDms">
165133
<property name="toolTip">
@@ -172,10 +140,23 @@
172140
<string>X and Y coordinates are expressed in degrees/minutes/seconds</string>
173141
</property>
174142
<property name="text">
175-
<string>DMS coords</string>
143+
<string>DMS coordinates</string>
176144
</property>
177145
</widget>
178146
</item>
147+
<item>
148+
<spacer name="hspacer4">
149+
<property name="orientation">
150+
<enum>Qt::Horizontal</enum>
151+
</property>
152+
<property name="sizeHint" stdset="0">
153+
<size>
154+
<width>40</width>
155+
<height>20</height>
156+
</size>
157+
</property>
158+
</spacer>
159+
</item>
179160
</layout>
180161
</item>
181162
<item>
@@ -820,6 +801,25 @@
820801
</property>
821802
</widget>
822803
</item>
804+
<item>
805+
<widget class="QCheckBox" name="cbxPointIsComma">
806+
<property name="enabled">
807+
<bool>true</bool>
808+
</property>
809+
<property name="toolTip">
810+
<string>X and Y coordinates have comma for decimal point</string>
811+
</property>
812+
<property name="statusTip">
813+
<string>X and Y coordinates have comma for decimal point</string>
814+
</property>
815+
<property name="whatsThis">
816+
<string>X and Y coordinates have comma for decimal point</string>
817+
</property>
818+
<property name="text">
819+
<string>Point is comma</string>
820+
</property>
821+
</widget>
822+
</item>
823823
<item>
824824
<spacer name="horizontalSpacer_2">
825825
<property name="orientation">
@@ -872,13 +872,20 @@
872872
<tabstop>txtEscapeChars</tabstop>
873873
<tabstop>delimiterRegexp</tabstop>
874874
<tabstop>txtDelimiterRegexp</tabstop>
875+
<tabstop>cbxTrimFields</tabstop>
876+
<tabstop>cbxSkipEmptyFields</tabstop>
877+
<tabstop>cbxPointIsComma</tabstop>
878+
<tabstop>rowCounter</tabstop>
879+
<tabstop>cbxUseHeader</tabstop>
875880
<tabstop>geomTypeXY</tabstop>
876881
<tabstop>cmbXField</tabstop>
877882
<tabstop>cmbYField</tabstop>
878-
<tabstop>cbxPointIsComma</tabstop>
883+
<tabstop>cbxXyDms</tabstop>
879884
<tabstop>geomTypeWKT</tabstop>
880885
<tabstop>cmbWktField</tabstop>
881886
<tabstop>cmbGeometryType</tabstop>
887+
<tabstop>geomTypeNone</tabstop>
888+
<tabstop>tblSample</tabstop>
882889
<tabstop>buttonBox</tabstop>
883890
</tabstops>
884891
<resources/>
@@ -890,12 +897,12 @@
890897
<slot>setEnabled(bool)</slot>
891898
<hints>
892899
<hint type="sourcelabel">
893-
<x>119</x>
894-
<y>246</y>
900+
<x>128</x>
901+
<y>219</y>
895902
</hint>
896903
<hint type="destinationlabel">
897-
<x>388</x>
898-
<y>245</y>
904+
<x>380</x>
905+
<y>218</y>
899906
</hint>
900907
</hints>
901908
</connection>
@@ -906,12 +913,12 @@
906913
<slot>setEnabled(bool)</slot>
907914
<hints>
908915
<hint type="sourcelabel">
909-
<x>101</x>
910-
<y>327</y>
916+
<x>93</x>
917+
<y>313</y>
911918
</hint>
912919
<hint type="destinationlabel">
913-
<x>270</x>
914-
<y>329</y>
920+
<x>262</x>
921+
<y>315</y>
915922
</hint>
916923
</hints>
917924
</connection>
@@ -922,12 +929,12 @@
922929
<slot>setEnabled(bool)</slot>
923930
<hints>
924931
<hint type="sourcelabel">
925-
<x>89</x>
926-
<y>327</y>
932+
<x>93</x>
933+
<y>313</y>
927934
</hint>
928935
<hint type="destinationlabel">
929-
<x>438</x>
930-
<y>329</y>
936+
<x>430</x>
937+
<y>315</y>
931938
</hint>
932939
</hints>
933940
</connection>
@@ -938,12 +945,12 @@
938945
<slot>setEnabled(bool)</slot>
939946
<hints>
940947
<hint type="sourcelabel">
941-
<x>101</x>
942-
<y>360</y>
948+
<x>95</x>
949+
<y>344</y>
943950
</hint>
944951
<hint type="destinationlabel">
945-
<x>250</x>
946-
<y>362</y>
952+
<x>261</x>
953+
<y>346</y>
947954
</hint>
948955
</hints>
949956
</connection>
@@ -954,8 +961,8 @@
954961
<slot>setEnabled(bool)</slot>
955962
<hints>
956963
<hint type="sourcelabel">
957-
<x>80</x>
958-
<y>182</y>
964+
<x>89</x>
965+
<y>155</y>
959966
</hint>
960967
<hint type="destinationlabel">
961968
<x>181</x>
@@ -970,76 +977,76 @@
970977
<slot>setEnabled(bool)</slot>
971978
<hints>
972979
<hint type="sourcelabel">
973-
<x>47</x>
974-
<y>359</y>
980+
<x>59</x>
981+
<y>344</y>
975982
</hint>
976983
<hint type="destinationlabel">
977-
<x>349</x>
978-
<y>358</y>
984+
<x>429</x>
985+
<y>346</y>
979986
</hint>
980987
</hints>
981988
</connection>
982989
<connection>
983990
<sender>geomTypeXY</sender>
984991
<signal>toggled(bool)</signal>
985-
<receiver>cbxPointIsComma</receiver>
992+
<receiver>textLabelx</receiver>
986993
<slot>setEnabled(bool)</slot>
987994
<hints>
988995
<hint type="sourcelabel">
989-
<x>49</x>
990-
<y>321</y>
996+
<x>52</x>
997+
<y>313</y>
991998
</hint>
992999
<hint type="destinationlabel">
993-
<x>512</x>
994-
<y>327</y>
1000+
<x>136</x>
1001+
<y>315</y>
9951002
</hint>
9961003
</hints>
9971004
</connection>
9981005
<connection>
9991006
<sender>geomTypeXY</sender>
10001007
<signal>toggled(bool)</signal>
1001-
<receiver>textLabelx</receiver>
1008+
<receiver>textLabely</receiver>
10021009
<slot>setEnabled(bool)</slot>
10031010
<hints>
10041011
<hint type="sourcelabel">
1005-
<x>40</x>
1006-
<y>320</y>
1012+
<x>69</x>
1013+
<y>313</y>
10071014
</hint>
10081015
<hint type="destinationlabel">
1009-
<x>116</x>
1010-
<y>326</y>
1016+
<x>304</x>
1017+
<y>315</y>
10111018
</hint>
10121019
</hints>
10131020
</connection>
10141021
<connection>
1015-
<sender>geomTypeXY</sender>
1022+
<sender>geomTypeWKT</sender>
10161023
<signal>toggled(bool)</signal>
1017-
<receiver>textLabely</receiver>
1024+
<receiver>label</receiver>
10181025
<slot>setEnabled(bool)</slot>
10191026
<hints>
10201027
<hint type="sourcelabel">
1021-
<x>57</x>
1022-
<y>327</y>
1028+
<x>58</x>
1029+
<y>344</y>
10231030
</hint>
10241031
<hint type="destinationlabel">
1025-
<x>282</x>
1026-
<y>326</y>
1032+
<x>350</x>
1033+
<y>346</y>
10271034
</hint>
10281035
</hints>
10291036
</connection>
10301037
<connection>
1031-
<sender>geomTypeWKT</sender>
1038+
<sender>geomTypeXY</sender>
10321039
<signal>toggled(bool)</signal>
1033-
<receiver>label</receiver>
1040+
<receiver>cbxXyDms</receiver>
10341041
<slot>setEnabled(bool)</slot>
10351042
<hints>
10361043
<hint type="sourcelabel">
1037-
<x>46</x>
1038-
<y>356</y>
1044+
<x>40</x>
1045+
<y>300</y>
10391046
</hint>
10401047
<hint type="destinationlabel">
1041-
<x>290</x>
1042-
<y>357</y>
1048+
<x>488</x>
1049+
<y>305</y>
10431050
</hint>
10441051
</hints>
10451052
</connection>

‎tests/src/python/test_qgsdelimitedtextprovider.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,38 @@ def test_013_read_dms_xy(self):
868868
]
869869
runTest(description,wanted,log_wanted,filename,**params)
870870

871+
872+
def test_014_decimal_point(self):
873+
description='Reading degrees/minutes/seconds angles'
874+
filename='testdp.csv'
875+
params={'yField': 'geom_y', 'xField': 'geom_x', 'type': 'csv', 'delimiter': ';', 'decimalPoint': ','}
876+
if printTests:
877+
createTest('014_decimal_point',description,filename,**params)
878+
assert False,"Set printTests to False to run delimited text tests"
879+
wanted={
880+
u'1': {
881+
'id': u'1',
882+
'description': u'Comma as decimal point 1',
883+
'geom_x': u'10',
884+
'geom_y': u'20',
885+
'other': u'30',
886+
'text field': u'Field with , in it',
887+
'#geometry': 'POINT(10.0 20.0)',
888+
},
889+
u'2': {
890+
'id': u'2',
891+
'description': u'Comma as decimal point 2',
892+
'geom_x': u'12',
893+
'geom_y': u'25.003',
894+
'other': u'-38.55',
895+
'text field': u'Plain text field',
896+
'#geometry': 'POINT(12.0 25.003)',
897+
},
898+
}
899+
log_wanted=[
900+
]
901+
runTest(description,wanted,log_wanted,filename,**params)
902+
871903
#END
872904

873905
if __name__ == '__main__':

0 commit comments

Comments
 (0)
Please sign in to comment.