Is there any way to save a location that is offset from a geopoint as the geometry of a survey record?
For example, if I wanted my survey points to be shifted by 1 degree of latitude from the coordinates captured by my device, my first thought would be to calculate an offset location in a second geopoint question:
type | name | label | calculation | bind::esri:fieldType |
geopoint | gps_location | GPS Location | null | |
decimal | gps_latitude | GPS Latitude | pulldata("@geopoint", ${gps_location}, "y") | null |
decimal | gps_longitude | GPS Longitude | pulldata("@geopoint", ${gps_location}, "x") | null |
geopoint | offset_location | Offset Location | string(${gps_latitude} + 1) + " " + string(${gps_longitude}) |
(In reality I wouldn't be adding a hardcoded offset; I would be calling a custom JavaScript function, passing in ${gps_location}, and returning the desired coordinates for the offset location, but those details are not relevant.)
Unfortunately, this does not work because Survey123 can only save survey records' geometries based on the first geopoint question encountered, as explained in this answer. Indeed, if I publish this survey and try submit a record, I get the following error:
Send Error
This survey could not be sent due to the following error:
No mapping exists from object type ESRI.ArcGIS.Client.Geometry.MapPoint to a known managed provider native type.
Given that this doesn't work, is there any other solution for saving the geometry by calculating coordinates based on the device's location?
Solved! Go to Solution.
It turns out all I needed to do is switch the order of the two geopoint questions! I did not realize that calculations in Survey123 can use values of questions defined later in the form. Taking the example in my original post, the following modification works:
type | name | label | calculation | bind::esri:fieldType |
decimal | gps_latitude | GPS Latitude | pulldata("@geopoint", ${gps_location}, "y") | null |
decimal | gps_longitude | GPS Longitude | pulldata("@geopoint", ${gps_location}, "x") | null |
geopoint | offset_location | Offset Location | string(${gps_latitude} + 1) + " " + string(${gps_longitude}) | |
geopoint | gps_location | GPS Location | null |
It doesn't seem ideal to arrange the questions in such a nonintuitive order, but at least it works.
It turns out all I needed to do is switch the order of the two geopoint questions! I did not realize that calculations in Survey123 can use values of questions defined later in the form. Taking the example in my original post, the following modification works:
type | name | label | calculation | bind::esri:fieldType |
decimal | gps_latitude | GPS Latitude | pulldata("@geopoint", ${gps_location}, "y") | null |
decimal | gps_longitude | GPS Longitude | pulldata("@geopoint", ${gps_location}, "x") | null |
geopoint | offset_location | Offset Location | string(${gps_latitude} + 1) + " " + string(${gps_longitude}) | |
geopoint | gps_location | GPS Location | null |
It doesn't seem ideal to arrange the questions in such a nonintuitive order, but at least it works.