Save Location with Offset

497
1
Jump to solution
03-17-2022 09:30 AM
SkylerKasko
New Contributor III

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:

typenamelabelcalculationbind::esri:fieldType
geopointgps_locationGPS Location null
decimalgps_latitudeGPS Latitudepulldata("@geopoint", ${gps_location}, "y")null
decimalgps_longitudeGPS Longitudepulldata("@geopoint", ${gps_location}, "x")null
geopointoffset_locationOffset Locationstring(${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?

0 Kudos
1 Solution

Accepted Solutions
SkylerKasko
New Contributor III

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:

typenamelabelcalculationbind::esri:fieldType
decimalgps_latitudeGPS Latitudepulldata("@geopoint", ${gps_location}, "y")null
decimalgps_longitudeGPS Longitudepulldata("@geopoint", ${gps_location}, "x")null
geopointoffset_locationOffset Locationstring(${gps_latitude} + 1) + " " + string(${gps_longitude}) 
geopointgps_locationGPS Location null

 

It doesn't seem ideal to arrange the questions in such a nonintuitive order, but at least it works.

View solution in original post

1 Reply
SkylerKasko
New Contributor III

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:

typenamelabelcalculationbind::esri:fieldType
decimalgps_latitudeGPS Latitudepulldata("@geopoint", ${gps_location}, "y")null
decimalgps_longitudeGPS Longitudepulldata("@geopoint", ${gps_location}, "x")null
geopointoffset_locationOffset Locationstring(${gps_latitude} + 1) + " " + string(${gps_longitude}) 
geopointgps_locationGPS Location null

 

It doesn't seem ideal to arrange the questions in such a nonintuitive order, but at least it works.