Permalink
Browse files

Fix support for 2.0 (attribute access)

  • Loading branch information...
Sandro Santilli
Sandro Santilli committed Mar 6, 2013
1 parent a0abbf5 commit 72691bb5ece0e4cb51722d2058b778c48160d5ba
Showing with 12 additions and 4 deletions.
  1. +1 −1 __init__.py
  2. +2 −0 metadata.txt
  3. +9 −3 pgtopoeditor.py
View
@@ -24,7 +24,7 @@ def name():
def description():
return "Edit toolbar for PostGIS topology primitives (ISO SQL/MM based)"
def version():
- return "0.0.1"
+ return "0.0.2"
def icon():
return "icons/topoedit.png"
def qgisMinimumVersion():
View
@@ -11,6 +11,8 @@ version=0.0.1
; start of optional metadata
changelog=
+ 0.0.2
+ Fix support for qgis 2.0
0.0.1
Fix version mismatch
0.0.0
View
@@ -29,6 +29,12 @@
import psycopg2
+def getAttributeByIndex(feature, index):
+ if QGis.QGIS_VERSION_INT < 20000:
+ return feature[index]
+ else:
+ return feature.attribute()[index]
+
class PgTopoEditor:
def __init__(self, iface):
@@ -96,7 +102,7 @@ def doRemEdgeModFace(self):
conn = psycopg2.connect( str(uri.connectionInfo()) )
for feature in selected:
# get its edge_id
- edge_id = feature.attributeMap()[edge_id_fno].toInt()[0]
+ edge_id = getAttributeByIndex(feature, edge_id_fno).toInt()[0]
try:
cur = conn.cursor()
cur.execute("SELECT ST_RemEdgeModFace(%s, %s)", (toponame, edge_id))
@@ -157,8 +163,8 @@ def doModEdgeHeal(self):
return
# get their edge_id
- edge1_id = selected[0].attributeMap()[edge_id_fno].toInt()[0]
- edge2_id = selected[1].attributeMap()[edge_id_fno].toInt()[0]
+ edge1_id = getAttributeByIndex(selected[0], edge_id_fno).toInt()[0]
+ edge2_id = getAttributeByIndex(selected[1], edge_id_fno).toInt()[0]
try:
conn = psycopg2.connect( str(uri.connectionInfo()) )
cur = conn.cursor()

0 comments on commit 72691bb

Please sign in to comment.