getodk / javarosa

The core library that many of the ODK tools are built around. It's written in Java, implements the ODK XForms spec, and runs on mobile devices and cloud servers. ✨🏗✨
Other
54 stars 106 forks source link

Add multi-argument and single string distance variants #761

Closed lognaturel closed 4 months ago

lognaturel commented 4 months ago

Closes #740

What has been done to verify that this works as intended?

Added a tests, tried sample form in Collect.

Why is this the best possible solution? Were any other approaches considered?

See https://github.com/getodk/xforms-spec/pull/311 for spec consideration.

I went back and forth on where to include the logic around argument quantity and types. I decided to put it in XPathFuncExpr because that's most inline with what other functions do and it feels helpful to get an overview of variants at that top level.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Regression risks center around the existing distance function. It's possible the changes break that existing variant in some subtle way.

Do we need any specific form for testing your changes? If so, please attach one.

https://docs.google.com/spreadsheets/d/1Dv9lD33Bfqz4XqmTNMJXm4NK9Lw0TloKph1juU0Kins/edit#gid=1068911091

Does this change require updates to documentation? If so, please file an issue here and include the link below.

https://github.com/getodk/docs/issues/1795

tiritea commented 4 months ago

An alternative would be to always only allow a single arg but to allow that arg to be a literal string rather than only a nodeset.

it actually seems more intuitive to me that the (singular) argument to the existing XPath distance() function should be able to support either a node/nodeset (for example, containing a geotrace value), or a string with an equivalent literal value (or string function generating such). Many XPath functions behave this way...

seadowg commented 4 months ago

Removing myself as a reviewer until we've merged https://github.com/getodk/xforms-spec/pull/311