I have the following expression, but " var distSub = Distance(f, pEnd);" returns an error "Geometry type expected".
Not sure what I am missing here.
I would appreciate the community's help.
var searchDist = 10;
var pEnd = Geometry($feature).paths[-1][-1];
var fsSub = FeatureSetbyName ($datastore,'Sub_11kV', ['OBJECTID','Name','SubAssetNo'], false);
var fBuf = Buffer(pEnd, searchDist, 'meters')
var fSub = Intersects(fsSub, fBuf);
var cnt = Count(fSub);
var nearSub;
var minDist = searchDist;
for (var f in fSub){
var distSub = Distance(f, pEnd);
if (distSub < minDist) {
nearSub = f.SubAssetNo;
minDist = distSub;
}
}
return IIf(nearSub==null,'',nearSub);
I Think if you looked at the type for fSub it would be Boolean rather than a Geometry. Try Intersection() rather than Intersects(). https://developers.arcgis.com/arcade/function-reference/geometry_functions/#intersection