| 250 | {{{ |
| 251 | DROP TABLE IF EXISTS wrbd.station_ccm_500; |
| 252 | CREATE TABLE wrbd.station_ccm_500 as ( |
| 253 | SELECT distinct on (st_id ) st_id , gid, wso1_id, min(distance) as distance, the_geom FROM ( |
| 254 | SELECT st_id, gid , wso1_id, CAST(distance(r.the_geom, s.the_geom) as decimal(15,1)) as distance,s.the_geom |
| 255 | FROM wrbd.station_st As s |
| 256 | INNER JOIN ccm21.riversegments r ON ST_DWithin(r.the_geom, s.the_geom,500) |
| 257 | WHERE s.the_geom IS NOT NULL |
| 258 | ORDER BY st_id) AS sub |
| 259 | GROUP BY st_id, gid, wso1_id, distance,the_geom |
| 260 | ); |
| 261 | alter table wrbd.station_ccm_500 add column id serial; |
| 262 | -- mise à jour de la table geometry_columns |
| 263 | INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") |
| 264 | SELECT '', 'wrbd', 'station_ccm_500', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) |
| 265 | FROM wrbd.station_ccm_500 LIMIT 1; |
| 266 | }}} |