-
Notifications
You must be signed in to change notification settings - Fork 20
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
Complete input argument type parsing #13
Comments
(edits by @florisvdh: references added to #13 (comment))
|
Some tips:
|
Thanks! |
We're having trouble specifying multilayer inputs (#25)...comma-separated filenames and multiple |
|
Some thoughts while preparing to tackle potential remaining opportunities here.
For now, I intend to focus on aspect 1, especially to look after interesting R object classes which we still don't handle or handle correctly. Handling aspect 2 more completely, especially for the acceptance part, would potentially require lots of 'class - qgis_type' combinations to handle in R, with future maintenance burden, while |
…ON objects ******* Will edit following tasks while proceeding. - [X] since QGIS 3.30.0, `qgis_type`s `distance`, `number` and `boolean` can also take a field or QGIS expression string (aka a data-defined override). Because in R this will be represented as a (specifically formatted) string, those cases are handled well already. Cf. the vignette on using QGIS expressions. - [X] `distance` usually expects numeric: current handling by `as_qgis_argument()` of numeric input is sufficient - [X] `multilayer` is sufficiently implemented for the vector case since multiple vector layers in R (even if belonging to same dsn) are always handled as separate R objects, which is also required for the multilayer input. Passing multiple layers is done either by repetition of the same multilayer argument (providing one layer each time) or by wrapping the layers in `qgis_list_input()`. - BTW it doesn't work well if passing single multi-layer files (as filepath), e.g. a vector GeoPackage or a multi-band raster; in both cases only the first layer will be used by `qgis_process`. This understanding of 'multilayer' appears to match more the QGIS meaning of a single 'layer', i.e. an entry in the 'layers' panel (such a layer can still be a multiband raster). - While filepath arguments are the user's responsibility, multiband raster objects could be taken care of automatically by splitting them before feeding to the multilayer argument, but that would essentially not match the QGIS GUI behaviour. Such cases will raise a warning (08abc26) and solution is left to the user, in order not to override QGIS behaviour. - [X] `range`: QGIS expects `"min,max"` format. This can be provided directly as a string in R. The no-JSON-input approach in the numeric method of `as_qgis_argument()` will also convert a `c(<min>, <max>)` vector to the expected string format already. While with the JSON input approach the vector is turned into a JSON array, the latter appears to also be correctly processed by `qgis_process`! So vectors are perfect. - [X] `expression` is always a string and this is supported well (see the vignette on using QGIS expressions) - [X] `aggregates` is only supported with JSON input, where it is represented as a nested object. Nested list objects prepared with the `qgis_list_input()` and `qgis_dict_input()` helpers can handle this well. - [ ] `matrix` - [ ] `fields_mapping` - [ ] `tininputlayers` - [ ] `vectortilewriterlayers` - [ ] `raster_calc_expression` - [ ] `relief_colors` - [ ] `color` + have a look at raster and stars objects as well, wrt the commits for terra (i.e.: warn with multiband objects that go to multilayer; add care in passing multiband sources) PR text (reviewer Dewey!) Hardening argument handling, with attention to some special qgis_types This will fix #13! - the remaining task list of #13 (special qgis_types) is further discussed in XXXcommentin13, where the related additions of this PR are described - the return value of `qgis_extract_output()` can now be directly used as an algorithm argument since methods were added for various qgis_output* classes (ed85db6). - terra objects that refer multiband source files but with non-matching layer selection or order are specifically addressed by as_qgis_argument() (86de86c). @Nowosad you may want to have a look since you contributed the original method.
Handled the following in branch
|
Basically, need to figure out which R objects can be interpreted as QGIS input types. I've done a bit of this (e.g., for sf, raster, numeric, character, and logical). It's always possible to pass a length-one character to represent these in a pinch, but it would be nice to enable more R-like objects where possible (e.g., sf::bbox, raster::extent, sf::st_crs()). A calculated table of argument types and the first 20 algorithms for each:
The text was updated successfully, but these errors were encountered: