Is it possible to use arcade to calculate your current location in a related table?
Essentially I want to use the geometry function to pull the device's location into a related table. I've done some testing and the current geometry functions in arcade are returning null values. Which makes sense because the related table doesn't "have" geometry.
Scenario:
For example, if we have a stream location that we always sample stream flow at, but some times when the site is visited the actual sample location may be up or down stream of official access site. So essentially, we want to store the actual sampled location in our related table in X/Y format, but not create a point at the location i.e the main sample access point stays put BUT the location of the sample varies. We don't really need the point location for display on field maps or in our web map.
Wasn't sure if this functionality was possible in a related table?
Basically some way to pull the device location into an attribute field in a related table.
Solved! Go to Solution.
Honestly, this seems more like a job for Survey123 than FieldMaps.
Why not just make it a related layer instead of a related table? Then you have both locations. That is what I do. It is really helpful in QA when users pick the wrong site.
That is an option. I just thought I would ask about the related table component because it seems like it should be possible.
Alternatively, you could just store the coordinates in a text or number field? Solved: Using Arcade to calculate xy geometry. - Esri Community
This does not work in a related table where you might just want to store X/Y data for future reference.
Yes it does?
|
|
Point | Related record |
I got the lat/long conversions from @JoshConrad1 here: Re: Collector (Aurora) Custom Expressions in Custo... - Esri Community
//Lat
var relF = FeatureSetByRelationshipName($feature, "exPoint1")
var ref_id = $feature.RelGUID
//This may be different for 1:M relationships?
//Idk I didn't test it.
relF = First(Filter(relF, 'GlobalID = @ref_id'))
var lat
var originShift = 2.0 * PI * 6378137.0 / 2.0
lat = number(Geometry(relF).Y / originShift) * 180.0
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0)
return lat
//Lon
var relF = FeatureSetByRelationshipName($feature, "exPoint1")
var ref_id = $feature.RelGUID
//This may be different for 1:M relationships?
//Idk I didn't test it.
relF = First(Filter(relF, 'GlobalID = @ref_id'))
var lon
var originShift = 2.0 * PI * 6378137.0 / 2.0
lon = number(Geometry(relF).X / originShift) * 180.0
return lon
My test data was in WGS84, so your mileage may vary here.
Couple things I had to figure out while doing this:
In any case, it may in fact be simpler to just use a related feature class, but if you want to use a table, this does work.
I think there is a bit of confusion. Yes, it does work when referencing the original point. That is, when you pull the geometry from the point and pass it to the related table. What I am curious about is if there is a way to pull the device location or any arcade expression to pass an X/Y value to a related table without having to actually physically create the point. Yes, I can create the related point feature class and manage data in the database that way. This question in theory should be possible but the arcade component may not be available yet. That is, pull my location and write it to a field using arcade. Not a big deal. Just curious if this was a possibility.
Honestly, this seems more like a job for Survey123 than FieldMaps.