Hey Esri community!
I'm hoping someone can help me out with a little problem I'm having. I'm trying to create an attribute rule that only allows certain assets to be created if they're either at the start or end of a line, or not on a line at all.
To do this, I need to check an array of arrays to see if another freshly built array is contained within it. Is this even possible?
If anyone has any suggestions or solutions, I'd be really grateful! Thanks in advance for any help you can give.
This is the code i currently have:
// Define target asset groups and types as touples
var tagt = [
[3, 957], // asset 1
[900, 901], // asset 2
[910, 911], // asset 3
[950, 951], // asset 4
[13, 710] // asset 5
];
// Create touple of feature asset group and type
var fagt = [$feature.assetgroup, $feature.assettype]
// Check if current feature triggers attribute rule
if (Includes(tagt, fagt)){
// Get pipeline features from datastore
var pipelines = FeatureSetByName($datastore, "PipelineLine", ["globalId"], false);
// Get all intersecting pipeline features
var intersectingPipes = Intersects(pipelines, $feature);
// If no line is intersected, allow edit process
if (isEmpty(intersectingPipes)){
return true;
} else {
// Else, iterate over inersecting pipeline features
for (var pipe in intersectingPipes) {
// Get start and endpoint of intersected line feature
var endPoint = Geometry(pipe).paths[-1][-1];
var startPoint = Geometry(pipe).paths[0][0];
// Check if the current feature intersects start or endpoint of line
if (Intersects(endPoint, $feature)) {
// If yes, allow edit process
return true;
} else if (Intersects(startPoint, $feature)) {
// If yes, allow edit process
return true;
}
}
// Else, hinder edit process
return false;
}
} else {
return true;
}