In this original Arcade script below, room IDs are successfully pulled and populated in the 'room_id' field of a point asset based on the floor level polygon of the intersecting layer. In virtually all cases, a Room ID is returned when running this script. The original working script is as follows:
// Check the value of the room level field, values are "base" "lowr" "uppr" "pent" "mezz"
var roomlevel = $feature.floor_level
// Define a function to get the room ID based on the room level
function GetRoomIdByLevel(levelName) {
// Create a feature set using the corresponding layer name
var level = FeatureSetByName($map, "ORD_" + levelName)
// Get the first intersecting room with the current location
var intersectingRoom = First(Intersects($feature, level))
// Check if an intersecting room is found (boolean check)
if (intersectingRoom != null) {
return intersectingRoom['room_id'];
} else {
return null;
}
}
// Get the room IDs for all levels
var baseRoomId = GetRoomIdByLevel("Basement");
var lowerRoomId = GetRoomIdByLevel("Lower");
var upperRoomId = GetRoomIdByLevel("Upper");
var pentRoomId = GetRoomIdByLevel("Penthouse");
var mezzRoomId = GetRoomIdByLevel("Mezzanine");
var ringRoomId = GetRoomIdByLevel("RingTunnel");
// Return the room ID based on the room level
if (roomlevel == "base") {
return baseRoomId;
} else if (roomlevel == "lowr") {
return lowerRoomId;
} else if (roomlevel == "uppr") {
return upperRoomId;
} else if (roomlevel == "pent") {
return pentRoomId;
} else if (roomlevel == "mezz") {
return mezzRoomId;
} else if (roomlevel == "ring") {
return ringRoomId;
} else {
// Return null if room level is invalid
return null;
}
And here is the modified script below that adds 'Within' as intersect method 1 and places the original method as intersect method 2. The goal here is to use intersect method 2 as a backup in case intersect method 1 returns a null value. So far, we have been unsuccessful at getting this modified script to return a value in the Room ID field. As far as we can tell, the script is functional and not returning any errors.
// Check the value of the room level field, values are "base" "lowr" "uppr" "pent" "mezz"
var roomlevel = $feature.floor_level
// Define a function to get the room ID based on the room level
function GetRoomIdByLevel(levelName) {
// Create a feature set using the corresponding layer name
var level = FeatureSetByName($map, "ORD_" + levelName)
// Get the first intersecting room with the current location
var intersectingRoom1 = First(Within($feature, level))
// Get the second intersecting room with the current location
var intersectingRoom2 = First(Intersects($feature, level))
// Check if an intersecting room is found (boolean check)
if (intersectingRoom1 != null) {
return intersectingRoom1['room_id'];
} else if (intersectingRoom2 != null) {
return intersectingRoom2['room_id'];
} else {
return null
}
}
// Get the room IDs for all levels
var baseRoomId = GetRoomIdByLevel("Basement");
var lowerRoomId = GetRoomIdByLevel("Lower");
var upperRoomId = GetRoomIdByLevel("Upper");
var pentRoomId = GetRoomIdByLevel("Penthouse");
var mezzRoomId = GetRoomIdByLevel("Mezzanine");
var ringRoomId = GetRoomIdByLevel("RingTunnel");
// Return the room ID based on the room level
if (roomlevel == "base") {
return baseRoomId;
} else if (roomlevel == "lowr") {
return lowerRoomId;
} else if (roomlevel == "uppr") {
return upperRoomId;
} else if (roomlevel == "pent") {
return pentRoomId;
} else if (roomlevel == "mezz") {
return mezzRoomId;
} else if (roomlevel == "ring") {
return ringRoomId;
} else {
// Return null if room level is invalid
return null;
}
levelis actually set.