Skip to content

Commit d8a768f

Browse files
author
Sandro Santilli
committedFeb 22, 2016
Make geometry typmod available for topology face layer queries
Greatly improves performances on topology loading. See http://hub.qgis.org/issues/14356
1 parent bf583c7 commit d8a768f

File tree

1 file changed

+9
-4
lines changed
  • python/plugins/db_manager/db_plugins/postgis/plugins/qgis_topoview

1 file changed

+9
-4
lines changed
 

‎python/plugins/db_manager/db_plugins/postgis/plugins/qgis_topoview/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ def run(item, action, mainwindow):
122122
face_extent = layer.extent()
123123

124124
# face geometry
125-
sql = u'SELECT face_id, topology.ST_GetFaceGeometry(%s, face_id) as geom ' \
126-
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame))
125+
sql = u'SELECT face_id, topology.ST_GetFaceGeometry(%s,' \
126+
'face_id)::geometry(polygon, %s) as geom ' \
127+
'FROM %s.face WHERE face_id > 0' % \
128+
(quoteStr(toponame), quoteId(toponame), toposrid)
127129
uri.setDataSource('', u'(%s\n)' % sql, 'geom', '', 'face_id')
128130
uri.setSrid(toposrid)
129131
uri.setWkbType(QGis.WKBPolygon)
@@ -136,8 +138,11 @@ def run(item, action, mainwindow):
136138
legend.setLayerExpanded(layer, False)
137139

138140
# face_seed
139-
sql = u'SELECT face_id, ST_PointOnSurface(topology.ST_GetFaceGeometry(%s, face_id)) as geom ' \
140-
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame))
141+
sql = u'SELECT face_id, ST_PointOnSurface(' \
142+
'topology.ST_GetFaceGeometry(%s,' \
143+
'face_id))::geometry(point, %s) as geom ' \
144+
'FROM %s.face WHERE face_id > 0' % \
145+
(quoteStr(toponame), quoteId(toponame), toposrid)
141146
uri.setDataSource('', u'(%s)' % sql, 'geom', '', 'face_id')
142147
uri.setSrid(toposrid)
143148
uri.setWkbType(QGis.WKBPoint)

0 commit comments

Comments
 (0)
Please sign in to comment.