zoran-cuckovic / QGIS-visibility-analysis

Quantum GIS plugin for visibility analysis
GNU General Public License v3.0
72 stars 17 forks source link

Problem running the algorithms from qgis_process #59

Closed JanCaha closed 2 years ago

JanCaha commented 2 years ago

Since QGIS 3.16 there is a possibility to run tools (algorithms) from command line using tool qgis_process without having to actually open QGIS. This allows running QGIS tools from other languages ie. R - package qgisprocess. The tools runned from qgis_process are handled somewhat differently (not exactly sure how, but there is a difference).

The way how the plugin is currently loaded (here) causes that qgis_process does not see the plugin at all and thus the tools are not available outside of QGIS. The problem is probably with setting the settings values and then only adding tools if the setting VISIBILITY_ANALYSIS_ACTIVATED is True (it is done here).

Maybe this could be handled differently? For example add the settings in main plugin init (instead of provider) and then checked if the setting exist and if does not, use some sensible default value? I would be happy to do prepare pull request to solve this issue.

zoran-cuckovic commented 2 years ago

Thank you Jan, It's true that the ACTIVATED setting is not really needed - we can des/activate the plugin under Plugins menu. However, most of Processing plugins do include this option, which is accessed in Processing settings. If you have a solution for this, please do make a pull request, I'll integrate it to the main code.

JanCaha commented 2 years ago

After some testing it seems that settings are not the problem. The issues are just minor changes. The solution is in #60.

I noticed one other minor thing that could be improved. The name() function for algorithm should return the name in the form of identificator. The standard is to use lower case without space or underscore (you can see it in QGIS algorithms). This is the identificator QGIS uses, along with plugin name, to actually run the algorim. It might be convenient to change the names. The displayName() function can stay as they are, as this is used only in UI.

Currently the names are:

Intervisibility
Viewshed
create_viewpoints
visibility_index

So maybe it could be change to:

intervisibility
viewshed
createviewpoints
visibilityindex
zoran-cuckovic commented 2 years ago

Thanks, I've changed the names as you suggest.

JanCaha commented 2 years ago

Perfect. That should make the plugin much more user friendly, if it is used without the GUI.