Survey123 with Collector: set geotrace

4265
19
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

1 Solution

Accepted Solutions
JamesTedrick
Esri Esteemed Contributor

Hi Marc-Andre,

I had a bit of time to work this out - this should provide the line.  There are some issues with more complex lines, as they can consist of multiple parts:

var geom = Geometry($feature);
var outparts = [];
var counter = 0;
for (var p in geom.paths) {
 var thispath = geom.paths
;
 for (var pt in thispath) {
   var ptstr = Concatenate(thispath[pt].y, " ", thispath[pt].x);
   outparts[counter]= ptstr;
   counter = counter + 1;
 } 
}

return Concatenate(outparts, ";");

View solution in original post

19 Replies
JamesTedrick
Esri Esteemed Contributor

Hi Marc-Andre,

What aspect of the line do you want to bring into Survey123?  I would take a look at the Geometry functions in Arcade Function Reference | ArcGIS for Developers - you could include these as an attribute expression.

0 Kudos
Marc-AndreBedard
New Contributor II

Hi James,

thanks for your quick response.

I would like to "copy" the geometry from collector to the geotrace in Survey123.

I have a map containing roads and I want to start a survey on a specific segment.

So from collector, I pass via arguments certain fields that I want from Collector to Survey via the survey123s-custom-url-scheme. E.g.: Road name, owner,...

We currently have multiple maps and surveys that use custom url scheme with "point" entities. So the XY coordinates are pass to the survey in the geopoint.

So, I would like to do the same thing but with a line in collector to a geotrace in survey123.

Is it currently possible and supported ?

Regards,

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Copying the full geometry is a little more complicated- to begin with geotrace support is in beta in Survey123.  Survey123 will want the incoming coordinates to 

y1 x1;y2 x2;y3 x3;...

So you would need an Arcade function to process the shape vertices into this format.

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Marc-Andre,

I had a bit of time to work this out - this should provide the line.  There are some issues with more complex lines, as they can consist of multiple parts:

var geom = Geometry($feature);
var outparts = [];
var counter = 0;
for (var p in geom.paths) {
 var thispath = geom.paths
;
 for (var pt in thispath) {
   var ptstr = Concatenate(thispath[pt].y, " ", thispath[pt].x);
   outparts[counter]= ptstr;
   counter = counter + 1;
 } 
}

return Concatenate(outparts, ";");
ChrisRoberts2
Occasional Contributor III

Thanks James

What would be the syntax if we want to pass a polygon geometry from Collector to a Geoshape question in Survey123?

Cheers

Chris

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Chris,

The Arcade expressions very similar, mostly you need to substitute 'rings' for 'paths':

var geom = Geometry($feature);
var firstpart = geom.rings[0];
var outparts = [];
var counter = 0;
for (var pt in firstpart){
var ptstr = Concatenate(firstpart[pt].y, " ", firstpart[pt].x);
outparts[counter]= ptstr;
counter = counter + 1;
}

return Concatenate(outparts, ";")

I'm planning on publishing these in GitHub - Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in t...  in the near future.

ChrisRoberts2
Occasional Contributor III

Thanks James

I got that working, can I assume though that we would need to convert this into Lats and Longs in order to parse it through to a geoshape question?

I have built this link and although it opens up the appropriate survey and does contain the coordinates, is doesn't create the geoshape.

I have also tried substituting center for geoshape and the geoshape question name

arcgis-survey123://?itemID=6ffa91c679cd4ec99a6482e70dd3158e&center=-4368437.09908237%2015568468.47895944%3B-4368478.018118211%2015569744.148226732%3B-4368584.9584379345%2015569765.78726955%3B-4369031.402026243%2015569856.124205573%3B-4369455.085184722%2015569941.862870062%3B-4369426.875276136%2015568806.965103844%3B-4368476.830919922%2015568477.717157682%3B-4368437.09908237%2015568468.47895944

Just to add, I have managed to get the script to convert to lat and longs, but its still not creating a geoshape in Survey123.  Is the something else in the url OR the form that needs to be done in order to construct the shape?

arcgis-survey123://?itemID=6ffa91c679cd4ec99a6482e70dd3158e&center=-34.926006640680235%20138.59669421630525%3B-34.92639395082917%20138.59672384658316%3B-34.926403392567615%20138.59653796524657%3B-34.92640749222722%20138.59645756316633%3B-34.92642486038284%20138.59611928621797%3B-34.926311593671414%20138.5961108695519%3B-34.92627059577672%20138.5961077648081%3B-34.92603749657436%20138.59608996445877%3B-34.926006640680235%20138.59669421630525

0 Kudos
JamesTedrick
Esri Esteemed Contributor

Hi Chris,

- Yes, the coordinates need to be latitude and longitude (decimal degrees, expected SRID is WGS1984 (4326) ).  This is most easily accomplished by creating your web map with a 4326-based basemap (Esri provides several to comply with organizations that have mandatory requirements to use WGS1984).

- You should not use the center parameter (which conceptually, would not make sense to pass a non-point object); use field:<fieldname>.

As an example, take a look at https://www.arcgis.com/home/item.html?id=9197d8545a214fe9829e95aa095302ec 

ChrisRoberts2
Occasional Contributor III

Awesome!  Cracked it!!

Thanks so much James

0 Kudos