"here()" function to return the current location

Do you think a fonction that returns the current location or a hidden question type could exist ?
As we can use now() to get current time, it could be very useful to be able to get the current location without asking for a geopoint, for example to filter options to be shown in a select from map :slight_smile:

Have you tried start-geopoint? The way it's implemented in the underlying XForms spec, it can be triggered by value change or repeat creation but we haven't exposed that in XLSForm yet. Do note that it's different from time because you're not guaranteed to get a good point or a point at all within the 20s window that it will try.

1 Like

Thanks @ln !
I didn't know that. I was thinking it was only usable one time at the begining of the form.
I will try it and come back to you about that.

I did compare it to now() because it can be used in a calculation without invoking it in a previous question.

1 Like

Note, a new XPath function (ala here()) for capturing the current GPS location has been discussed (and rejected) previously. Specifically:

I think the custom XForms action orx:setlocation is the way to go instead of an XPath function, because obtaining a location can be assumed to an asynchronous operation, which would be very problematic in an XPath evaluator (it would have to block until a response is received or timeout has passed).

As noted by @ln there is the existing start-geopoint question type in XLSForm for doing a one-time location fix at the beginning of the form. And if you dont mind getting your hands dirty with XForm XML, you can also trigger capturing a GPS locations at later points in your form whenever a question is answered; from https://getodk.github.io/xforms-spec/#setting-a-static-value-when-a-nodes-value-changes

<input ref="/data/my_text">
    <setvalue event="xforms-value-changed" ref="/data/my_text_changed">Value changed!</setvalue>
    <odk:setgeopoint event="xforms-value-changed" ref="/data/my_current_location" />
</input>

(although as stated the odk:seteopoint part isnt exposed in XLSForm, yet... Whereas the setvalue bit is bascially what an XLSForm trigger gets turned into)