 
 
 -- Loss map data.
+-- See https://bugs.launchpad.net/openquake/+bug/805434 and
+-- https://bugs.launchpad.net/openquake/+bug/797708
 
 -- Design decision: store both probabilistic and event based loss map in the
 -- same tables (with some checks for consistency)

    output_id INTEGER NOT NULL, -- FK to output.id
    loss_map_ref VARCHAR,
    end_branch_label VARCHAR,
    loss_category VARCHAR, -- open-ended, cfr Vitor's mail
    unit VARCHAR, -- open-ended
    -- time_span and poe are significant only for probabilistic calculations,
    -- fact that is hard to enforce here
    time_span float CONSTRAINT non_negative_time_span CHECK (time_span >= 0.0),
    poe float CONSTRAINT valid_poe CHECK ((poe >= 0.0) AND (poe <= 1.0))
) TABLESPACE uiapi_ts;


            OR (loss_value IS NOT NULL AND loss_mean IS NULL AND loss_std_dev IS NULL))
) TABLESPACE uiapi_ts;
SELECT AddGeometryColumn('uiapi', 'loss_map_site_data', 'site', 4326, 'POINT', 2);


-- Loss asset data.
