1. What is the issue? Please be detailed.
I've seen that quite a few people have used geopoints and the distance function to verify that the enumerator is at least X distance away from a previous/static GPS point using a geopoints question. I'd like to do this for a larger quantity of points (let's say about 50-100) and making this as passive on the enumerator as possible. It seems like this would ideally be a geotrace. I searched the forum and couldn't find anything but I wanted to throw this out there to see if I'm way off, if someone else has already done this, or if this is worth pursuing.
I ideally want to make a form that has a start for the geotrace then they can put their phone in their pocket for the next 15 minutes and walk do a field inspection which would inspect a couple hundred trees about a hectare or slightly more in size. I would then want a calculate field that would be able to confirm that any point in the geotrace comes within 10m of each of my previous 50-100 points. Finally I would want a constraint so that the form cannot be submitted unless this has been achieved.
Kapa AI basically says this isn't possible. I got chatGPT to suggest putting calculate questions in a repeat that doesn't have other questions so it isn't visible to the user. I've never thought of this and never seen any examples of this. Has anyone ever tried this to iterate a calculation / create a for loop?
It seems like this could be done but I figured I'd ask if anyone has ever done this first. My ideas so far would be to transform a geotrace into a space separated string, then use count-selected() to count the total number of geopoints, the Position() + repeat iteration to get a specific gps point in the geotrace, then use distance() to evaluate between that point and point 1 of 50. If I have 50 points, then in my repeat I'd put 50 calculate fields each with the nested formulas above but Comparing them to different points. If I have these hard coded points this seems possible, but would making a repeat with only calculate fields and a repeat count = the number of points in a geotrace actually be a way to iterate through the geotrace?
Take a look at this for how to scan thru the points in a geoshape/geotrace, using a repeat.
Also, look at the min() function (in addition to your distance() calculation). That may basically tell you the furthest a single point is from your geotrace points encompassed by the repeat [notwithstanding that the minimum distance from a point A to two other points B & C is, in almost all cases, greater than the minimum distance between A and the line B-C joining them…]
If you have a variable in the repeat_count column, don't repeat instances get created the moment that variable calculates? I would think if you only had calculate fields in the repeat and didn't make the repeat or any of its fields irrelevant that it would instantly make all the repeats and calculations (if the variables in those calculations already have values) in those repeats the moment the repeat_count variable is calculated...
min() will tell you the closest distance the point lies from all the other points in the geotrace; that would basically tells you how far away the point is from the geotrace [notwithstanding the above caveat wrt lines]. Whereas max() will tell you the maximum distance the point is from any point in the geotrace, which doesn’t really tell you much; eg I could be only 1m (ie my ‘furthest’) from the geotrace’s starting point, but I could well be 500m from the last point; I’d want to know that I only strayed 1m off the geotrace, not 500m.
Ideally, you’d want to measure the distance from the point to the line between each adjacent pair of points in the geotrace. That would more accurately tell you how far off the geotrace you are. The above geofence form does in fact pull out adjacent pairs of points in its repeat loop (its point-in-polygon algorithm needs this), but you would then need to implement your own distance calculation to measure the geospatial distance between a geopoint and the great circle defined by the two other points, since you would not be able to use the built-in distance() function.
[aside: this is the general geospatial solution, but for ‘short’ offset distances you may be able to get a sufficient approximation of this distance using a planar (flat) projection of a point onto a line, which may be mathematically simple to compute in XLSForm/javarosa; eg https://stackoverflow.com/questions/64330618/finding-the-projection-of-a-point-onto-a-line\]