[Qgis-developer] addAttributes case sensitive?

cfarmer cfarmer at uvic.ca
Fri May 30 02:24:50 EDT 2008


Hello list,

Does anyone know how addAttributes on a QgsFeature defines which field to
populate? As far as I can tell, I should have to specify an index, and the
attribute that I am trying to add, however, if I have two fields that have
the same name with different cases (i.e. one field says "Ycoor" and
another says 'YCOOR', even if I specify the index of 'YCOOR', values are
written to 'Ycoor'.

So in short, why does field name matter in this case? Or am I doing
something completely wrong:

fieldList #pre-existing field list obtained from QgsProvider.fields()
field = QgsField("YCOOR", QVariant.Double, "double", 24, 16, "Polygon area")
index1 = len(fieldList.keys())
fieldList[index1] = field

#then later on, when setting the attributes of an output feature...
#Set new attributes equal to attributes of currently existing feature...
outFeat.setAttributeMap(atMap)
#Now add on the new attribute...
outFeat.addAttribute(index1, QVariant(attr1))

Note: The currently existing attributes have a field named 'Ycoor'. The
new field being added is called 'YCOOR'. Using the above code, 'Ycoor' is
(re)populated, and 'YCOOR' is left blank?

Any suggestions welcomed!

C




More information about the Qgis-developer mailing list