Skip to content
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

number(geopoint) returns empty string #555

Open
getodk-bot opened this issue Sep 5, 2016 · 4 comments · May be fixed by #598
Open

number(geopoint) returns empty string #555

getodk-bot opened this issue Sep 5, 2016 · 4 comments · May be fixed by #598

Comments

@getodk-bot
Copy link
Member

Issue by mitchellsundt
Thursday Jul 09, 2015 at 19:39 GMT
Originally opened as getodk/getodk#1006 (3 comment(s))


Originally reported on Google Code with ID 1005

number(geopoint) should return a number. It returns an empty string,

Reported by yanokwa@nafundi.com on 2014-05-20 19:39:27


- _Attachment: [geopoint_accuracy.xml](https://storage.googleapis.com/google-code-attachments/opendatakit/issue-1005/comment-0/geopoint_accuracy.xml)_
@getodk-bot
Copy link
Member Author

Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:39 GMT


Looked into this...

The handling/placement of IExprType is entirely broken in the JR code.

It should be an interface on the data returned by the GeoPointData container, not an
interface on the container itself.

This mis-coding was hidden due to the order if the instanceof tests in the XPathFuncExpr
class' implementations of toNumeric, toBoolean, toString.


The toBoolean and toString behaviors work as intended just by accident.

Should probably rework all the data types except int, numeric and string (e.g., all
the date and time types) to use IExprType and should test for this type first in the
XPathFuncExpr logic.

This is likely why the date-time logic remains completely broken w.r.t. type conversions.


Reported by mitchellsundt on 2014-05-21 17:59:47

  • Labels added: Collect, JavaRosa

@getodk-bot
Copy link
Member Author

Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:39 GMT


Also faced this issue here needing to check GPS accuracy.  Came up with an ugly workaround
as:
number(substr(geopoint, string-length(geopoint)-5))

However this only works reliably for accuracy between 10 and 999m

Reported by peterdcrees on 2014-09-15 08:00:09

@getodk-bot
Copy link
Member Author

Comment by mitchellsundt
Thursday Jul 09, 2015 at 19:39 GMT


Another work-around might be

selected-at(/data/geopoint, 3)

Assuming the geopoint value is converted early to a string, this should pick out the
accuracy value.

Reported by mitchellsundt on 2014-09-15 17:29:10

@lognaturel lognaturel transferred this issue from getodk/collect Mar 10, 2020
@lognaturel
Copy link
Member

There are some possible issues highlighted at #555 (comment) that would be good to introduce tests around.

macdude357 pushed a commit to macdude357/javarosa that referenced this issue Sep 16, 2020
Added test to test XPathFuncExpr.toString, toNumber, etc when passing a
GeoPointData instance.
@macdude357 macdude357 linked a pull request Sep 16, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants