I would like to do some checks on a new created polygon using attribute rules.
For example count the vertexes or check if they exists as points in a different layer.
I could not find a way to do it.
Possible way is to convert the feature geometry to JSON.
I found FromJSON but not ToJSON. There are many functions to translate from JSON to feature but not the other way around.
Is there any way to do it?
Thanks
Solved! Go to Solution.
Documentation for polygons and polylines: Type System | ArcGIS Arcade | ArcGIS Developer
Polygons have a rings attribute, polylines have a paths attribute. These are three-dimensional lists of numbers, representing point coordinates of multiple line segments / rings.
// get the number of vertices in a polygon
var rings = Geometry($feature).rings
var vertex_count = 0
for(var i in rings) {
vertex_count += Count(rings[i])
// for polygons, the first and last point of a ring are the same, so we have to subract 1
vertex_count -= 1
}
return vertex_count
// get number of points on vertices
var rings = Geometry($feature).rings
var point_fc = FeatureSetByName($datastore, "TestPoints", ["OBJECTID"], true)
var points_on_vertices = 0
for(var i in rings) {
for(var j in rings[i]) {
var vertex = rings[i][j]
points_on_vertices += Count(Intersects(vertex, point_fc))
}
}
return points_on_vertices
Documentation for polygons and polylines: Type System | ArcGIS Arcade | ArcGIS Developer
Polygons have a rings attribute, polylines have a paths attribute. These are three-dimensional lists of numbers, representing point coordinates of multiple line segments / rings.
// get the number of vertices in a polygon
var rings = Geometry($feature).rings
var vertex_count = 0
for(var i in rings) {
vertex_count += Count(rings[i])
// for polygons, the first and last point of a ring are the same, so we have to subract 1
vertex_count -= 1
}
return vertex_count
// get number of points on vertices
var rings = Geometry($feature).rings
var point_fc = FeatureSetByName($datastore, "TestPoints", ["OBJECTID"], true)
var points_on_vertices = 0
for(var i in rings) {
for(var j in rings[i]) {
var vertex = rings[i][j]
points_on_vertices += Count(Intersects(vertex, point_fc))
}
}
return points_on_vertices