Select to view content in your preferred language

Store Geometry in Field Maps Related Table?

927
7
Jump to solution
09-01-2023 06:07 AM
santamariaa
New Contributor III

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.

0 Kudos
1 Solution

Accepted Solutions
AlfredBaldenweck
MVP Regular Contributor

Honestly, this seems more like a job for Survey123 than FieldMaps.

View solution in original post

7 Replies
DougBrowning
MVP Esteemed Contributor

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.

0 Kudos
santamariaa
New Contributor III

That is an option. I just thought I would ask about the related table component because it seems like it should be possible.

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Alternatively, you could just store the coordinates in a text or number field? Solved: Using Arcade to calculate xy geometry. - Esri Community 

0 Kudos
santamariaa
New Contributor III

This does not work in a related table where you might just want to store X/Y data for future reference. 

AlfredBaldenweck
MVP Regular Contributor

Yes it does?

AlfredBaldenweck_3-1694011559550.jpeg

 

AlfredBaldenweck_4-1694011576049.jpeg

 

PointRelated 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:

  • Make sure the relationship is not globalid:globalid. it should be globalid:guid. 
  • Make sure this setting is checked
    AlfredBaldenweck_0-1694009816384.png

     

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.

0 Kudos
santamariaa
New Contributor III

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.

0 Kudos
AlfredBaldenweck
MVP Regular Contributor

Honestly, this seems more like a job for Survey123 than FieldMaps.