[Qgis-developer] QGIS not displaying geometries from ogr provider
Nathan Woodrow
madmanwoo at gmail.com
Fri Mar 18 02:17:44 EDT 2011
Hi All,
I wrote a blog post a couple of days ago about opening MS SQL
Spatial geometries and it worked fine then but the latest revision can't
seem to display them.
It opens the table correctly, detects the geometry type right and I can even
browse the table but no geometries are displayed.
This is the code I use in the Python console to open the layer and then test
to see if the geometry is there.
>>> uri =
> "MSSQL:server=SD0302;database=Test;tables=DRAINAGE;trusted_connection=yes"
> >>> uri
> 'MSSQL:server=SD0302;database=Test;tables=DRAINAGE;trusted_connection=yes'
> >>> qgis.utils.iface.addVectorLayer(uri,'drains1','ogr')
> <qgis.core.QgsVectorLayer object at 0x1EBD96A8>
> >>> can = qgis.utils.iface.mapCanvas()
> >>> can
> <qgis.gui.QgsMapCanvas object at 0x0667F7C8>
> >>> can.currentLayer()
> <qgis.core.QgsVectorLayer object at 0x1EBD9F18>
> >>> can.currentLayer().dataProvider()
> <qgis.core.QgsVectorDataProvider object at 0x1EBD9F60>
> >>> can.currentLayer().select(1)
> >>> can.currentLayer().select(1)
> >>> layer.selectedFeatures()
> [<qgis.core.QgsFeature object at 0x1EBD9E88>]
> >>> item = layer.selectedFeatures()[0]
> >>> item
> <qgis.core.QgsFeature object at 0x1EBD96A8>
> >>> item.isValid()
> True
> >>> item.geometry()
> <qgis.core.QgsGeometry object at 0x1EBD9F60>
> >>> item.geometry().length()
> 14.968913045995375
> >>> item.geometry().asWkb()
> '\x01\x02\x00\x00\x00\x02\x00\x00\x00\xf9
> \xdb{\xd2\xb5\x18A\xc5\x19\x0f\x19\x04?ZA\xd4=W\xfb\x96\xb5\x18A\xff\xcf\xea\x83\x04?ZA'
> >>> item.geometry().exportToWkt()
> PyQt4.QtCore.QString(u'LINESTRING(404852.620953 6880272.391547,
> 404837.745450 6880274.061207)')
> >>>
When I run can.currentLayer().select(1) QGIS says in the status bar that
there is 1 feature selected and I can zoom to the correct spot on the map
but nothing is displayed.
Would anyone have any idea what's going on here?
OS: Windows XP
QGIS Version r15530
GDAL/OGR 1.8
- Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20110318/126b1db9/attachment-0001.html
More information about the Qgis-developer
mailing list