Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-26 Thread matteo
ok I create a first Pull Request here:

https://github.com/qgis/QGIS/pull/6678

a first draft of the implementation of this idea.

more feedback are more than welcome

Cheers

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-26 Thread matteo
ok I created a first Pull Request here:

https://github.com/qgis/QGIS/pull/6678

a first draft of the implementation of this idea.

more feedback are more than welcome

Cheers

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-26 Thread matteo
Hi all,

Besides a custom python template, it would be also cool to have a small
set of functions.. in 2.18 there was a button in the UI with the chance
to load some functions.

What about resurrecting it?

I found this old topic started from Victor:

https://lists.osgeo.org/pipermail/qgis-developer/2015-November/040140.html

I don't know if this could be of interest (and actually where is the
correct place to put this functions being aware that this "box" could be
filled in a second moment)

Cheers

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-25 Thread Nyall Dawson
On 26 March 2018 at 07:24, Erno Mäkinen  wrote:
> Hi Matteo,
>
> You may want to take a look to this blog post by Anita Graser:
> https://anitagraser.com/2018/03/25/processing-script-template-for-qgis3/.
> There is also her related twitter post:
> https://twitter.com/underdarkGIS/status/977834578638405637. Based on the
> comments there seems to be interest for such template to appear when one
> clicks the "Create new script".

Big +1

Nyall

>
> BR,
> Erno
>
>
> On 25 March 2018 at 18:25, matteo  wrote:
>>
>> Hi all,
>>
>> after this issue I had, I was thinking.. Why not implementing a kind of
>> template for scripts? Clicking on "create new script" the editor could
>> be filled with a template of functions (like @erno pointed out the
>> template of the Plugin Builder).
>>
>> I can have a look at it, but I just want to hear some feedback on this
>> (if any is interested).
>>
>> Thanks
>>
>> Matteo
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
>
> --
> Erno Mäkinen
> Gispo Oy
> e...@gispo.fi - GSM +358 50 505 7003
> www.gispo.fi - www.facebook.com/GispoFinland/
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-25 Thread Erno Mäkinen
Hi Matteo,

You may want to take a look to this blog post by Anita Graser:
https://anitagraser.com/2018/03/25/processing-script-template-for-qgis3/.
There is also her related twitter post:
https://twitter.com/underdarkGIS/status/977834578638405637. Based on the
comments there seems to be interest for such template to appear when one
clicks the "Create new script".

BR,
Erno


On 25 March 2018 at 18:25, matteo  wrote:

> Hi all,
>
> after this issue I had, I was thinking.. Why not implementing a kind of
> template for scripts? Clicking on "create new script" the editor could
> be filled with a template of functions (like @erno pointed out the
> template of the Plugin Builder).
>
> I can have a look at it, but I just want to hear some feedback on this
> (if any is interested).
>
> Thanks
>
> Matteo
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Erno Mäkinen
Gispo Oy
e...@gispo.fi - GSM +358 50 505 7003
www.gispo.fi - www.facebook.com/GispoFinland/
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-25 Thread matteo
Hi all,

after this issue I had, I was thinking.. Why not implementing a kind of
template for scripts? Clicking on "create new script" the editor could
be filled with a template of functions (like @erno pointed out the
template of the Plugin Builder).

I can have a look at it, but I just want to hear some feedback on this
(if any is interested).

Thanks

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-25 Thread matteo
Hi Erno,

thank for the input, with this template it is working. I don't know what
I was missing.

Thanks to all for the help

Cheers

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-25 Thread erno
Hi Matteo,
So, here is an example processing script that works in QGIS 3.0.0. I took
it, including the comments, from the result that  Plugin Builder
   by  GeoApt LLC
   creates for processing:
# -*- coding: utf-8 -*-from PyQt5.QtCore import QCoreApplicationfrom
qgis.core import (QgsProcessing,   QgsFeatureSink,  

QgsProcessingAlgorithm,  
QgsProcessingParameterFeatureSource,  
QgsProcessingParameterFeatureSink)class
ExampleProcessingAlgorithm(QgsProcessingAlgorithm):"""This is an
example algorithm that takes a vector layer andcreates a new identical
one.It is meant to be used as an example of how to create your own   
algorithms and explain methods and variables used to do it. Analgorithm
like this will be available in all elements, and thereis not need for
additional work.All Processing algorithms should extend the
QgsProcessingAlgorithmclass."""# Constants used to refer to
parameters and outputs. They will be# used when calling the algorithm
from another algorithm, or when# calling from the QGIS console.   
OUTPUT = 'OUTPUT'INPUT = 'INPUT'def initAlgorithm(self,
config=None):"""Here we define the inputs and output of the
algorithm, alongwith some other properties."""# We
add the input vector features source. It can have any kind of#
geometry.self.addParameter(   
QgsProcessingParameterFeatureSource(self.INPUT,   
self.tr('Input layer'),[QgsProcessing.TypeVectorAnyGeometry]
   
))# We add a feature sink in which to store our processed
features (this# usually takes the form of a newly created vector
layer when the# algorithm is run in QGIS).self.addParameter(
   
QgsProcessingParameterFeatureSink(self.OUTPUT,   
self.tr('Output layer')))def processAlgorithm(self,
parameters, context, feedback):"""Here is where the
processing itself takes place."""# Retrieve the feature
source and sink. The 'dest_id' variable is used# to uniquely
identify the feature sink, and must be included in the# dictionary
returned by the processAlgorithm function.source =
self.parameterAsSource(parameters, self.INPUT, context)(sink,
dest_id) = self.parameterAsSink(parameters, self.OUTPUT,context,
source.fields(), source.wkbType(), source.sourceCrs())# Compute the
number of steps to display within the progress bar and# get features
from sourcetotal = 100.0 / source.featureCount() if
source.featureCount() else 0features = source.getFeatures()   
for current, feature in enumerate(features):# Stop the algorithm
if cancel button has been clickedif feedback.isCanceled():  
 
break# Add a feature in the sink   
sink.addFeature(feature, QgsFeatureSink.FastInsert)# Update the
progress barfeedback.setProgress(int(current * total))#
Return the results of the algorithm. In this case our only result is   
# the feature sink which contains the processed features, but some#
algorithms may return multiple feature sinks, calculated numeric#
statistics, etc. These should all be included in the returned#
dictionary, with keys matching the feature corresponding parameter#
or output names.return {self.OUTPUT: dest_id}def name(self):   
"""Returns the algorithm name, used for identifying the algorithm.
Thisstring should be fixed for the algorithm, and must not be
localised.The name should be unique within each provider. Names
should containlowercase alphanumeric characters only and no spaces
or otherformatting characters."""return
'duplicatevectorlayer'def displayName(self):"""Returns
the translated algorithm name, which should be used for any   
user-visible display of the algorithm name."""return
self.tr('Duplicate a vector layer')def group(self):"""   
Returns the name of the group this algorithm belongs to. This string   
should be localised."""return self.tr('Example scripts')   
def groupId(self):"""Returns the unique ID of the group this
algorithm belongs to. Thisstring should be fixed for the algorithm,
and must not be localised.The group id should be unique within each
provider. Group id shouldcontain lowercase alphanumeric characters
only and no spaces or otherformatting characters."""   
return 'examplescripts'def tr(self, string):return
QCoreApplication.translate('Processing', string)def

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-24 Thread matteo
Hi Nyall,


> Does it help if you inherit from QgsProcessingAlgorithm instead?
> There's no need to inherit from QgisAlgorithm here, you should use the
> base class directly.

nope.. I already changed that so that now the class inherits from
QgsProcessingAlgorithm.

I also noticed that I have to put:

def createInstance(self):
  return type(self)()

else the algorithm will crash..


Thanks

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-24 Thread erno
Hi Matteo,

I encountered the same problem when starting processing script creation from
scratch for QGIS 3.0.0. However, the  Plugin Builder
   by  GeoApt LLC
   can create a processing plugin template. It includes
also class that can be used directly as a processing script. I tried it in
the QGIS 3.0.0 and it worked.

Hope it helps,
Erno





--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-23 Thread Nyall Dawson
On 23 March 2018 at 17:39, matteo  wrote:
> Hi all,
>
> I really don't know if I'm missing something basic, but even with this
> super short script (that does not run anything):
>
>
> from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
>
>
> class myScript(QgisAlgorithm):

Does it help if you inherit from QgsProcessingAlgorithm instead?
There's no need to inherit from QgisAlgorithm here, you should use the
base class directly.

Nyall

>
> INPUT = 'INPUT'
> OUTPUT = 'OUTPUT'
>
>
> def group(self):
> return 'My group'
>
> def name(self):
> return 'my algorithm'
>
>
> from the editor I can run it (and the dialog pops up normally, even
> without parameters), I can save it, but when I close it than the same
> error appears:
>
> NotImplementedError: QgsProcessingAlgorithm.name() is abstract and must
> be overridden
>
>
> Cheers and thanks for any hint
>
> Matteo
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-23 Thread matteo
Hi all,

I really don't know if I'm missing something basic, but even with this
super short script (that does not run anything):


from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


class myScript(QgisAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'


def group(self):
return 'My group'

def name(self):
return 'my algorithm'


from the editor I can run it (and the dialog pops up normally, even
without parameters), I can save it, but when I close it than the same
error appears:

NotImplementedError: QgsProcessingAlgorithm.name() is abstract and must
be overridden


Cheers and thanks for any hint

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-22 Thread matteo
Hi Tom,

yep I have both:


def name(self):
return 'myscatters'

def displayName(self):
return self.tr('My scatter Plots')


actually when restarting QGIS I have bot errors (for name and
displayname) and now the scripts are in Processing in the scripts
provider but I have a blank group name and a blank algorithm name..

Thanks

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-22 Thread Tom Chadwin
Have you implemented a name() method for your algorithm? The API has changed
a fair deal in 3.

Tom



-
Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon 
--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Error when saving Processing Script QGIS master

2018-03-22 Thread matteo
Hi guys,

I'm testing the the Processing script editor with custom python syntax.
It works super nice, but, after the scripts is saved and I want to close
the window this error pops up:

NotImplementedError: QgsProcessingAlgorithm.name() is abstract and must
be overridden

the script is correctly saved in the folder but is not loaded in Processing.

Some hints?

Thanks to all

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer