Changes between Version 13 and Version 14 of CookBook EpA


Ignore:
Timestamp:
Mar 30, 2010 2:24:02 PM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBook EpA

    v13 v14  
    4747= Projecting the files on the ccm = 
    4848 
     49 * first create two index to speed up queries 
     50 
     51 
     52{{{ 
     53CREATE INDEX indexiabret ON ia.iabret 
     54  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
     55CREATE INDEX indexiaiav ON ia.iaiav 
     56  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
     57}}} 
     58Joining the riversegment and stationsp2, the_geom is that of stationsp2 
     59 
     60-- creation de la table correspondance, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis   
     61DROP TABLE IF EXISTS bd_map.correspondance; 
     62CREATE TABLE bd_map.correspondance as ( 
     63        SELECT distinct on (st_codecsp) st_codecsp, gid, min(distance) as distance, the_geom FROM ( 
     64               SELECT st_codecsp, gid ,CAST(distance(r.the_geom, s.the_geom) as  decimal(15,1)) as distance,s.the_geom  
     65               FROM bd_map.stationsp2 As s 
     66               INNER JOIN  riversegments r ON ST_DWithin(r.the_geom, s.the_geom,300) 
     67               WHERE s.the_geom IS NOT NULL 
     68               ORDER BY st_codecsp) AS sub  
     69        GROUP BY st_codecsp, gid, the_geom 
     70); 
     71alter table bd_map.correspondance add column id serial; 
     72-- mise à jour de la table geometry_columns 
     73INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
     74SELECT '', 'bd_map', 'correspondance', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     75FROM bd_map.correspondance LIMIT 1; 
     76 
     77-- creation d'index, clé primaire, et constraintes qui vont bien 
     78alter table bd_map.correspondance add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 
     79alter table bd_map.correspondance add  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); 
     80alter table bd_map.correspondance add  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 
     81alter table bd_map.correspondance ADD CONSTRAINT pk_id PRIMARY KEY(id); 
     82CREATE INDEX indexcorrespondance ON bd_map.correspondance 
     83  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
     84