Re: [QGIS-Developer] Inserting provider filter just before PostGIS layer is loaded?
Thomas B sent me a suggestion off list and allowed me to share it: QgsProject.layersAdded.connect(func) actually seems to emit in just the right moment. This feels super finicky but so far it has worked flawlessly to set the layer.setSubsetString() *before* the actual query goes out to the DB. Hope I don't jinx it by posting ;) Handle with care, and thanks Thomas! Cheers, Hannes Am 09.08.22 um 11:15 schrieb Johannes Kröger (WhereGroup) via QGIS-Developer: Howdy! I'd like to force a provider filter when a user adds a PostGIS layer and have it applied *before* any data is loaded. Setting it after the layer (and some of its big data) is loaded initially is not an option. Is there a way to sneak in between "user clicked something in the GUI to load a table/query and QGIS will construct a QgsVectorLayer now" and "QGIS now talks to the PostGIS database to get the data for the new layer", maybe with a signal? Something like a "layerAboutToBeLoaded" (like the opposite layerWillBeRemoved on https://qgis.org/pyqgis/master/core/QgsProject.html) basically. :o) Cheers, Hannes OpenPGP_0x840A4B843789797F.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] Inserting provider filter just before PostGIS layer is loaded?
Thank you for the idea! The goal is to sneakily jump in when the user is adding any layer though (without them caring about anything, without any rules they have to follow). I'll post our solution in the main thread in a moment. Cheers, Hannes Am 22.08.22 um 12:11 schrieb Jacky Volpes: Hi, I don't know any way to do this, except for using a workaround. But it will depend on your use-case. Maybe using query layers, such as QgsVectorLayer("table='(select * from . conditions>)' service='' key=''", "name>", "postgres") can help ? Regards, Jacky Le 09/08/2022 à 11:15, Johannes Kröger (WhereGroup) via QGIS-Developer a écrit : Howdy! I'd like to force a provider filter when a user adds a PostGIS layer and have it applied *before* any data is loaded. Setting it after the layer (and some of its big data) is loaded initially is not an option. Is there a way to sneak in between "user clicked something in the GUI to load a table/query and QGIS will construct a QgsVectorLayer now" and "QGIS now talks to the PostGIS database to get the data for the new layer", maybe with a signal? Something like a "layerAboutToBeLoaded" (like the opposite layerWillBeRemoved on https://qgis.org/pyqgis/master/core/QgsProject.html) basically. :o) Cheers, Hannes ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer -- Jacky Volpes Ingénieur SIG - Oslandia -- Johannes Kröger / GIS-Entwickler/-Berater - Schon gewusst? In unserem Blog geben wir Tipps & Tricks zu Open-Source-GIS-Software und berichten aus unserem Experten-Alltag: https://wheregroup.com/blog/ - WhereGroup GmbH Grevenweg 89 20537 Hamburg Germany Tel: +49 (0)228 / 90 90 38 - 36 Fax: +49 (0)228 / 90 90 38 - 11 johannes.kroe...@wheregroup.com www.wheregroup.com Geschäftsführer: Olaf Knopp, Peter Stamm Amtsgericht Bonn, HRB 9885 --- OpenPGP_0x840A4B843789797F.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] Inserting provider filter just before PostGIS layer is loaded?
I think this could find an interesting framework in the proposal of a new database interface. One of the proposals pertains to the process interface. Maybe it could become a more generic interface to data sources. More and more data infrastructures are intrinsically no-SQL and it could be interesting to mix them at the source level and not afterwards when it becomes heavy and very application specific. Disclaimer: I had a love affair with MapInfo MapBasic and I miss its command interface. It would be wonderful to have a SQL-like interface for it – and the Spatialite interface that comes with GDAL would be a good opportunity for it. BTW: maybe a virtual GDAL interface would help in getting what you need for OsGeo services. On Mon, Aug 22, 2022 at 12:11 PM Jacky Volpes via QGIS-Developer < qgis-developer@lists.osgeo.org> wrote: > Hi, > > I don't know any way to do this, except for using a workaround. > But it will depend on your use-case. > Maybe using query layers, such as > > QgsVectorLayer("table='(select * from . )' > service='' key=''", "", "postgres") > > can help ? > > Regards, > Jacky > > > > Le 09/08/2022 à 11:15, Johannes Kröger (WhereGroup) via QGIS-Developer a > écrit : > > Howdy! > > I'd like to force a provider filter when a user adds a PostGIS layer and > have it applied *before* any data is loaded. Setting it after the layer > (and some of its big data) is loaded initially is not an option. > > Is there a way to sneak in between "user clicked something in the GUI to > load a table/query and QGIS will construct a QgsVectorLayer now" and "QGIS > now talks to the PostGIS database to get the data for the new layer", maybe > with a signal? > > Something like a "layerAboutToBeLoaded" (like the opposite > layerWillBeRemoved on https://qgis.org/pyqgis/master/core/QgsProject.html) > basically. :o) > > Cheers, Hannes > > > ___ > QGIS-Developer mailing listqgis-develo...@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > > > -- > Jacky Volpes > > Ingénieur SIG - Oslandia > > ___ > QGIS-Developer mailing list > QGIS-Developer@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer > ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [QGIS-Developer] Inserting provider filter just before PostGIS layer is loaded?
Hi, I don't know any way to do this, except for using a workaround. But it will depend on your use-case. Maybe using query layers, such as QgsVectorLayer("table='(select * from . conditions>)' service='' key=''", "name>", "postgres") can help ? Regards, Jacky Le 09/08/2022 à 11:15, Johannes Kröger (WhereGroup) via QGIS-Developer a écrit : Howdy! I'd like to force a provider filter when a user adds a PostGIS layer and have it applied *before* any data is loaded. Setting it after the layer (and some of its big data) is loaded initially is not an option. Is there a way to sneak in between "user clicked something in the GUI to load a table/query and QGIS will construct a QgsVectorLayer now" and "QGIS now talks to the PostGIS database to get the data for the new layer", maybe with a signal? Something like a "layerAboutToBeLoaded" (like the opposite layerWillBeRemoved on https://qgis.org/pyqgis/master/core/QgsProject.html) basically. :o) Cheers, Hannes ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer -- Jacky Volpes Ingénieur SIG - Oslandia ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
[QGIS-Developer] Inserting provider filter just before PostGIS layer is loaded?
Howdy! I'd like to force a provider filter when a user adds a PostGIS layer and have it applied *before* any data is loaded. Setting it after the layer (and some of its big data) is loaded initially is not an option. Is there a way to sneak in between "user clicked something in the GUI to load a table/query and QGIS will construct a QgsVectorLayer now" and "QGIS now talks to the PostGIS database to get the data for the new layer", maybe with a signal? Something like a "layerAboutToBeLoaded" (like the opposite layerWillBeRemoved on https://qgis.org/pyqgis/master/core/QgsProject.html) basically. :o) Cheers, Hannes OpenPGP_0x840A4B843789797F.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer