Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make geometry typmod available for topology face layer queries
Greatly improves performances on topology loading.
See http://hub.qgis.org/issues/14356
  • Loading branch information
Sandro Santilli committed Feb 22, 2016
1 parent bf583c7 commit d8a768f
Showing 1 changed file with 9 additions and 4 deletions.
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d8a768f

Please sign in to comment.