Changes between Version 5 and Version 6 of OriaEda


Ignore:
Timestamp:
Nov 23, 2010 9:14:40 AM (14 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OriaEda

    v5 v6  
    1212-- Une table pour les vues dans Qgis 
    1313create table ccm21.riversegments_spain as ( 
    14         select * from ccm21.riversegments where wso_id in ((select wso_id from europe.wso where area='Spain' 
     14        select * from ccm21.riversegments where wso_id in ((select wso_id from europe.wso where area='Spain' 
    1515except (select  wso_id  from europe.wso where area='France')) --2339 
    1616intersect (select wso_id from ccm21.seaoutlets where area_cd='A1'))); --348); 
     
    3434drop table if exists oria.estaciones_st; 
    3535create table oria.estaciones_st (   
    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); 
    4747alter table oria.estaciones_st add constraint  pk_st_id primary key (st_id); 
    4848set client_encoding to 'latin1'; 
     
    5151drop table if exists oria.operation_op; 
    5252create table oria.operation_op ( 
    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); 
    7676alter table oria.operation_op add constraint  fk_op_st_id foreign key (op_st_id) references oria.estaciones_st(st_id); 
    7777copy oria.operation_op  from 'c:/base/operation.csv' with csv delimiter as ';' header;  
     78alter table oria.operation_op drop column  st_x; 
     79alter table oria.operation_op drop column         st_y ; 
     80alter table oria.operation_op drop column         st_z ; 
     81alter table oria.operation_op drop column         st_pk_des ; 
     82-- projection sur le SRID 3035 
     83SELECT AddGeometryColumn('oria', 'estaciones_st','the_geom', 3035,'POINT',2);  
     84UPDATE oria.estaciones_st   SET the_geom=ST_Transform(PointFromText('POINT(' || st_x || ' ' || st_y || ')',23030),3035); 
     85ALTER TABLE oria.estaciones_st SET WITH OIDS; 
     86 
     87CREATE INDEX indexestaciones_st ON oria.estaciones_st 
     88  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
     89 
     90-- capture des stations de pêche 
     91DROP TABLE IF EXISTS oria.oria_ccm_500; 
     92CREATE 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); 
     101alter table oria.oria_ccm_500 add column id serial; 
     102-- mise à jour de la table geometry_columns 
     103INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     104SELECT '', 'oria', 'oria_ccm_500', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     105FROM oria.oria_ccm_500 LIMIT 1; 
     106 
     107-- creation d'index, clé primaire, et constraintes qui vont bien 
     108alter table oria.oria_ccm_500 add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 
     109alter table oria.oria_ccm_500 add  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); 
     110alter table oria.oria_ccm_500 add  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 
     111alter table oria.oria_ccm_500 ADD CONSTRAINT pk_id PRIMARY KEY(id); 
     112CREATE INDEX indexoria_ccm_500 ON oria.oria_ccm_500 
     113  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
    78114}}}