| 19 | -- Sauvegarde de la table station depuis la dbeel vers la ccm |
| 20 | {{{ |
| 21 | e: |
| 22 | cd E:\IAV\eda\anglian |
| 23 | C:\"Program Files"\PostgreSQL\9.0\bin\pg_dump -h localhost -U postgres --table anglian.station --file "anglian_station.sql" dbeel |
| 24 | C:\"Program Files"\PostgreSQL\9.0\bin\psql -h 93.20.247.238 -U postgres --file "anglian_station.sql" eda2 |
| 25 | }}} |
| 26 | |
| 27 | {{{ |
| 28 | create schema anglian; |
| 29 | }}} |
| 30 | {{{ |
| 31 | #!sql |
| 32 | DROP TABLE IF EXISTS anglian.anglian_station_ccm_500; |
| 33 | CREATE TABLE anglian.anglian_station_ccm_500 as ( |
| 34 | SELECT distinct on (site_id ) site_id , gid, wso1_id, min(distance) as distance, the_geom FROM ( |
| 35 | SELECT site_id, gid , wso1_id, CAST(distance(r.the_geom, s.the_geom) as decimal(15,1)) as distance,s.the_geom |
| 36 | FROM anglian.station As s |
| 37 | INNER JOIN ccm21.riversegments r ON ST_DWithin(r.the_geom, s.the_geom,500) |
| 38 | WHERE s.the_geom IS NOT NULL |
| 39 | ORDER BY site_id) AS sub |
| 40 | GROUP BY site_id, distance, gid, wso1_id, the_geom |
| 41 | ); |
| 42 | alter table anglian.anglian_station_ccm_500 add column id serial; |
| 43 | -- mise à jour de la table geometry_columns |
| 44 | INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") |
| 45 | SELECT '', 'anglian', 'anglian_station_ccm_500', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) |
| 46 | FROM anglian.anglian_station_ccm_500 LIMIT 1; |
| 47 | -- creation d'index, clé primaire, et constraintes qui vont bien |
| 48 | alter table anglian.anglian_station_ccm_500 add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); |
| 49 | alter table anglian.anglian_station_ccm_500 add CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); |
| 50 | alter table anglian.anglian_station_ccm_500 add CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); |
| 51 | alter table anglian.anglian_station_ccm_500 ADD CONSTRAINT pk_id PRIMARY KEY(id); |
| 52 | CREATE INDEX indexstation_ccm_500 ON anglian.anglian_station_ccm_500 |
| 53 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |
| 54 | }}} |
| 55 | |
| 56 | {{{ |
| 57 | C:\"Program Files"\PostgreSQL\9.0\bin\pg_dump -h 93.20.247.238 -U postgres --table anglian.station --file "anglian_station_ccm_500.sql" eda2 |
| 58 | }}} |
| 59 | |
| 60 | |