Re: [QGIS-Developer] Custom python expression question

2017-05-05 Thread Marco Grisolia
Hi Andreas, I don't know if it is the best way for doing it, but I generally add the current feature and the current layer as input parameters of the custom function: def my_function(layer_name, curr_feat, feature, parent): They are set as inputs in this way when calling the custom function:

Re: [QGIS-Developer] Custom python expression question

2017-05-05 Thread Nathan Woodrow
Hey Andreas, Parent means the parent expression itself. So in a function, you can know what the whole expression is e.g it points to the instance of. You can't really know what the layer because expressions are not always layer bound and QgsFeatures don't hold a reference to the layer they are

Re: [QGIS-Developer] Custom python expression question

2017-05-05 Thread Matthias Kuhn 
Actually, there would also be the "context" which gives access to the @layer variable (a QgsVectorLayer object) and other additional things. It's just slightly more complex to set up because it's not proxied to the @qgsfunction. One will need to subclass QgsExpression.Function as done here:

Re: [QGIS-Developer] Custom python expression question

2017-05-05 Thread Nyall Dawson
On 5 May 2017 at 22:08, Matthias Kuhn  wrote: > > I think we should also send this to the @qgsfunction in QGIS 3. > Agreed. Shall I assign a ticket to you or will you file a PR for this? Nyall ___ QGIS-Developer mailing list

[QGIS-Developer] Custom python expression question

2017-05-05 Thread Neumann, Andreas
Hi, If one creates a custom python expression, one gets a reference to the "feature" and the "parent". Question: what is "parent" referring to? What object type is it? Is it somehow possible in the Python script to get a reference to the layer the feature is part of? Would there be some

Re: [QGIS-Developer] Python example with aggregate calculation

2017-05-05 Thread Neumann, Andreas
Hi, Finally, with the support from Matthias, I got a working example of my custom Python expression: @qgsfunction(args='auto', group='Custom', usesgeometry=False) def get_ews_anlage_nr(gemeinde, feature, parent): AnlageLayer = QgsMapLayerRegistry.instance().mapLayersByName('Anlage')[0]

Re: [QGIS-Developer] Custom python expression question

2017-05-05 Thread Matthias Kuhn 
I hope you don't mind very verbose docs ;) https://github.com/qgis/QGIS/blob/fd25288a6444c1fd6fb965a408550992d7d1f84b/python/user.py#L69-L94 On 05/05/2017 02:35 PM, Nathan Woodrow wrote: > Yes please :) > > On Fri, May 5, 2017 at 10:29 PM, Matthias Kuhn 

Re: [QGIS-Developer] Python example with aggregate calculation

2017-05-05 Thread Neumann, Andreas
Hi, I have a basic example using aggregates: -- @qgsfunction(args='auto', group='Custom', usesgeometry=False) def get_ews_anlage_nr(gemeinde, feature, parent): AnlageLayer = QgsMapLayerRegistry.instance().mapLayersByName('Anlage')[0] maxVal =

[QGIS-Developer] Fwd: OSGeo welcomes 15 GSoC students!

2017-05-05 Thread Werner Macho
QGIS has got a new GSoC project. Congratulations -- Forwarded message -- From: Margherita Di Leo Date: Fri, May 5, 2017 at 10:19 AM Subject: OSGeo welcomes 15 GSoC students! To: news_i...@osgeo.org Cc: "gsoc-adminosgeo.org"

[QGIS-Developer] Python example with aggregate calculation

2017-05-05 Thread Neumann, Andreas
Hi, Does someone have an example how to use QgsVectorLayer.aggregate() from Python? How would the syntax for the parameters in the QgsAggregateCalculator.calculate() method look like in Python? Thanks, Andreas___ QGIS-Developer mailing list

Re: [QGIS-Developer] Custom python expression question

2017-05-05 Thread Matthias Kuhn 
On 05/05/2017 02:22 PM, Nyall Dawson wrote: > On 5 May 2017 at 22:08, Matthias Kuhn  wrote: >> >> I think we should also send this to the @qgsfunction in QGIS 3. >> > > Agreed. Shall I assign a ticket to you or will you file a PR for this? > > Nyall > Is backwards

[QGIS-Developer] Problem reading project file

2017-05-05 Thread Jörg Höttges
Hi, in a QGIS-plugin I need to read a template project file (*.qgs), modify it to adapt it to the currently loaded database etc. using xml.etree.ElementTree, write it and read it again. qgsxml.write(projectfile) # writemodified project file project =

Re: [QGIS-Developer] [Qgis-user] Qgis keeps crashing

2017-05-05 Thread Richard Duivenvoorde
Hi All, please create an issue about this crashing: https://issues.qgis.org/projects/qgis/issues/ note that devs need as much as info possible (Operating System, versions used, plugins used, and actual things to do to reproduce the crash, see

Re: [QGIS-Developer] [Qgis-user] Qgis keeps crashing

2017-05-05 Thread C Hamilton
I am adding this to the developers mailing list as it is something to pay attention to. It looks like there are a number of individuals that are having QGIS crash. On Fri, May 5, 2017 at 12:45 PM, Armin Konrad wrote: > I have the same problem and it is really annoying. The

[QGIS-Developer] Plugin [1220] RS approval notification.

2017-05-05 Thread noreply
Plugin RS approval by pcav. The plugin version "[1220] RS 0.2" is now approved Link: http://plugins.qgis.org/plugins/NITK_RS-GIS_17/ ___ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: