# take the union of three different assets (buildings x 2 and roads)
input('roads', name: 'exposure') as roads
 -> exposures
input('building-points', name: 'exposure') as points
 -> exposures
input('buildings', name: 'exposure') as buildings
 -> union() as exposures
 -> select({*, hazard: sample(exposure, bookmark('hazard'))})
 -> select({*, consequence: exposed_state(exposure, hazard)})
 -> select({*}) as event_impact_table
 -> group(by: consequence.status, select: { consequence.status as consequence, count(*) as total })
 -> sort(consequence)
 -> save('summary', format: 'csv')

# calculate losses (or rather value) separately, then take the union
buildings
 -> select({ value_building(*) as value })
 -> group({ 'Buildings' as input, sum(value) as total_value })
 -> union() as total_value
 -> sort(input)
 -> save('total_value', format: 'csv')

roads
 -> select({ value_road(*) as value })
 -> group({ 'Roads' as input, round(sum(value), 2) as total_value })
 -> total_value

points
 -> select({ value_building(*) as value })
 -> group({ 'Building Points' as input, round(sum(value), 2) as total_value })
 -> total_value

