Issue with SetParameterString for ListView parameters
ListView parameters, the
SetParameterStringList selects from a vector of string the corresponding element in the ListView whose name can be found in the vector. However
SetParameterString does not have the same behavior, it selects the element in the listView whose key correspond to the input string. This leads to some weird behavior, as the key names are usually managed by the application and are usually unknown to the users.
import otbApplication as otb appStat = otb.Registry.CreateApplication("PolygonClassStatistics") img = "img.tif" db = "vec.sqlite" # vec.sqlite contains a field named my_id appStat.SetParameterValue("in",img) appStat.SetParameterString("out", "stats.xml") appStat.SetParameterValue("vec",db) # Here UpdateParameters is called by the wrapper and the list view is initialized. for the my_id field, an element is added to the listView, with the key myid (PolygonClassStatistics only keeps the alphanumeric characters) and with name my_id appStat.SetParameterString("field", "my_id") # error, my_id cannot be found in the list view keys appStat.SetParameterString("field", "myid") # OK, myid can be found in the list view keys appStat.SetParameterStringList("field", ["my_id"]) # OK, my_id can be found in the list view names appStat.ExecuteAndWriteOutput()
import otbApplication as otb app = otb.Registry.CreateApplication("RadiometricIndices") app.SetParameterStringList("list", ["Vegetation:NDVI"]) # OK, Vegetation:NDVI can be found in the list view names app.SetParameterString("list", "Vegetation:NDVI") # Error, Vegetation:NDVI can be found in the list view keys app.SetParameterString("list", "ndvi") # OK, ndvi can be found in the list view keys (but this is not documented)
this really depends on how the application manage the list view, but I think
SetParameterString should have the same behavior, and for most (all ?) applications the behavior of
SetParameterStringList is the expected one.