jorgealmerio / valuetool

QGis plugin to display in a table or plot the values from the visible raster layers at the current mouse position
5 stars 7 forks source link

Coordinate value is too large #28

Closed jjimenezshaw closed 7 months ago

jjimenezshaw commented 7 months ago

The Coordinate value at the bottom of the widget can be too large, and that re-scales the panel. I do not need such ridiculous precision for the coordinates, and the re-scale of the panel bothers a lot. In this example I have the panel on the right side of the window, and it becomes too big, reducing area for the image. I cannot make the widget/panel smaller! image

jorgealmerio commented 7 months ago

Done! Please, check the new version 3.0.18 when available and close this issue if it's ok!

jjimenezshaw commented 7 months ago

Thank you!

It throws an error if the mouse is out of the extent:

An error has occurred while executing Python code: 

ValueError: Unknown format code 'f' for object of type 'str' 
Traceback (most recent call last):
  File "/home/jshaw/.local/share/QGIS/QGIS3/profiles/default/python/plugins/valuetool/valuewidget.py", line 478, in printValue
    self.labelStatus.setText(self.tr('Coordinate:') + strFmt.format(position.x(), position.y(),bandvalue))
ValueError: Unknown format code 'f' for object of type 'str'

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] 
QGIS version: 3.36.0-Maidenhead Maidenhead, 09951dc0acf 

I tried this and apparently worked:

                if isinstance(bandvalue, (int, float)):
                    strFmt = '\''+numFormat+ ','+numFormat+','+ numFormat+'\''
                else:
                    strFmt = '\''+numFormat+ ','+numFormat+',{}\''

probably you need a better solution for the "isinstance".

jjimenezshaw commented 7 months ago

BTW, you have one trace left over (print(strFmt)) in line 362

Bavarello commented 7 months ago

After the latest update I have this error message

Si è verificato un errore durante l'esecuzione del codice Python:

ValueError: Unknown format code 'f' for object of type 'str' Traceback (most recent call last): File "C:\Users/Utente/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\valuetool\valuewidget.py", line 478, in printValue self.labelStatus.setText(self.tr('Coordinate:') + strFmt.format(position.x(), position.y(),bandvalue)) ValueError: Unknown format code 'f' for object of type 'str'

Versione Python: 3.9.18 (heads/master:5eba59e, Feb 1 2024, 20:02:10) [MSC v.1929 64 bit (AMD64)] Versione di QGIS: 3.36.0-Maidenhead Maidenhead, 09951dc0

Percorso Python: G:/OSGeo4W/apps/qgis/./python C:/Users/Utente/AppData/Roaming/QGIS/QGIS3\profiles\default/python C:/Users/Utente/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins G:/OSGeo4W/apps/qgis/./python/plugins G:\OSGeo4W\apps\Python39\Scripts G:\OSGeo4W\bin\python39.zip G:\OSGeo4W\apps\Python39\DLLs G:\OSGeo4W\apps\Python39\lib G:\OSGeo4W\bin G:\OSGeo4W\apps\Python39 G:\OSGeo4W\apps\Python39\lib\site-packages G:\OSGeo4W\apps\Python39\lib\site-packages\win32 G:\OSGeo4W\apps\Python39\lib\site-packages\win32\lib G:\OSGeo4W\apps\Python39\lib\site-packages\Pythonwin C:/Users/Utente/AppData/Roaming/QGIS/QGIS3\profiles\default/python

Immagine 2024-03-06 222116

balazsan commented 7 months ago

Thank you!

It throws an error if the mouse is out of the extent:

An error has occurred while executing Python code: 

ValueError: Unknown format code 'f' for object of type 'str' 
Traceback (most recent call last):
  File "/home/jshaw/.local/share/QGIS/QGIS3/profiles/default/python/plugins/valuetool/valuewidget.py", line 478, in printValue
    self.labelStatus.setText(self.tr('Coordinate:') + strFmt.format(position.x(), position.y(),bandvalue))
ValueError: Unknown format code 'f' for object of type 'str'

Python version: 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] 
QGIS version: 3.36.0-Maidenhead Maidenhead, 09951dc0acf 

I tried this and apparently worked:

                if isinstance(bandvalue, (int, float)):
                    strFmt = '\''+numFormat+ ','+numFormat+','+ numFormat+'\''
                else:
                    strFmt = '\''+numFormat+ ','+numFormat+',{}\''

probably you need a better solution for the "isinstance".

I had the same issue, your edit solved it, thanks!

jorgealmerio commented 7 months ago

Thanks to all! jjimenezshaw solved the bug. I already pushed version 3.0.19 to repository.

jjimenezshaw commented 7 months ago

Thanks @jorgealmerio I think it can be closed as completed.

jorgealmerio commented 7 months ago

Ok, thanks!