@Raghu_Mittal has generously offered to contribute a Collect feature that will read the device location in the background. Read more about the feature at Auto-gps implementation on ODK Collect. This is something he has built and used in a fork. In that fork, the code populates a node in the form with name
Since we try to avoid reserved node names and want to make sure forms can work across implementations, I think it's worth discussing possible alternatives.
I think the approach that would be most consistent with W3C XForms is to introduce a new
action that given an event and a node would populate that node with a location when the event happens. For example, the event in this case would generally be form load. That would look something like:
<bind nodeset="/data/current_location" type="geopoint"/> <orx:getlocation event="xforms-ready" ref="/data/current_location"/>
Conveniently, Dimagi has already had the same idea: https://dimagi.github.io/xform-spec/#actions. For some reason, they called their action
orx:pollsensor so we'd have to weigh having a specific, descriptive name against bringing the two specifications into better alignment. Or perhaps we could document something like
orx:getlocation and alias
orx:pollsensor for compatibility.
A great thing about this strategy is that it would also allow us to request location readings on different events. For example:
<bind nodeset="/data/species" type="string" /> <bind nodeset="/data/species_location" type="geopoint" /> ... <input ref="/data/species"> <orx:pollsensor event="xforms-value-changed" ref="/data/species_location" /> </input>
This would trigger a request for a location reading when the value of
species is changed. The reading would be stored in
species_location when acquired.
@martijnr, @Xiphware, @michal_dudzinski and I have been involved in a related conversation about capturing timestamps here (the conversation started before the forum existed!) and it would be nice for these two features to harmonize. What do you all think of this approach?
@Raghu_Mittal the client implementation would be the same and someone can definitely help you connect the pieces together.