Make geometry typmod available for topology face layer queries

Greatly improves performances on topology loading.
See http://hub.qgis.org/issues/14356
This commit is contained in:
Sandro Santilli 2016-02-22 23:12:52 +01:00
parent bf583c7236
commit d8a768f0a0

View File

@ -122,8 +122,10 @@ def run(item, action, mainwindow):
face_extent = layer.extent()
# face geometry
sql = u'SELECT face_id, topology.ST_GetFaceGeometry(%s, face_id) as geom ' \
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame))
sql = u'SELECT face_id, topology.ST_GetFaceGeometry(%s,' \
'face_id)::geometry(polygon, %s) as geom ' \
'FROM %s.face WHERE face_id > 0' % \
(quoteStr(toponame), quoteId(toponame), toposrid)
uri.setDataSource('', u'(%s\n)' % sql, 'geom', '', 'face_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBPolygon)
@ -136,8 +138,11 @@ def run(item, action, mainwindow):
legend.setLayerExpanded(layer, False)
# face_seed
sql = u'SELECT face_id, ST_PointOnSurface(topology.ST_GetFaceGeometry(%s, face_id)) as geom ' \
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame))
sql = u'SELECT face_id, ST_PointOnSurface(' \
'topology.ST_GetFaceGeometry(%s,' \
'face_id))::geometry(point, %s) as geom ' \
'FROM %s.face WHERE face_id > 0' % \
(quoteStr(toponame), quoteId(toponame), toposrid)
uri.setDataSource('', u'(%s)' % sql, 'geom', '', 'face_id')
uri.setSrid(toposrid)
uri.setWkbType(QGis.WKBPoint)