Select to view content in your preferred language

Possible to constrain geopoint response location on repeat maps?

197
2
Jump to solution
08-06-2025 01:26 PM
Crinoid
Occasional Contributor

Hi, I've got a geopoint question nested inside a repeat. I want to constrain the responses so they can only submit each location if the point was placed in a given geographic area. I tried to use pulldata following this methodology to identify whether a given map point was in the permitted area, then used a constraint on the geopoint question to only allow responses in that area. At first I thought it was working, but then I realized that the constraint only gets triggered on the first response in the repeat. The other responses can be placed outside the permitted area and the constraint message doesn't get triggered. Is this just a limitation of repeats or can I get around it somehow?

Thank you!

0 Kudos
1 Solution

Accepted Solutions
TylerGraham2
Frequent Contributor

I just tested a snippet of a spatial constraint setup that I use to make sure marine mammal sightings being reported are in the water. Mine is normally outside of a repeat, but I set it up in one and it is working across multiple repeat records.  

This also checks to see if the device is online since you need to have an active internet connection to query the layers and bypasses the check if there's no internet.  

Here's how it works.

The online_check field uses the calculation: pulldata("@property", 'online') to make sure the device is connected to the internet.

The loc_check field uses the calculation: pulldata("@layer", "getRecordAt", "Feature Layer to check URL Goes Here", ${animalLoc}) which pulls the vertices of the feature that the geopoint is in.

The water_check field uses the calculation: pulldata("@json", ${loc_check}, "attributes.BodyType") to grab the attribute from the BodyType field, which in my case is "Water". You'll need to change attributes.BodyType to whatever field you want to pull the value from.  

The geopoint has the following constraint: if(${online_check} = 'true', ${water_check} = 'Water', ${online_check} = 'false') which when it is online the water_check value has to equal 'Water' or it doesn't meet the conditions of the constraint. So if the point is outside of one of my water polygons, it is essentially returning null = 'Water' which fails and triggers the constraint response.  You can change 'Water' to whatever value you want the water_check question to match.  

Notice that I'm not passing the layer coordinates into the constraint. With complex polygons that have a lot of vertices it crashes Survey123 since it is always trying to see if the geopoint is within the vertices. This way finds the polygon the geopoint is in and passes an attribute value to the constraint instead which doesn't cause any performance issues.

View solution in original post

0 Kudos
2 Replies
TylerGraham2
Frequent Contributor

I just tested a snippet of a spatial constraint setup that I use to make sure marine mammal sightings being reported are in the water. Mine is normally outside of a repeat, but I set it up in one and it is working across multiple repeat records.  

This also checks to see if the device is online since you need to have an active internet connection to query the layers and bypasses the check if there's no internet.  

Here's how it works.

The online_check field uses the calculation: pulldata("@property", 'online') to make sure the device is connected to the internet.

The loc_check field uses the calculation: pulldata("@layer", "getRecordAt", "Feature Layer to check URL Goes Here", ${animalLoc}) which pulls the vertices of the feature that the geopoint is in.

The water_check field uses the calculation: pulldata("@json", ${loc_check}, "attributes.BodyType") to grab the attribute from the BodyType field, which in my case is "Water". You'll need to change attributes.BodyType to whatever field you want to pull the value from.  

The geopoint has the following constraint: if(${online_check} = 'true', ${water_check} = 'Water', ${online_check} = 'false') which when it is online the water_check value has to equal 'Water' or it doesn't meet the conditions of the constraint. So if the point is outside of one of my water polygons, it is essentially returning null = 'Water' which fails and triggers the constraint response.  You can change 'Water' to whatever value you want the water_check question to match.  

Notice that I'm not passing the layer coordinates into the constraint. With complex polygons that have a lot of vertices it crashes Survey123 since it is always trying to see if the geopoint is within the vertices. This way finds the polygon the geopoint is in and passes an attribute value to the constraint instead which doesn't cause any performance issues.

0 Kudos
Crinoid
Occasional Contributor

With your help I was able to identify my issue! I had my checks outside of the repeat rather than inside, so it wasn't running on anything past the first repeat. I really appreciate the help, thank you!

0 Kudos