| 52 | |
| 53 | drop table if exists ccm21.taux_etagement; |
| 54 | create table ccm21.taux_etagement as ( |
| 55 | select te.*,c0.the_geom from ccm21.catchments c0 join ( |
| 56 | select wso3_id,max(cs_height)-min(cs_height) as ddh, |
| 57 | max(elev_mean)-min(elev_mean) as dnh, |
| 58 | CASE WHEN (max(elev_mean)-min(elev_mean))=0 then NULL |
| 59 | ELSE (max(cs_height)-min(cs_height)) / (max(elev_mean)-min(elev_mean)) |
| 60 | END as te |
| 61 | from ccm21.catchments c |
| 62 | join (select * from ccm21.riversegments WHERE wso_id IN (SELECT wso_id FROM europe.wso WHERE area='France'))r |
| 63 | on r.wso1_id=c.wso1_id |
| 64 | group by wso3_id) as te |
| 65 | on te.wso3_id=c0.wso3_id); |
| 66 | alter table ccm21.taux_etagement add column id serial; |
| 67 | alter table ccm21.taux_etagement add CONSTRAINT taux_etagement_pkey PRIMARY KEY (id); |
| 68 | alter table ccm21.taux_etagement add CONSTRAINT enforce_dims_the_geom CHECK (st_ndims(the_geom) = 2); |
| 69 | alter table ccm21.taux_etagement add CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL); |
| 70 | alter table ccm21.taux_etagement add CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 3035); |
| 71 | |