[QGIS-Developer] Reading current measurement with python

Jacky Volpes jacky.volpes at oslandia.com
Wed Oct 25 03:11:28 PDT 2023


Hi,

If I understand well, it's possible that a styled layer could be 
sufficient...?
See "Description" section on this style 
<https://plugins.qgis.org/styles/5/>.
Import the style 
<https://docs.qgis.org/3.28/en/docs/user_manual/style_library/style_manager.html#importing-items> 
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<jacky.volpes at oslandia.com>  
> Gesendet: Freitag, 6. Oktober 2023 15:00
> An:qgis-developer at lists.osgeo.org
> Cc: Simon Gröchenig<groechenig at zt-gis.at>
> 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<jacky.volpes at oslandia.com>
>> To:qgis-developer at lists.osgeo.org
>> Subject: Re: [QGIS-Developer] Reading current measurement with python
>> Message-ID:<352a9e94-9010-4f39-8738-89323a87a15a at 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 at 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:<http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231002/ce6f1c41/attachment-0001.htm>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20231025/12bcd798/attachment.htm>


More information about the QGIS-Developer mailing list