| 184 | |
| 185 | select id_drain from rht.rht_bdcarthage where id_drain not in select id_drain from rht.rht_bdcarthage; --- |
| 186 | |
| 187 | ---Changement de buffer |
| 188 | drop table if exists rht.rht_150b; |
| 189 | create table rht.rht_150b as select id_drain, gid, st_buffer(the_geom,150,endcap=flat) as the_geom from rht.rht; ---12578 ms |
| 190 | CREATE INDEX indexrht_150b ON rht.rht_150b |
| 191 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |
| 192 | CREATE INDEX indexrht150b |
| 193 | ON rht.rht_150b |
| 194 | USING btree (id_drain); |
| 195 | |
| 196 | drop table if exists rht.rht_bdcarthage2; |
| 197 | create table rht.rht_bdcarthage2 as |
| 198 | select distinct on (id_bdcarth) id_bdcarth, min(distance) as distance, id_drain from ( |
| 199 | select r.id_drain, |
| 200 | id_bdcarth, |
| 201 | ST_Distance(r.the_geom,bdc.the_geom) as distance |
| 202 | from rht.rht r join rht.rht_150b rht150b on r.id_drain=rht150b.id_drain |
| 203 | join bd_carthage2011.troncon_hydrographique bdc on st_intersects(bdc.the_geom,rht150b.the_geom) |
| 204 | where nature !='Aqueduc, conduite forcée' and num_superp !=1 ) as toto |
| 205 | group by id_bdcarth, distance, id_drain |
| 206 | order by id_bdcarth ; ---393393 lines |
| 207 | CREATE INDEX indexrhtbdc2 |
| 208 | ON rht.rht_bdcarthage2 |
| 209 | USING btree (id_bdcarth); |
| 210 | CREATE INDEX indexrhtbdc22 |
| 211 | ON rht.rht_bdcarthage2 |
| 212 | USING btree |
| 213 | (id_drain); |