[QGIS-Developer] processing =output boolean workaround ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[QGIS-Developer] processing =output boolean workaround ?

Andreas Plesch-2
For use in models it is sometimes useful to generate a boolean output from a processing script. Since boolean is not available as output, what would be a good workaround ?
I am simply using string as output type:
output=str(False)
but then the receiving script has to work a bit on that input and it is awkward to type 'True' if the input script is used standalone.

Of course, the real question is why boolean is not offered as output type ? To me it would be useful.

Andreas
--
Andreas Plesch
39 Barbara Rd.
Waltham, MA 02453

_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: processing =output boolean workaround ?

Nyall Dawson
On 14 May 2017 at 22:09, Andreas Plesch <[hidden email]> wrote:

> For use in models it is sometimes useful to generate a boolean output from a
> processing script. Since boolean is not available as output, what would be a
> good workaround ?
> I am simply using string as output type:
> output=str(False)
> but then the receiving script has to work a bit on that input and it is
> awkward to type 'True' if the input script is used standalone.
>
> Of course, the real question is why boolean is not offered as output type ?
> To me it would be useful.

I suspect there's no reason apart from that no-one has had the need
until now and accordingly no-one has coded this feature.

A PR would be very welcome! (after the upcoming outputs->c++ work lands)

Nyall
_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: processing =output boolean workaround ?

Andreas Plesch-2
On May 18, 2017 7:37 PM, "Nyall Dawson" <[hidden email]> wrote:
On 14 May 2017 at 22:09, Andreas Plesch <[hidden email]> wrote:
> For use in models it is sometimes useful to generate a boolean output from a
> processing script. Since boolean is not available as output, what would be a
> good workaround ?
> I am simply using string as output type:
> output=str(False)
> but then the receiving script has to work a bit on that input and it is
> awkward to type 'True' if the input script is used standalone.
>
> Of course, the real question is why boolean is not offered as output type ?
> To me it would be useful.

I suspect there's no reason apart from that no-one has had the need
until now and accordingly no-one has coded this feature.

A PR would be very welcome! (after the upcoming outputs->c++ work lands)

In fact, I took a look at the Python code and found that it would be probably possible to implement following the code for the number type, in a few places in the processing code. I think the models provider may not need changes.

Since I am not very proficient in c++, it will probably more efficient for me to stick to somewhat awkward workarounds. But I will take a look.

(I would like to use Travis as much as possible. Is it possible to avoid building locally altogether ?)


_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: processing =output boolean workaround ?

Andreas Plesch-2
On May 18, 2017 7:37 PM, "Nyall Dawson" <[hidden email]> wrote:
On 14 May 2017 at 22:09, Andreas Plesch <[hidden email]> wrote:
> For use in models it is sometimes useful to generate a boolean output from a
> processing script. Since boolean is not available as output, what would be a
> good workaround ?
> I am simply using string as output type:
> output=str(False)
> but then the receiving script has to work a bit on that input and it is
> awkward to type 'True' if the input script is used standalone.
>
> Of course, the real question is why boolean is not offered as output type ?
> To me it would be useful.

I suspect there's no reason apart from that no-one has had the need
until now and accordingly no-one has coded this feature.

A PR would be very welcome! (after the upcoming outputs->c++ work lands)

In fact, I took a look at the Python code and found that it would be probably possible to implement following the code for the number type, in a few places in the processing code. I think the models provider may not need changes.

Since I am not very proficient in c++, it will probably more efficient for me to stick to somewhat awkward workarounds. But I will take a look.

(I would like to use Travis as much as possible. Is it possible to avoid building locally altogether ?)

Andreas

_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer