mach0 / qchainage

Chainage Plugin for QGIS
GNU General Public License v3.0
19 stars 18 forks source link

Unable to change distance unit in QGIS 3.30 #28

Open SC651 opened 1 year ago

SC651 commented 1 year ago

I upgraded to the new QGIS 3.30. When I try to change "meters" to "feet" on the QChainage options screen, it presents this error:

An error has occurred while executing Python code:

TypeError: QgsDistanceArea.convertLengthMeasurement(): argument 2 has unexpected type 'int' Traceback (most recent call last): File "/Users/[username]/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/qchainage/qchainagedialog.py", line 119, in on_UnitsComboBox_currentIndexChanged calc = self.da.convertLengthMeasurement(1.0, self.currentUnits) TypeError: QgsDistanceArea.convertLengthMeasurement(): argument 2 has unexpected type 'int'

Python version: 3.9.5 (default, Sep 10 2021, 16:18:19) [Clang 12.0.5 (clang-1205.0.22.11)] QGIS version: 3.30.0-'s-Hertogenbosch 's-Hertogenbosch, f186b8efe0

--

If I proceed, it displays the same message a few more times. The results are incorrect since it seems to use the default meters unit even though feet is selected.

mach0 commented 1 year ago

hi and thanks for reporting. QGIS has changed a lot since this plugin was initially written. I think I am porting it to the processing toolbox anyway, but I am busy (since pre pandemic time) with finishing my house (which is currently much more important to me) - so it might not take another 3 years, but still some time to find time to port it .. please be patient or - create a pull request with your suggestions.

wayne19980 commented 1 month ago

from qgis.core import ( Qgis )

and change line 119 to calc = self.da.convertLengthMeasurement(1.0, Qgis.DistanceUnit(self.currentUnits))

should fix the problem