Re: [Qgis-developer] UPDATE: New Plugin - Edit Any Layer

2012-08-30 Thread Kuhn Matthias, Vermessung
Hey Rob,
 
I'm trying to get something similar accomplished in another python project and 
stumbled across a problem your plugin might be affected of as well. I couldn't 
test it because of an error with character encoding. [1]
I have a layer provided by postgis, where the geometry column is not the last 
column. The leads to the problem, that any attribute column that comes after 
the geometry column is shifted by 1 and so are the values. So a table:

A | b | the_geom  | c | d |
---
1 | 2 | Point(0,0)| 4 | 5 |

Results in a memory layer:

A | b | c | d |
---
1 | 2 |   | 4 |

I fixed it by inserting a dummy column at the index where in the original data 
the geometry column was located. Maybe you can use this in your code as well [2]
 
Regards,
Matthias

[1]: .qgis//python/plugins\EditAnyLayer\editanylayerdialog.py", line 42, in 
__init__
print layer.name()
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 3: 
ordinal not in range(128)
 
[2]:  

curKey = -1
for key, value in fields.iteritems():
  while key != curKey+1:
pr.addAttributes( [QgsField( "dummy", QVariant.Double )] )
curKey += 1
  pr.addAttributes([ value ])
  curKey += 1
 




From: [email protected] 
[mailto:[email protected]] On Behalf Of 
[email protected]
Sent: Wednesday, August 08, 2012 2:22 PM
To: [email protected]
Subject: [Qgis-developer] UPDATE: New Plugin - Edit Any Layer


This plugin has now been uploaded to http://plugins.qgis.org/ and is 
awaiting approval (thanks Paolo).

Changelog:
* New icon
* Added comment to dialogue window
* Changed menu entry to "Edit Any Layer -> Create Editable Layer..." 

Alister, thanks for the suggestions but, although the name "Copy as 
memory layer" would explain _what_ the plugin does, I will stick with "Edit Any 
Layer" as this explains _why_ you would want to run the plugin. I have also not 
added an option to copy selected items only (and this is low priority as this 
feature is in QGIS core UI).

Regards,
Rob

___
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] UPDATE: New Plugin - Edit Any Layer

2012-08-09 Thread haubourg
Hi Rob , 
I just published a very close plugin : EasyCustomLabeling. You made me
finish it faster ! 

One first remark, I will open a dedicated topic, not sure it is a QGIS API
bug . 
If duplicating a layer with AttributeMap() , and AddAttribute() methods, if
source layer contains oid , fid or geometry fields that are not last fields,
ID's of fields are handled differently between AttributeMap() that fetches
id's, and addattribute that write ids..  
This is quite common with postgis.
First method fetches values with id calculated without those masked fields, 
the other one sees raw id's. As a result,  attributes are not writen in the
right column. 

We found a workaround be recreating our own field indexes every time.. Have
a look at the code  http://planet.qgis.org/plugins/EasyCustomLabeling/
http://planet.qgis.org/plugins/EasyCustomLabeling/ 

Cheers, 
Régis



--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/UPDATE-New-Plugin-Edit-Any-Layer-tp4993854p4994180.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
___
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer