// Check the value of the room level field: values are "base" "lowr" "uppr" "pent" "mezz"
var roomlevel = $feature.Room_Level
// Create a feature set using the 'Basement' layer in the map
var based = FeatureSetByName($map, "BORG_Basement_Level")
// Intersect the current location with the the level and
// get the first intersecting room
var base1 = First(Intersects($feature, based))
// Create a feature set using the 'Lower' layer in the map
var lowerd = FeatureSetByName($map, "BORG_LowerLevel")
// Intersect the current location with the the level and
// get the first intersecting room
var lower1 = First(Intersects($feature, lowerd))
// Create a feature set using the 'Upper' layer in the map
var upperd = FeatureSetByName($map, "BORG_UpperLevel")
// Intersect the current location with the the level and
// get the first intersecting room
var upper1 = First(Intersects($feature, upperd))
// Create a feature set using the 'Penthouse' layer in the map
var pentd = FeatureSetByName($map, "BORG_Penthouse")
// Intersect the current location with the the level and
// get the first intersecting room
var pent1 = First(Intersects($feature, pentd))
// Create a feature set using the 'Mezzanine' layer in the map
var mezzd = FeatureSetByName($map, "BORG_Mezzanine")
// Intersect the current location with the the level and
// get the first intersecting room
var mezz1 = First(Intersects($feature, mezzd))
// If the current location does intersect a feature,
// return the name of the region. Otherwise, return null
return When(
roomlevel == "base", base1['room_id'],
roomlevel == "lowr", lower1['room_id'],
roomlevel == "uppr", upper1['room_id'],
roomlevel == "pent", pent1['room_id'],
roomlevel == "mezz", mezz1['room_id']
)
The final part of the script is where I'm having the most trouble, I don't know how to format the script to output the desired value reliably. Right now can only make it return the basement value.
Thanks!