[Qgis-developer] QgsMapLayerRegistry.mapLayers() not available in Python Bindings

Düster Horst Horst.Duester at bd.so.ch
Fri Jan 11 06:01:52 EST 2008


Martin,

Thank you very much for your response. I think for my purposes
mapLayers() would be a good solution. So I'll wait for the wrapped
method.

Horst

------------------------------------------------

Dr. Horst Düster
GIS-Koordinator, Stv. Amtschef

Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
SO!GIS Koordination
Rötistrasse 4
CH-4501 Solothurn

Telefon ++41(0)32 627 25 32
Telefax ++41(0)32 627 22 14

mailto:horst.duester at bd.so.ch
http://www.agi.so.ch



-----Ursprüngliche Nachricht-----
Von: Martin Dobias [mailto:wonder.sk at gmail.com]
Gesendet am: Freitag, 11. Januar 2008 11:57
An: Düster Horst
Cc: qgis-developer
Betreff: Re: [Qgis-developer] QgsMapLayerRegistry.mapLayers() not
available in Python Bindings

On Jan 11, 2008 11:01 AM, Düster Horst <Horst.Duester at bd.so.ch> wrote:
>
>
> With Python I want to get all avalilable map layers from my current
project.
> I tried to do this with
>
> layerCollection = QgsMapLayerRegistry().instance().mapLayers()
>
> It doesn't work. I took a look into qgsmaplayerregistry.sip and found
out
> that the method mapLayers() is not wrapped until now. What is to do to
wrap
> this method. Does exists a workareound to retrieve all project layers.

Hi,

this function isn't wrapped so far because mapLayers() uses std::map
container which should be replaced with QMap instead. It's not a lot
of work, I'll do it probably soon.
Please note that theoretically QgsMapLayerRegistry can contain also
layers which are not part of the project (e.g. when using
georeferencer plugin it adds temporarily a layer to the registry).

In fact there is currently no way how to directly access all project's
layers correctly, since map canvas doesn't keep list of all layers
(only those which are visible) and it's not possible to access legend
from the plugin as it's not part of QGIS libraries :-/

One workaround would be to save the project and then use legend's
nodes to parse the list of layers, which is, well, quite inconvenient.
We should definitely do something with this. I guess for now wrapping
mapLayers() would do it...

Regards
Martin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20080111/b449806e/attachment.html


More information about the Qgis-developer mailing list