Changes between Version 30 and Version 31 of CookBook join ROE_CCM


Ignore:
Timestamp:
Mar 23, 2010 7:43:43 AM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBook join ROE_CCM

    v30 v31  
    123123 
    124124== Joining CCM and Dams == 
    125 this is ticket #47 
     125 
     126-- Création d'un index sur obstacle_referentiel 
     127 
     128-- Création de la table correspondance, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis  
     129CREATE INDEX indexgeobs ON geobs.obstacle_referentiel  USING GIST (ref_position_etrs89 GIST_GEOMETRY_OPS); 
     130DROP TABLE IF EXISTS geobs.correspondance; 
     131CREATE TABLE geobs.correspondance as ( 
     132        SELECT distinct on (ref_id) ref_id, gid, min(distance) as distance, ref_position_etrs89 as the_geom FROM ( 
     133               SELECT ref_id, gid ,CAST(distance(r.the_geom, b.ref_position_etrs89) as  decimal(15,1)) as distance ,b.ref_position_etrs89 
     134               FROM geobs.obstacle_referentiel As b 
     135               INNER JOIN  riversegments r ON ST_DWithin(r.the_geom, b.ref_position_etrs89,300) 
     136               WHERE b.goodproj IS TRUE 
     137               ORDER BY ref_id) AS sub  
     138        GROUP BY ref_id, gid, the_geom 
     139); --53s 
     140alter table geobs.correspondance add column id serial PRIMARY KEY; 
     141-- mise à jour de la table geometry_columns 
     142INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     143SELECT '', 'public', 'correspondance', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     144FROM correspondance LIMIT 1; 
     145 
     146-- creation d'index, clé primaire, et constraintes qui vont bien 
     147alter table correspondance add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 
     148alter table correspondance add  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); 
     149alter table correspondance add  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 
     150 
     151alter table correspondance ADD CONSTRAINT pk_id PRIMARY KEY(id); 
     152CREATE INDEX indexcorrespondance ON correspondance 
     153  USING GIST ( the_geom GIST_GEOMETRY_OPS );