| 39 | -- je vais chercher dans la ccm les informations sur les distances mer et les cumuls de barrages |
| 40 | |
| 41 | select distinct on (zonegeo) zonegeo from rht.noeudmer; |
| 42 | |
| 43 | alter table rht.noeudmer add column cumnbbar integer; |
| 44 | alter table rht.noeudmer add column dmer numeric; |
| 45 | alter table rht.noeudmer add column wso1_id integer; |
| 46 | |
| 47 | |
| 48 | update rht.noeudmer set (cumnbbar,dmer,wso1_id)= (jointure.cs_nbdams,jointure.cum_len_sea,jointure.wso1_id) from |
| 49 | -- resultat final de la jointure spatiale entre ccm et noeudfrontiere |
| 50 | (select distinct on (id_drain) id_drain, min(distance) as distance, wso1_id,cs_nbdams, cum_len_sea from ( |
| 51 | -- requete intermédiaire dont on prend le min (sub) |
| 52 | select id_drain, ST_distance(noeudfrontiere.the_geom,ccmrs.the_geom) as distance,ccmrs.* |
| 53 | FROM ccm.riversegments_france ccmrs join |
| 54 | (select id_drain, the_geom from rht.noeudmer where noeudmer and zonegeo in ('Est','pyrénées')) as noeudfrontiere |
| 55 | on ST_DWithin(noeudfrontiere.the_geom,ccmrs.the_geom, 500)) as sub |
| 56 | group by id_drain, distance, wso1_id,cs_nbdams, cum_len_sea) as jointure |
| 57 | where noeudmer.id_drain=jointure.id_drain; --100 lignes modifiées |