Survey123 with Collector: set geotrace

1901
18
Jump to solution
04-29-2019 12:45 PM
Marc-AndreBedard
New Contributor II

Hi !

is there a way to pass the location of a line in collector "Aurora" to Survey123 in the same way of passing the location to a geopoint in survey123 ?

Thanks to great thread https://community.esri.com/groups/survey123/blog/2016/07/30/understanding-survey123s-custom-url-sche...  from https://community.esri.com/people/ichivite-esristaff and https://community.esri.com/people/JTedrick-esristaff

0 Kudos
18 Replies
TaraHaynes
New Contributor III

Hey! I've been trying to figure this out, but it seems I don't have permission to view your survey - does the shape text translate to a shape on a map within the Survey123 form, or is it simply saved as text?

RustyCook
New Contributor II

Was this ever solved? Im trying to pass the coordinates for a polygon via url but no luck on getting it to show up on the map within the survey. 

?field:<geoshape field name>=47.31507205963135%20-122.41456244885921;47.314385414123535%20-122.41456244885921

0 Kudos
ChrisRoberts2
Occasional Contributor II

This works for me.  Below is the Arcade script I created:

var geom = Geometry($feature);
var firstpart = geom.rings[0];
var originShift = 2.0 * PI * 6378137.0 / 2.0;
 
var outparts = [];
var counter = 0;
for (var pt in firstpart){
    var long = (firstpart[pt].x / originShift) * 180.0;
var lat = (firstpart[pt].y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
 
var lat =Round(lat, 5) 
var long =Round(long, 5)
var ptstr = Concatenate(lat, " ", long);
outparts[counter]= ptstr;
Then create a hyperlink in the pop up:  "arcgis-survey123://?itemID=xxxxxx&amp;field:Polygon={expression/expr0}" 
With Polygon being the geotrace question in the survey
You might notice in my Arcade that I round the lat and long returns down to 5 decimal places.  I found that leaving them as default would often fail for slightly complex polys which I think is due to the overall length of the url it produces.
Hope that helps
Chris
RustyCook
New Contributor II

Thanks! Could you share what the url looks like, just the geometry part? Im passing the geometry through the REST API so I may have to format it within the script before passing it over in a similar fashion just different language. Also Im using a geoshape, not trace. Do you know if thats possible?

0 Kudos
ChrisRoberts2
Occasional Contributor II

The Arcade expression is for the geoshape question, sorry miss typed there.

Here is one that copies a selected parcel in Explorer and parses the polygon to a Survey123 form (the bit in italics is what you want I think).  Note I also capture the centroid of the Parcel so I can perform a reverse geocode in Survey123 to get the address

arcgis-survey123://?itemID=xxx&field:dcdbid_1=F112784A2&field:ct=CT&field:volume=5203&field:folio=279&field:LandholderLiaisonParcels_polygon=-35.03596%20138.83725%3B-35.03959%20138.8346%3B-35.03807%20138.83162%3B-35.0355%20138.83349%3B-35.03549%20138.83348%3B-35.03446%20138.83422%3B-35.03596%20138.83725&field:longitude=138.8344310701019&field:latitude=-35.03701676138787

0 Kudos
RustyCook
New Contributor II

Thanks Chris for the help! So I tested it but it doesn't translate to a shape on a map within the Survey form; is it just saved as text in the background?

0 Kudos
ChrisRoberts2
Occasional Contributor II

Hi Rusty

Not sure why its not working for you, perhaps you could share the xlsform, and if I get a chance I'll have a look and see if there is anything obvious? If you parse the coordinates to the appropriate geoshape question in the form then in should  work  - field:LandholderLiaisonParcels_polygon=-35.03596%20138.83725%3B-35.03959%20138.8346%3B-35.03807%20138.83162%3B-35.0355%20138.83349%3B-35.03549%20138.83348%3B-35.03446%20138.83422%3B-35.03596%20138.83725

0 Kudos
RustyCook
New Contributor II

Attached is what I have. I haven't built this out as I'm only using this as my test/sandbox survey. 

?field:geofence=-35.03596%20138.83725%3B-35.03959%20138.8346%3B-35.03807%20138.83162%3B-35.0355%20138.83349%3B-35.03549%20138.83348%3B-35.03446%20138.83422%3B-35.03596%20138.83725

Thanks for taking a look!

0 Kudos
Marc-AndreBedard
New Contributor II

Perfect !

Arcade expression combined with a WGS84 basemap really did the trick !!!

Thank you James

0 Kudos