ubarsc / rios

A raster processing layer on top of GDAL
https://www.rioshome.org
GNU General Public License v3.0
15 stars 8 forks source link

rios.applier.apply does not pass information about the output files to the userFunction #22

Closed gillins closed 5 years ago

gillins commented 5 years ago

Original report by Johan Mollevik (Bitbucket: [Johan Mollevik](https://bitbucket.org/Johan Mollevik), ).


It would occationally be usefull to know which and how many output files are supplied to rios.applier.apply

To be usefull this should probably work both with multiple output fies in different variables and multiple ones in a list in the same output variables.

I see two ways this could easily be implemented, either by pre populating the output object passed to the callback or by adding the information to the info object.

Is this something you think would make sense adding to rios?

gillins commented 5 years ago

Original comment by Neil Flood (Bitbucket: neilflood, GitHub: neilflood).


Hi Johan,

there is a much easier way to manage this sort of thing. If the user function needs to do different things in some cases, and some of these cases have different numbers of output files on the outputs object, then you should use the otherargs object to pass in enough information for the user function to be able to make the right decisions. In most cases this just means that there are two different cases, and I pass a boolean flag on the otherargs object, and that is sufficient to make decisions in the user function. More complicated cases could arise, but it will always be true that the calling function already knows this, and so can off the right information on the otherargs object.

We have been using RIOS for many years now, in research and operationally, and we have never really needed anything more complicated than that.

Does that seem like it answers your needs?

Neil

gillins commented 5 years ago

Original comment by Johan Mollevik (Bitbucket: [Johan Mollevik](https://bitbucket.org/Johan Mollevik), ).


This is what I ended up doing, however I think the code looked less nice by doing this so I would have preffered another way. However this is not blocking me.

gillins commented 5 years ago

Original comment by Sam Gillingham (Bitbucket: gillins, GitHub: gillins).


Johan, Can you give us an example of code that could be improved by doing this? Sam.