-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean code and add more expression functions #8
Conversation
Great. Thanks Simran! |
@NathanW2: If you have any questions in order to accept this pull request, don't hesitate to ask @simran001 or me. |
Looks fine. Thanks. |
Thanks! That will be useful for my former workshop about QGIS Expressions https://giswiki.hsr.ch/Workshop_QGIS_Python_GeoPython_2017 |
Sorry, me again: I'm confused regarding the current version in this repo (0.1) and the one published at official QGIS plugin page (0.4) http://plugins.qgis.org/plugins/qgsexpressionsplus/ . The metadata.txt in this repo https://github.com/NathanW2/qgsexpressionsplus/blob/master/metadata.txt indicates "version=0.1". But the available version in official QGIS plugin page is 0.4 (so the forthcoming release of this new plugin version will be 0.5...)? |
Nice, good job @simran001 . One question concerning, the set/get_env_variable methods: do they work on environment variables (as the name indicates) or on qgis variables (what I think it actually does looking at the code). What is the use case for the |
@m-kuhn : You're correct, the code is about QGIS variables. I understood, that these include the variables from QProcessEnvironment, since it contains e.g. user_full_name from "global QGIS context". => Isn't this correct? Do you suggest to rename set/get_env_variable methods to set/get_qgis_env_variable? The method set_env_variable was introduced to enable global/shared info between more than one methods. It's also there just for completeness. Of course it should be used with care. Looking at the code of get_env_variable(var_name) I now also realize, that it probably should be modified to get_env_variable(var_name, scope) in order to deal the situation where there exist variables with same name in more than one scope? |
QGIS variables can easily be retrieved with If anything, then a Concerning the |
Agreed. So I'd suggest following:
BTW: Update also https://gis.stackexchange.com/questions/236638/get-value-of-variable-in-custom-python-expression-function |
Sounds good The name in QGIS 3 is Update on gis.se sounds good, simran, could you take care of that (probably add a new answer which highlights the diff between env var and qgis var and explains how qgis variables can be accessed)? |
@sfkeller @simran001 do you want me to make a new package for this now or wait until you have done the refactor? |
Thanks for your offering! I'd suggest you wait until we've done the refactoring. |
No worries. Ping me when you are good to go.
…On Wed, Jul 5, 2017 at 8:07 AM, Stefan ***@***.***> wrote:
Thanks for your offering! I'd suggest you wait until we've done the
refactoring.
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#8 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAXS3GhJ6mDCM14zd2w82yjv35ylC0Klks5sKre8gaJpZM4NdKa0>
.
|
Hi Prof Keller and Matthias, Thanks for all the info! Just to add on, regarding the get/set_env_variable functions:
As included in the function documentation here, a user might want to import the qgis_variables.py script and use these functions from the Python console or elsewhere.
True, get/set_qgis_variable() would be a better name for the functions. Also since they are not expression functions, they probably do not belong here. Yes, will update the answer on gis.se, and see if I can retrieve variables from outside QGIS. |
Please allow me to chime in, I've had a look at this today. My 20¢:
|
Just found a built-in function! Please try out For example, Also, Prof Stefan, you had once mentioned that you would like to retrieve the path of the QGIS expressions directory. The following would do it I tried the above on QGIS version 2.18.7. |
@simran001 does this mean from your perspective, all the code from the two functions is not neccessary anymore? If so, should it be removed? What I'm trying to say: remove the code and the reference in the Readme to |
@hixi yes. I have removed the two functions and created a new pull request. |
@NathanW2 I'm coming back to your question above where you asked to release the plugin immediately before env() expression function becomes part of it. Now I'm not sure when we can care about this env() and another pull request. IMHO the current code and documentation seam pretty clean so far. So I propose that you release this nice extension now to the QGIS plugins web portal. I'm looking forward e.g. that it will be used in the workshop by Andreas at the forthcoming QGIS User Conf. in Nødebo. |
Hey,
No worries. will get it done today. Sorry just been busy on other things.
…On Fri, Jul 21, 2017 at 2:38 AM, Stefan ***@***.***> wrote:
@NathanW2 <https://github.com/nathanw2> I'm coming back to your question
above where you asked to release the plugin immediately before env()
expression function becomes part of it. Now I'm not sure when we can care
about this env() and another pull request. IMHO the current code and
documentation seam pretty clean so far. So I propose that you release this
nice extension now to the QGIS plugins web portal. I'm looking forward e.g.
that it will be used in the workshop by Andreas at the forthcoming QGIS
User Conf. in Nødebo.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAXS3Gce54BDxaOCBnLKvdYlFGB12Eq-ks5sP4KjgaJpZM4NdKa0>
.
|
Hi @NathanW2
Thanks for accepting my contributions to the qgsexpressionsplus plugin.
I have made a few changes, cleaned up the code, and added a few more custom expression functions. My supervisor, Prof Stefan Keller, suggested some more ideas for expression functions that will be nice to have in QGIS, which are included here as well.
Here is the final list:
I have added a description for the functions above in the Readme.
The hstore functions are useful when we are working with Openstreetmap data in QGIS, and the attribute table has a tags column like the one in the screenshot [1] attached. We can select features by expression using these hstore functions as
hstore_contains_key_value("tags", 'amenity=>restaurant')
which would select all the restaurants on the layer.The jitter_geometry() function produces an output like [2]. I found your blog post on Generating chainage nodes in QGIS really helpful when implementing this.
If you have the time, it would be great if you could review my code, in case I could have better implemented any of these functions.
Thank you!
[1]
![attribute-table](https://cloud.githubusercontent.com/assets/15504304/26130987/a571d09e-3a97-11e7-9908-df0382a13530.PNG)
[2]
![jitter](https://cloud.githubusercontent.com/assets/15504304/26131073/0ea9cb0c-3a98-11e7-82e8-238cb311a0ce.PNG)