Re: [QGIS-Developer] Access to shapeDigitizeToolBar menu's text

2024-03-06 Thread Jacky Volpes via QGIS-Developer

Hi Luke,

It works with setDisabled on action_item.
Be careful not to call setDisabled on every action of a category, then 
yes, it disables the entire icon.


Updated snippet for example:

actions_list = []
sdtb = iface.shapeDigitizeToolBar()
for i, action_widget_item in enumerate(sdtb.actions()):
    if action_widget_item.defaultWidget().menu() is None:
actions_list.append(action_widget_item.defaultWidget().defaultAction())
    continue
    actions_list += action_widget_item.defaultWidget().menu().actions()

actions_ids = ['rectangle-from-extent', 'circle-from-3-points']  # 
actions ids to disable
[a.setDisabled(True) for a in actions_list if a.data() in actions_ids]  
# disable the actions




Jacky Volpes

Ingénieur SIG - Oslandia




Le 05/03/2024 à 19:32, Catania, Luke A ERDC-RDE-GRL-VA CIV a écrit :


When I use setDisabled on either action_widget_item.defaultWidget or 
action_item it sets the disables the entire icon as opposed to the 
specific action item found.  Maybe I am missing something.  Like I 
don’t want the user to be able to draw an Ellipse from Foci so I 
disable that, but it disables the entire icon of menus for drawing 
Elipses.


*From:* Jacky Volpes 
*Sent:* Tuesday, February 27, 2024 5:29 AM
*To:* Catania, Luke A ERDC-RDE-GRL-VA CIV 
; qgis-developer@lists.osgeo.org

*Subject:* Re: [QGIS-Developer] Access to shapeDigitizeToolBar menu's text

Hi Luke,

As you can see on the printed text, objects are QWigetAction, not QAction.
This is because you get each category of the tool bar, where then each 
one contains one or more digitizing QActions.



Here is a snippet that can help you explore the tool bar:


sdtb = iface.shapeDigitizeToolBar()
for i, action_widget_item in enumerate(sdtb.actions()):
    print(f"{i}: {action_widget_item.defaultWidget().text()}")
    for j, action_item in 
enumerate(action_widget_item.defaultWidget().menu().actions()):

    print (f"\t{j}: {action_item.data()}")  # id like
    print (f"\t\ttranslated text: {action_item.text()}")


Regards,

Jacky Volpes
Ingénieur SIG - Oslandia


Le 27/02/2024 à 04:10, Catania, Luke A ERDC-RDE-GRL-VA CIV via 
QGIS-Developer a écrit :


Trying to get access to the button menus in shapeDigitizeToolBar.

from qgis.utils import iface

from PyQt5.QtWidgets import QWidgetAction

sdtb = iface.shapeDigitizeToolBar()

i=0

for action_item in sdtb.actions():

    i=i+1

    print (f"{i}: {action_item}")

This prints:

1: 

2: 

3: 

4: 

5: 

I want to access each button and the menus of the button so I can
disable certain tools.  I need to get the text associated with the
tools so I can key on that.

I can’t figure out how to get to them from QWidgetAction. I called
all the methods on QAction that returns a string: data, iconText,
statusTip, whatsThis and they all return empty strings.  So how
are these menus labeled.

Thanks,

Luke



___

QGIS-Developer mailing list

QGIS-Developer@lists.osgeo.org

List info:Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked  
https://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked>

Unsubscribe:Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked 
 https://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked>

___
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] Access to shapeDigitizeToolBar menu's text

2024-02-27 Thread Jacky Volpes via QGIS-Developer

Hi Luke,

As you can see on the printed text, objects are QWigetAction, not QAction.
This is because you get each category of the tool bar, where then each 
one contains one or more digitizing QActions.



Here is a snippet that can help you explore the tool bar:


sdtb = iface.shapeDigitizeToolBar()
for i, action_widget_item in enumerate(sdtb.actions()):
    print(f"{i}: {action_widget_item.defaultWidget().text()}")
    for j, action_item in 
enumerate(action_widget_item.defaultWidget().menu().actions()):

    print (f"\t{j}: {action_item.data()}")  # id like
    print (f"\t\ttranslated text: {action_item.text()}")


Regards,

Jacky Volpes

Ingénieur SIG - Oslandia


Le 27/02/2024 à 04:10, Catania, Luke A ERDC-RDE-GRL-VA CIV via 
QGIS-Developer a écrit :


Trying to get access to the button menus in shapeDigitizeToolBar.

from qgis.utils import iface

from PyQt5.QtWidgets import QWidgetAction

sdtb = iface.shapeDigitizeToolBar()

i=0

for action_item in sdtb.actions():

    i=i+1

    print (f"{i}: {action_item}")

This prints:

1: 

2: 

3: 

4: 

5: 

I want to access each button and the menus of the button so I can 
disable certain tools.  I need to get the text associated with the 
tools so I can key on that.


I can’t figure out how to get to them from QWidgetAction. I called all 
the methods on QAction that returns a string: data, iconText, 
statusTip, whatsThis and they all return empty strings.  So how are 
these menus labeled.


Thanks,

Luke


___
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] GSoC 2024 proposal : QGIS improve the graphical modeler UI and UX

2024-02-22 Thread Jacky Volpes via QGIS-Developer

Hi Valentin,

That's quite an impressive proposal!
I could not agree more with you about the need to have a better design, 
UX, and UI for the modeler.
However, as Nyall already pointed out, you can be sure that the schedule 
will largely shift seeing the amount of work/features, and I also would 
advise to drop quality of life changes, the proposal still remaining 
very attractive.


I am looking forward to seeing you in Grenoble next month :-)

Best regards,

Jacky Volpes

Ingénieur SIG - Oslandia



Le 22/02/2024 à 08:37, Valentin BUIRA via QGIS-Developer a écrit :

Hi qgis developers

My name is Valentin Buira, I'm a french student in urban planning and 
I'm interested in participating in this year Google Summer of Code to 
improve the graphical modeler.


In particular I am interested in improving the user interface(UI) and 
user experience (UX) of the graphical modeler based on my previous 
experience with other node-based applications. If you are familiar 
with Blender the inspiration will be obvious to you but I tried to 
adapt to the identity and features of Qgis like the expression engine.


You can find the proposal at the url : 
https://docs.google.com/document/d/1iXHMTylTHLljfHBITfuIfJzi4_4hpQifEvj5GkM8OCc/edit?usp=sharing


So far I am happy with my proposal but I'm looking for feedback and 
suggestions, and also tips on the technical feasibility and the 
schedule of the proposal.


On a side note, I will be attending the local code sprint in Grenoble 
the 26 mars. Where I will also discuss this proposal in person.


Best regards,
Valentin Buira



___
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] Reading current measurement with python

2023-10-25 Thread Jacky Volpes via QGIS-Developer

Hi,

If I understand well, it's possible that a styled layer could be 
sufficient...?
See "Description" section on this style 
.
Import the style 
 
in QGIS style manager.


Regards,

Jacky Volpes

Ingénieur SIG - Oslandia

Le 09/10/2023 à 09:45, Simon Gröchenig a écrit :

Hi,


As I don't have the context explaining why you need this

I try to "save" measurements as annotation or linestring/area layer in order to 
see measurements in layouts.

Currently, I copy (linear) measurements and use the coordinates from 
QGuiApplication.clipboard() to draw a temporary linestring. I would like to skip copying 
the measurements. Also, I would like to "save" area measurements where copy is 
not supported by the measurement gui.

Any ideas?

Simon


-Ursprüngliche Nachricht-
Von: Jacky Volpes  
Gesendet: Freitag, 6. Oktober 2023 15:00

An:qgis-developer@lists.osgeo.org
Cc: Simon Gröchenig
Betreff: Re: [QGIS-Developer] Reading current measurement with python

Hi Simon,

Ok, I understand your question now.

Unfortunately, the measurement tool is not accessible with the python API.

As I don't have the context explaining why you need this, I can propose you to 
find another way for your process, or, if you really need to get the 
measurement value, here is a code snippet that finds the text within the 
measurement dialog (I don't recommend you to use this in a production 
environment though, or you might have unexpected behaviors if something changes 
in the dialog implementation).


measurementDialogs = [d for d in
iface.mainWindow().findChildren(QDialog, "QgsMeasureBase") if d.isVisible()] if 
len(measurementDialogs) == 1:
      measurementDialog = measurementDialogs[0]
      totalTextLineEdit = measurementDialog.findChild(QLineEdit, "editTotal")
      if totalTextLineEdit is not None:
      print(totalTextLineEdit.text())


Best regards,

Jacky Volpes

Ingénieur SIG - Oslandia

--

Le 04/10/2023 à 10:15, Simon Gröchenig a écrit :

Hi Jacky,

thanks for your help and for pointing me to this code snippet.

However, I see that the measurement tools are instances of QgsMapTool with an 
QAction (and not QgsMapToolDigitizeFeature) and therefore mapTool().pointsZM() 
is not available.

Now I wonder if I can utilize the QgsRubberBand

Best regards
Simon


--

Message: 2
Date: Mon, 2 Oct 2023 08:56:58 +0200
From: Jacky Volpes
To:qgis-developer@lists.osgeo.org
Subject: Re: [QGIS-Developer] Reading current measurement with python
Message-ID:<352a9e94-9010-4f39-8738-89323a87a...@oslandia.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi,

You can have a look at this snippet:
https://lists.osgeo.org/pipermail/qgis-developer/2023-May/065789.html

Regards,

--

Jacky Volpes

Ing?nieur SIG - Oslandia

--

Le 02/10/2023 ? 07:05, Simon Gr?chenig via QGIS-Developer a ?crit?:

Hi list,

is it possible to get the current line/area measurement with Python?

Simon


___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
Listinfo:https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer

-- next part --
An HTML attachment was scrubbed...
URL:

___
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] Reading current measurement with python

2023-10-06 Thread Jacky Volpes via QGIS-Developer

Hi Simon,

Ok, I understand your question now.

Unfortunately, the measurement tool is not accessible with the python API.

As I don't have the context explaining why you need this, I can propose 
you to find another way for your process, or, if you really need to get 
the measurement value, here is a code snippet that finds the text within 
the measurement dialog (I don't recommend you to use this in a 
production environment though, or you might have unexpected behaviors if 
something changes in the dialog implementation).



measurementDialogs = [d for d in 
iface.mainWindow().findChildren(QDialog, "QgsMeasureBase") if d.isVisible()]

if len(measurementDialogs) == 1:
    measurementDialog = measurementDialogs[0]
    totalTextLineEdit = measurementDialog.findChild(QLineEdit, "editTotal")
    if totalTextLineEdit is not None:
    print(totalTextLineEdit.text())


Best regards,

Jacky Volpes

Ingénieur SIG - Oslandia

--

Le 04/10/2023 à 10:15, Simon Gröchenig a écrit :

Hi Jacky,

thanks for your help and for pointing me to this code snippet.

However, I see that the measurement tools are instances of QgsMapTool with an 
QAction (and not QgsMapToolDigitizeFeature) and therefore mapTool().pointsZM() 
is not available.

Now I wonder if I can utilize the QgsRubberBand

Best regards
Simon


--

Message: 2
Date: Mon, 2 Oct 2023 08:56:58 +0200
From: Jacky Volpes 
To: qgis-developer@lists.osgeo.org
Subject: Re: [QGIS-Developer] Reading current measurement with python
Message-ID: <352a9e94-9010-4f39-8738-89323a87a...@oslandia.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi,

You can have a look at this snippet:
https://lists.osgeo.org/pipermail/qgis-developer/2023-May/065789.html

Regards,

--

Jacky Volpes

Ing?nieur SIG - Oslandia

--

Le 02/10/2023 ? 07:05, Simon Gr?chenig via QGIS-Developer a ?crit?:

Hi list,

is it possible to get the current line/area measurement with Python?

Simon


___
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

-- next part --
An HTML attachment was scrubbed...
URL: 



___
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] Reading current measurement with python

2023-10-02 Thread Jacky Volpes via QGIS-Developer

Hi,

You can have a look at this snippet: 
https://lists.osgeo.org/pipermail/qgis-developer/2023-May/065789.html


Regards,

--

Jacky Volpes

Ingénieur SIG - Oslandia

--

Le 02/10/2023 à 07:05, Simon Gröchenig via QGIS-Developer a écrit :


Hi list,

is it possible to get the current line/area measurement with Python?

Simon


___
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] loadNamedStyle() is loading default style instead of QML file

2023-09-11 Thread Jacky Volpes via QGIS-Developer

Hi Alexandre,

When the layer is a PostgreSQL layer, it's the method from 
QgsVectorLayer which is called:


https://qgis.org/pyqgis/3.32/core/QgsVectorLayer.html#qgis.core.QgsVectorLayer.loadNamedStyle

https://api.qgis.org/api/classQgsVectorLayer.html#a2bd3a21badac411179dbfbc724136a45


The documentation is somewhat incomplete, as "loadFromLocalDb" boolean 
set to true will in fact call QgsMapLayer::loadNamedStyle()


https://api.qgis.org/api/classQgsMapLayer.html#a8b271b8bf3074e84808cff26f722b26f

which says: "[...] First an attempt will be made to see if this is a 
file and load that, if that fails the qgis.db styles table will be 
consulted to see if there is a style who's key matches the URI."


Regards,

--

Jacky Volpes

Ingénieur SIG - Oslandia

--

Le 9/11/23 à 13:33, Alexandre Neto via QGIS-Developer a écrit :

I am trying to load a style from a QML file into a vector layer.

When I use a memory layer, loading the style works fine with the 
following code:


layer = iface.activeLayer()
layer.loadNamedStyle(path_to_style)

If the layer is a postgreSQL layer with a default style, the above 
code will return:


('Loaded from provider', True)

and the style from the QML won't be loaded. The way to force it was 
add a True parameter in the end of the method call:


layer = iface.activeLayer()
layer.loadNamedStyle(path_to_style, True)

Not sure if this is the correct behavior, but it does not match with 
the documentation:


https://api.qgis.org/api/classQgsMapLayer.html#a8b271b8bf3074e84808cff26f722b26f

Thanks,

Alexandre Neto

___
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] Load Style and Save Style forms from python code

2023-05-11 Thread Jacky Volpes via QGIS-Developer

Hello,

You can try this method 
, 
available in python bindings from 3.30:


props = QgsVectorLayerProperties(iface.mapCanvas(), iface.messageBar(), 
iface.activeLayer())

props.loadStyle() or props.saveStyleAs()

Regards,
Jacky Volpes



Le 11/05/2023 à 07:21, Giulio Fattori via QGIS-Developer a écrit :

Good morning
how can I recall and use the Load Style and Save Style forms from 
python code ?


Many thanks for any support

Giulio

___
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


Re: [QGIS-Developer] Digitizing with Edit Menu

2023-05-02 Thread Jacky Volpes via QGIS-Developer

Hello,

Have you tried this following code? Using 
iface.mapCanvas().mapTool().pointsZM() is good for me with any 
digitizing tool, while drawing.



# Measurement object (adapt with crs/transform context/ellipsoid)
da = QgsDistanceArea()
da.setSourceCrs(QgsProject.instance().crs(), 
QgsProject.instance().transformContext())

# If distance measurement must use ellipsoid
da.setEllipsoid(QgsProject.instance().ellipsoid())

# This is a demonstration function to adapt with your needs
def showArea(current_point):
    if not isinstance(iface.mapCanvas().mapTool(), 
QgsMapToolDigitizeFeature):

    return

    # Snapping
    snapped_point = 
iface.mapCanvas().snappingUtils().snapToMap(current_point).point()

    if not snapped_point.isEmpty():
    current_point = snapped_point

    # Coordinates of currently drawn points in map coordinates
    points = [QgsPointXY(point) for point in 
iface.mapCanvas().mapTool().pointsZM()]

    points.append(current_point)

    # Get area
    print(da.measurePolygon(points))

# Must be handled correctly in the final code, but here is for testing
iface.mapCanvas().xyCoordinates.connect(showArea)



Le 29/04/2023 à 01:45, Catania, Luke A ERDC-RDE-GRL-VA CIV via 
QGIS-Developer a écrit :


When you digitize a shape using the Edit menu in QGIS is the shape 
accessible?  I am looking to get he area of the shape as it is drawn.  
I have added an event filter to my code to capture the coordinates and 
calculate it by creating a QgsGeometry, but my code is getting 
complicated as there are many shapes that a user can draw from this 
menu so if I can get access to this shape if it is temporary in 
memory, then I can just calculate the area on the shape and not have 
to capture all the positions of the mouse when clicked and moved.



___
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


Re: [QGIS-Developer] Temporarily disable map canvas right click showing Copy Coordinates

2023-04-13 Thread Jacky Volpes via QGIS-Developer
Maybe return True in your eventFilter, so that the event is not 
processed further by other widgets?


Regards,


--
Jacky Volpes

Ingénieur SIG - Oslandia



Le 13/04/2023 à 08:11, Catania, Luke A ERDC-RDE-GRL-VA CIV via 
QGIS-Developer a écrit :

I thought I tried this before and it still showed the menu with its menu grayed 
out, but maybe I set it on the submenu item, but I solved my issue by calling

menu.setDisabled(True) on the QMenu.  I reset it to False after my editing is 
done so the context menu is available again.

If anyone thinks of a better way feel free to answer, but this will work for 
now.  I was hoping the setContextMenuPolicy methd would work.

-Original Message-
From: QGIS-Developer  On Behalf Of 
Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer
Sent: Thursday, April 13, 2023 1:29 AM
To: Nyall Dawson
Cc:qgis-developer@lists.osgeo.org
Subject: Re: [QGIS-Developer] Temporarily disable map canvas right click 
showing Copy Coordinates

I am not using QgsMapTool.

T o capute mouse events, I declared my class as

class AoiSizeValidator(QWidget):

And added

def eventFilter(self, source, event):

with code that captures mouse click events.

I tried using

 iface.mapCanvas().setContextMenuPolicy(Qt.NoContextMenu)

and

 iface.mapCanvas().setContextMenuPolicy(Qt.PreventContextMenu)

But it did not work. I found that suggestion on a site where someone was 
looking to disable the context menu for QWebEngineView, so thought it would 
work for the map canvas.

I did find half a solution by setting

 
iface.mapCanvas().contextMenuAboutToShow.connect(self.disable_context_menu)

 def disable_map_canvas_context_menu(self, menu: QMenu, event: 
QgsMapMouseEvent):
menu.clear()

which basically completely clears the context menu from all its widgets, but I 
would like he menu back after my right click event happens to end the edit 
session.

-Original Message-
From: Nyall Dawson  
Sent: Wednesday, April 12, 2023 9:09 PM

To: Catania, Luke A ERDC-RDE-GRL-VA CIV
Cc:qgis-developer@lists.osgeo.org
Subject: Re: [QGIS-Developer] Temporarily disable map canvas right click 
showing Copy Coordinates

On Thu, 13 Apr 2023 at 10:47, Catania, Luke A ERDC-RDE-GRL-VA CIV via 
QGIS-Developer  wrote:

I have an event filter on the map canvas that performs a commit during feature 
editing when right clicking on the canvas.  While this performs the commit, it 
then pops up Copy Coordinates.  I don’t want the user to see this.  I want my 
mouse click event to be recognized and not have QGIS use it to popup the Copy 
Coordinates.  Is there a way to call QgsMapTool.deactivate on that built in 
tool just for this instance and then reactivate it?

Are you using a custom QgsMapTool subclass? If so, implement the "flags" method 
and don't return the ShowContextMenu flag.

Nyall



___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info:
Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
Unsubscribe:
Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
Unsubscribe: 
Blockedhttps://lists.osgeo.org/mailman/listinfo/qgis-developerBlocked
___
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] Detect a Map Canvas Mouse Event

2023-04-11 Thread Jacky Volpes via QGIS-Developer

Hello,

Here is a snipped of code that can help you.
To test this you have to:
- Show python console
- enable the polygonal digitizing tool (must be the active tool before 
launching this snippet)

- execute the code in the python editor
- start digitizing
- see the area printing in the console

Don't hesitate if you have further questions.

Regards,
Jacky Volpes - Djedouas - Oslandia

---

# Measurement object (adapt with crs/transform context/ellipsoid)
da = QgsDistanceArea()
da.setSourceCrs(QgsProject.instance().crs(), 
QgsProject.instance().transformContext())

# If distance measurement must use ellipsoid
da.setEllipsoid(QgsProject.instance().ellipsoid())

# This is a demonstration function to adapt with your needs
def showArea(current_point):
    if not isinstance(iface.mapCanvas().mapTool(), 
QgsMapToolDigitizeFeature):

    return

    # Snapping
    snapped_point = 
iface.mapCanvas().snappingUtils().snapToMap(current_point).point()

    if not snapped_point.isEmpty():
    current_point = snapped_point

    # Coordinates in map coordinates
    points = [QgsPointXY(point) for point in 
iface.mapCanvas().mapTool().pointsZM()]

    points.append(current_point)

    # Show area
    print(da.measurePolygon(points))

# Must be handled correctly in the final code, but here is for testing
iface.mapCanvas().xyCoordinates.connect(showArea)








Le 05/04/2023 à 17:56, Catania, Luke A ERDC-RDE-GRL-VA CIV via 
QGIS-Developer a écrit :


Looking for something like

canvas.xyCoordinates.connect( self.canvasMoveEvent )

but that’s from a 7 year old post so looks like xyCoordinates is not 
in QGIS 3.x


*From:* QGIS-Developer  *On 
Behalf Of *Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer

*Sent:* Wednesday, April 5, 2023 11:53 AM
*To:* qgis-developer@lists.osgeo.org
*Subject:* Re: [QGIS-Developer] Detect a Map Canvas Mouse Event

I found

QgsMapToolEmitPoint, QgsMapTooland |canvas.setMapTool(…)|
||

|So I declared my class as |AoiSizeValidator(QgsMapToolEmitPoint)

||
|But gave that a try and it gets me x,y, initially but when I select 
an add layer from the qgis edit menu, I guess it sets a new map tool 
so mine gets overridden.  So looks like I need a different approach to 
get xy from the map canvas. |


*From:* QGIS-Developer  *On 
Behalf Of *Catania, Luke A ERDC-RDE-GRL-VA CIV via QGIS-Developer

*Sent:* Wednesday, April 5, 2023 11:27 AM
*To:* qgis-developer@lists.osgeo.org
*Subject:* [QGIS-Developer] Detect a Map Canvas Mouse Event

Trying to get a map canvas event when canvas is clicked and mouse is 
dragged.  I have code that creates an empty layer, but I use the QGIS 
edit menu to add the actually layer.  I want to be able to track the 
mouse movement so I can calculated the area of the feature being drawn 
in real time so I can make sure the area is within a defined range.


Is there an event I can connect to so I can run my custom code when 
the even occurs?



___
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


Re: [QGIS-Developer] install plugin from github

2023-03-21 Thread Jacky Volpes via QGIS-Developer

Hi,

I recommend that you clone the repository somewhere else on your 
computer, and add the path in QGIS settings, in the System > Environment 
variable section, in QGIS_PLUGINPATH (see capture below).


This way you will always be able to put the correct path to the plugin.

Because here for instance with this plugin 
, if you want 
your method to work, you should put "ProjectPackager" directory in 
C:\...AppData...\python\plugins\, which is one level inside the cloned repo.
(i.e. the plugin directory is the directory where the metadata.txt file 
is, and not the whole directory from the repo).


I also recommend the use of the plugin "Plugin Reloader", so that you 
can reload your python files without quiting/lauching QGIS each time (or 
deactivating/reactivating the plugin).





Regards,

Jacky Volpes
Oslandia



Le 21/03/2023 à 14:57, Hugh Kelley via QGIS-Developer a écrit :

Hi,

could anyone share instructions for installing a plugin from the 
source code on github instead of the plugin manager and subsequently 
making changes and running the plugin to see the difference?


I've tried cloning the repo to:
C:\Users\hkelley\AppData\Roaming\QGIS\QGIS3\profiles\project-packager_dev\python\plugins\qgis-project-packager-plugin
and moved some things around to copy the set up of other installed 
plugins.


The plugin appears in the "installed" list but doesn't work.

Maybe I need to compile it? but I would have thought for a python only 
plugin that wouldn't be necessary.


I've also separately followed the instructions for building a plugin 
from scratch using plug in builder and plugin reloader. It's not clear 
to me how I would apply those steps to working with an existing plugin.


thanks for any guidance.

Hugh

___
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


Re: [QGIS-Developer] PyQGIS: how to modify default behavior of QgsRubberBand

2023-02-20 Thread Jacky Volpes via QGIS-Developer

Hi Joseph,

Like you, rubber bands and drawing/paint stuff are quite obscure to me 
and I need to dig into it when I want something specific...
I don't have a direct answer, but you could look into existing code 
doing similar things: the plugins "beePen" and "Bezier Editing" 
available in QGIS are "freehand" drawing tools.

They might use some of these functions.

Regards,

--
Jacky Volpes

Ingénieur SIG - Oslandia


beePen: https://github.com/mauroalberti/beePen
Bezier Editing: https://github.com/tmizu23/BezierEditing



Le 19/02/2023 à 21:59, Joseph Burkhart via QGIS-Developer a écrit :

Hello,

I'm working on a python plugin that provides a new map tool for 
drawing polygons and I'm hoping someone could give me some pointers. 
I'm very familiar with the pyqgis API when it comes to processing, 
less so (but learning) when it comes to gui.


I have created a new polygon drawing tool that behaves like the 
default one. What I want to do now is modify the drawing widget so 
that it behaves more like a brush tool, so the user can activate the 
tool, click on the map canvas and drag to leave a brush stroke, and 
when they release the mouse button the brush stroke is turned into a 
polygon.


My impression is that I need to create a subclass of QgsRubberBand and 
then re-implement that class's draw method, but honestly I can't 
figure out where to start with that reimplementation. I've read 
through the pyqt docs for QPainter, and through the pyqgis docs and 
source code for QgsRubberBand (links below); I still couldn't figure 
out what to do next.


Anyone have any recommendations?

Thanks very much,

Joseph Burkhart



QgsRubberBand:
https://qgis.org/pyqgis/3.28/gui/QgsRubberBand.html
https://github.com/qgis/QGIS/blob/master/src/gui/qgsrubberband.h 
 
https://github.com/qgis/QGIS/blob/master/src/gui/qgsgeometryrubberband.cpp


QPainter:
https://doc.qt.io/qtforpython-5/PySide2/QtGui/QPainter.html


___
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] Autocomplete python code in QGIS compiled

2023-01-11 Thread Jacky Volpes via QGIS-Developer

Exactly the same here!

On Ubuntu 22.04

Regards,

--
Jacky Volpes

Ingénieur SIG - Oslandia



Le 09/01/2023 à 17:12, matteo via QGIS-Developer a écrit :

Hi all,

maybe that's a silly question, but with all the self compiled QGIS 
versions that I have (3.22, 3.28, master, ecc) QGIS is not 
autocompleting the code, not in the console, editor, Processing 
script, macros, etc etc.


With the QGIS 3.22, but again the version seems not be the problem, 
installed from packages, the autocompletion works as expected.


Is there a parameter in the cmake that I have to adjust or is this 
behavior expected?


p.s. working on a Debian Sid OS

Cheers and thanks!

Matteo
___
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] segmentation fault in standalone script using PyQGIS

2022-11-02 Thread Jacky Volpes via QGIS-Developer

Hi,

See answers below.

Best regards.
Jacky


Le 31/10/2022 à 17:26, Mélanie Dol via QGIS-Developer a écrit :

Hi Jacky,

Thank you so much, the segmentation fault has disappeared.

However, my styles don't work. I guess my script can't access to my 
symbols pre-configured. Is there a path to add or anything else ?


You have to specify the QGIS profile directory path in which the symbols 
are saved.

For example :
qgs = QgsApplication([], False, 
'/home/jacky/.local/share/QGIS/QGIS3/profiles/default')




Another question, how to force a label placement mode to "horizontal" ?


the line "layer_settings.LabelPlacement = 4" should be changed to 
"layer_settings.placement = 4"
you can also use the enum : "layer_settings.LabelPlacement = 
QgsPalLayerSettings.Placement.Horizontal"





Many thanks and regards,

Mélanie

On 10/31/22 12:14 PM, Jacky Volpes via QGIS-Developer wrote:

Hi Mélanie,

Thanks for the script, I was able to reproduce the segmentation fault 
with a dummy gpkg I made.


After some investigations, it seems that the symbol named 
"style_layer" used in

    1. the addSymbol() method for the first layer
    2. & 3. the QgsRendererCategory() constructor for the second and 
third layer

is None (nullptr -> hence  the segfault).

If I add the following

    if style_layer is None:
        style_layer = 
QgsSymbol.defaultSymbol(Layer_Pressure_Center.geometryType())


just before using style_layer as a safe check (for each layer of 
course) everything works fine.
Maybe it's simply because I don't have these symbols pre-configured, 
but it's worth the check on your side.


Also, I encapsulated the code like this, which prevents another  
segfault to occur due to local/global scope stuff I think:


---

all imports

def main():
    the main code

if__name__ == '__main__':
    set prefix path
    create qgs application
    append plugins path to sys.path and import processing stuff
    main()
    qgs.exitQgis()

---


Regards,
Jacky



Le 28/10/2022 à 17:10, Mélanie Dol via QGIS-Developer a écrit :

Hi Jacky,

Yes of course. Please find attached my script.

Regards,

Mélanie

On 10/28/22 4:55 PM, Jacky Volpes via QGIS-Developer wrote:

Hi Mélanie,

Have you initialized your standalone script as shown in 
https://docs.qgis.org/3.22/en/docs/pyqgis_developer_cookbook/intro.html#using-pyqgis-in-standalone-scripts 
?


Best regards,
Jacky


Le 28/10/2022 à 16:40, Mélanie Dol via QGIS-Developer a écrit :

Hi Andrea,

Thank you. I've updated with QGIS 3.26 Buenos Aires. The warning 
message have disappeared. Unfortunately, the script still 
generates a segmentation fault.


Best regards,

Mélanie Dol

On 10/28/22 11:47 AM, Andrea Giudiceandrea via QGIS-Developer wrote:

Il 27/10/2022 16:34, Mélanie Dol via QGIS-Developer ha scritto:
/usr/share/qgis/python/plugins/processing/algs/grass7/Grass7Utils.py:191: 
SyntaxWarning: "is" with a literal. Did you mean "=="?

  if path is '':


Hi Mélanie,
while I don't know why that script generates a segmentation 
fault, It seems you are using QGIS 3.10 which is a three years 
old version. The QGIS repository for Ubuntu 20.04 currently 
offers the latest available QGIS LTR 3.22.12.


Best regards.

Andrea Giudiceandrea

___
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


--
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


--
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


--
Jacky Volpes

Ingénieur SIG - Oslandia
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List inf

Re: [QGIS-Developer] segmentation fault in standalone script using PyQGIS

2022-10-31 Thread Jacky Volpes via QGIS-Developer

Hi Mélanie,

Thanks for the script, I was able to reproduce the segmentation fault 
with a dummy gpkg I made.


After some investigations, it seems that the symbol named "style_layer" 
used in

    1. the addSymbol() method for the first layer
    2. & 3. the QgsRendererCategory() constructor for the second and 
third layer

is None (nullptr -> hence  the segfault).

If I add the following

    if style_layer is None:
        style_layer = 
QgsSymbol.defaultSymbol(Layer_Pressure_Center.geometryType())


just before using style_layer as a safe check (for each layer of course) 
everything works fine.
Maybe it's simply because I don't have these symbols pre-configured, but 
it's worth the check on your side.


Also, I encapsulated the code like this, which prevents another segfault 
to occur due to local/global scope stuff I think:


---

all imports

def main():
    the main code

if__name__ == '__main__':
    set prefix path
    create qgs application
    append plugins path to sys.path and import processing stuff
    main()
    qgs.exitQgis()

---


Regards,
Jacky



Le 28/10/2022 à 17:10, Mélanie Dol via QGIS-Developer a écrit :

Hi Jacky,

Yes of course. Please find attached my script.

Regards,

Mélanie

On 10/28/22 4:55 PM, Jacky Volpes via QGIS-Developer wrote:

Hi Mélanie,

Have you initialized your standalone script as shown in 
https://docs.qgis.org/3.22/en/docs/pyqgis_developer_cookbook/intro.html#using-pyqgis-in-standalone-scripts 
?


Best regards,
Jacky


Le 28/10/2022 à 16:40, Mélanie Dol via QGIS-Developer a écrit :

Hi Andrea,

Thank you. I've updated with QGIS 3.26 Buenos Aires. The warning 
message have disappeared. Unfortunately, the script still generates 
a segmentation fault.


Best regards,

Mélanie Dol

On 10/28/22 11:47 AM, Andrea Giudiceandrea via QGIS-Developer wrote:

Il 27/10/2022 16:34, Mélanie Dol via QGIS-Developer ha scritto:
/usr/share/qgis/python/plugins/processing/algs/grass7/Grass7Utils.py:191: 
SyntaxWarning: "is" with a literal. Did you mean "=="?

  if path is '':


Hi Mélanie,
while I don't know why that script generates a segmentation fault, 
It seems you are using QGIS 3.10 which is a three years old 
version. The QGIS repository for Ubuntu 20.04 currently offers the 
latest available QGIS LTR 3.22.12.


Best regards.

Andrea Giudiceandrea

___
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


--
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


--
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


Re: [QGIS-Developer] segmentation fault in standalone script using PyQGIS

2022-10-28 Thread Jacky Volpes via QGIS-Developer

Hi Mélanie,

Have you initialized your standalone script as shown in 
https://docs.qgis.org/3.22/en/docs/pyqgis_developer_cookbook/intro.html#using-pyqgis-in-standalone-scripts 
?


Best regards,
Jacky


Le 28/10/2022 à 16:40, Mélanie Dol via QGIS-Developer a écrit :

Hi Andrea,

Thank you. I've updated with QGIS 3.26 Buenos Aires. The warning 
message have disappeared. Unfortunately, the script still generates a 
segmentation fault.


Best regards,

Mélanie Dol

On 10/28/22 11:47 AM, Andrea Giudiceandrea via QGIS-Developer wrote:

Il 27/10/2022 16:34, Mélanie Dol via QGIS-Developer ha scritto:
/usr/share/qgis/python/plugins/processing/algs/grass7/Grass7Utils.py:191: 
SyntaxWarning: "is" with a literal. Did you mean "=="?

  if path is '':


Hi Mélanie,
while I don't know why that script generates a segmentation fault, It 
seems you are using QGIS 3.10 which is a three years old version. The 
QGIS repository for Ubuntu 20.04 currently offers the latest 
available QGIS LTR 3.22.12.


Best regards.

Andrea Giudiceandrea

___
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


--
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


Re: [QGIS-Developer] Inserting provider filter just before PostGIS layer is loaded?

2022-08-22 Thread Jacky Volpes via QGIS-Developer

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


Re: [QGIS-Developer] Feature count for DB provider.

2022-06-28 Thread Jacky Volpes via QGIS-Developer

Hello Rémi,

The function you refer to
https://github.com/qgis/QGIS/blob/master/src/core/vector/qgsvectorlayerfeaturecounter.cpp#L76-L90
is only called when the feature count must be done for the symbols (for 
instance when a categorized symbology is used, then QGIS does not use 
estimated metadata, and the count for each symbol is then evaluated and 
displayed).


Normally there is no SELECT count(*) FROM or SELECT * FROM when 
estimated metadata is used.


Regards,

--
Jacky Volpes

Ingénieur SIG - Oslandia


Le 26/06/2022 à 20:20, Rémi Desgrange via QGIS-Developer a écrit :


Thanks Regis.

I tried with an existing project, and with no project. The information 
of the layers is:


service='mycomp_prod' sslmode=require key='gid' estimatedmetadata=true 
srid=27572 type=Point checkPrimaryKeyUnicity='1' table="public"."mylayer"


with service in `.pg_service.conf` :

[mycomp_prod]

user=rd

sslmode=require

host=gis.mycomp.fr

port=5432

dbname=mycomp

(don’t blame me for the 27572 OK )

I think I’ll open an issue because it _/seems/_ to do a SELECT 
count(*) FROM mylayer + SELECT * FROM mylayer until all features have 
been fetched. In my example, I have a 11M Points layer so it takes a 
while .


*From: *Régis Haubourg 
*Date: *Saturday, 25 June 2022 at 12:54
*To: *Rémi Desgrange 
*Cc: *QGIS Developers List 
*Subject: *Re: [QGIS-Developer] Feature count for DB provider.

Hi Rémy, There had been a lot of work for postGIS and oracle 
providers. A count(*) might be really expensive for big tables, so 
there are options to use db statistics instead of real count. I bet 
the loop you point out occurs only in fallback situations but is not 
the main case.


One is here for instance by there are numerous PRs like this one 
https://github.com/qgis/QGIS/pull/37619


In think @troopa81 has a clear view of the current state.

all the best

Régis

Le sam. 25 juin 2022 à 10:38, Rémi Desgrange via QGIS-Developer 
 a écrit :


Hi,

Just launched the new QGIS 3.24, and tests the SQL debugger, I
just found out that the “feature count” does a while loop on all
features in the layer to count.

While it’s probably necessary for shapefiles or stuff like that,
it appears suboptimal for databases access. I found this part in
the code that looks like to be responsible for the feature counts,

https://github.com/qgis/QGIS/blob/master/src/core/vector/qgsvectorlayerfeaturecounter.cpp#L76-L90


Do you think I could make a special case for database-based
provider (geopackage, postgres/oracle/mysql/etc…) that launch a
“SELECT count(*) FROM table” instead of looping on all features.

Thanks.

___
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
___
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