Hello,
I'm trying to create a simple attribute rule to prevent a user from creating a point outside a polygon layer. My code is below, when I hit validate it seems to check out but when I try creating points it returns the error even if the point is inside the polygon layer I'm referencing. Any feedback is much appreciated, thanks!
-------------------------------------------------------------------------------------------
// variable for 'AOR' layer
var aor = FeatureSetByName($datastore, "aor", ['*'], True);
// boolean "if statement" for determining if point intersects the 'aor' layer
if (Within($feature, aor) == True)
return True
else
return False
Solved! Go to Solution.
This function has 2 signatures:
You use the second version (with a geometry for the inner feature and a feature set for the outer features) and expect a boolean return value, but it actually returns a feature set of polygons. So you have to check if this feature set contains any features.
var aor = FeatureSetByName($datastore, "aor")
return Count(Within($feature, aor)) > 0
// you could also do this
//return First(Within($feature, aor)) != null
This function has 2 signatures:
You use the second version (with a geometry for the inner feature and a feature set for the outer features) and expect a boolean return value, but it actually returns a feature set of polygons. So you have to check if this feature set contains any features.
var aor = FeatureSetByName($datastore, "aor")
return Count(Within($feature, aor)) > 0
// you could also do this
//return First(Within($feature, aor)) != null