36 | | st_id character varying(10), |
37 | | st_ecoregion character varying(10), |
38 | | st_river character varying(40), |
39 | | st_name text, |
40 | | st_x numeric, |
41 | | st_y numeric, |
42 | | st_z numeric, |
43 | | st_pk_des numeric, |
44 | | st_date date, |
45 | | st_21fpcomun_num integer, |
46 | | st_nha numeric); |
| 36 | st_id character varying(10), |
| 37 | st_ecoregion character varying(10), |
| 38 | st_river character varying(40), |
| 39 | st_name text, |
| 40 | st_x numeric, |
| 41 | st_y numeric, |
| 42 | st_z numeric, |
| 43 | st_pk_des numeric, |
| 44 | st_date date, |
| 45 | st_21fpcomun_num integer, |
| 46 | st_nha numeric); |
53 | | op_date date, |
54 | | op_st_id character varying(10), |
55 | | op_op_id character varying(10) primary key, |
56 | | st_x numeric, |
57 | | st_y numeric, |
58 | | st_z numeric, |
59 | | st_pk_des numeric, |
60 | | op_surf numeric, |
61 | | op_methodest character varying(30), |
62 | | op_fishingobj character varying(30), |
63 | | op_nbpas integer, |
64 | | op_effort numeric, |
65 | | op_densite numeric, |
66 | | op_nbtot numeric, |
67 | | op_nbp1 numeric, |
68 | | op_nbp2 numeric, |
69 | | op_nbp3 numeric, |
70 | | op_nb150 numeric, |
71 | | op_nb150_300 numeric, |
72 | | op_nb300_450 numeric, |
73 | | op_nb_450_600 numeric, |
74 | | op_nb_600 numeric, |
75 | | op_glass_eel_transport boolean); |
| 53 | op_date date, |
| 54 | op_st_id character varying(10), |
| 55 | op_op_id character varying(10) primary key, |
| 56 | st_x numeric, |
| 57 | st_y numeric, |
| 58 | st_z numeric, |
| 59 | st_pk_des numeric, |
| 60 | op_surf numeric, |
| 61 | op_methodest character varying(30), |
| 62 | op_fishingobj character varying(30), |
| 63 | op_nbpas integer, |
| 64 | op_effort numeric, |
| 65 | op_densite numeric, |
| 66 | op_nbtot numeric, |
| 67 | op_nbp1 numeric, |
| 68 | op_nbp2 numeric, |
| 69 | op_nbp3 numeric, |
| 70 | op_nb150 numeric, |
| 71 | op_nb150_300 numeric, |
| 72 | op_nb300_450 numeric, |
| 73 | op_nb_450_600 numeric, |
| 74 | op_nb_600 numeric, |
| 75 | op_glass_eel_transport boolean); |
| 78 | alter table oria.operation_op drop column st_x; |
| 79 | alter table oria.operation_op drop column st_y ; |
| 80 | alter table oria.operation_op drop column st_z ; |
| 81 | alter table oria.operation_op drop column st_pk_des ; |
| 82 | -- projection sur le SRID 3035 |
| 83 | SELECT AddGeometryColumn('oria', 'estaciones_st','the_geom', 3035,'POINT',2); |
| 84 | UPDATE oria.estaciones_st SET the_geom=ST_Transform(PointFromText('POINT(' || st_x || ' ' || st_y || ')',23030),3035); |
| 85 | ALTER TABLE oria.estaciones_st SET WITH OIDS; |
| 86 | |
| 87 | CREATE INDEX indexestaciones_st ON oria.estaciones_st |
| 88 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |
| 89 | |
| 90 | -- capture des stations de pêche |
| 91 | DROP TABLE IF EXISTS oria.oria_ccm_500; |
| 92 | CREATE TABLE oria.oria_ccm_500 as ( |
| 93 | SELECT distinct on (st_id ) st_id , gid, wso1_id, min(distance) as distance, the_geom FROM ( |
| 94 | SELECT st_id, gid , wso1_id, CAST(distance(r.the_geom, s.the_geom) as decimal(15,1)) as distance,s.the_geom |
| 95 | FROM oria.estaciones_st As s |
| 96 | INNER JOIN ccm21.riversegments r ON ST_DWithin(r.the_geom, s.the_geom,500) |
| 97 | WHERE s.the_geom IS NOT NULL |
| 98 | ORDER BY st_id) AS sub |
| 99 | GROUP BY st_id, gid, wso1_id, distance,the_geom |
| 100 | ); |
| 101 | alter table oria.oria_ccm_500 add column id serial; |
| 102 | -- mise à jour de la table geometry_columns |
| 103 | INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") |
| 104 | SELECT '', 'oria', 'oria_ccm_500', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) |
| 105 | FROM oria.oria_ccm_500 LIMIT 1; |
| 106 | |
| 107 | -- creation d'index, clé primaire, et constraintes qui vont bien |
| 108 | alter table oria.oria_ccm_500 add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); |
| 109 | alter table oria.oria_ccm_500 add CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); |
| 110 | alter table oria.oria_ccm_500 add CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); |
| 111 | alter table oria.oria_ccm_500 ADD CONSTRAINT pk_id PRIMARY KEY(id); |
| 112 | CREATE INDEX indexoria_ccm_500 ON oria.oria_ccm_500 |
| 113 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |