Changes between Version 98 and Version 99 of CookBook join BDMAP_CCM


Ignore:
Timestamp:
May 24, 2010 10:07:24 PM (15 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBook join BDMAP_CCM

    v98 v99  
    230230{{{ 
    231231#!sql 
    232 -- creation de la table correspondance, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis   
    233 DROP TABLE IF EXISTS bd_map.correspondance; 
    234 CREATE TABLE bd_map.correspondance as ( 
     232-- creation de la table bdmap_ccm, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis   
     233DROP TABLE IF EXISTS bd_map.bdmap_ccm; 
     234CREATE TABLE bd_map.bdmap_ccm as ( 
    235235        SELECT distinct on (st_codecsp) st_codecsp, gid, min(distance) as distance, the_geom FROM ( 
    236236               SELECT st_codecsp, gid ,CAST(distance(r.the_geom, s.the_geom) as  decimal(15,1)) as distance,s.the_geom  
     
    241241        GROUP BY st_codecsp, distance,gid, the_geom 
    242242); 
    243 alter table bd_map.correspondance add column id serial; 
     243alter table bd_map.bdmap_ccm add column id serial; 
    244244-- mise à jour de la table geometry_columns 
    245245INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") 
    246 SELECT '', 'bd_map', 'correspondance', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
    247 FROM bd_map.correspondance LIMIT 1; 
     246SELECT '', 'bd_map', 'bdmap_ccm', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 
     247FROM bd_map.bdmap_ccm LIMIT 1; 
    248248 
    249249-- creation d'index, clé primaire, et constraintes qui vont bien 
    250 alter table bd_map.correspondance add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 
    251 alter table bd_map.correspondance add  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); 
    252 alter table bd_map.correspondance add  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 
    253 alter table bd_map.correspondance ADD CONSTRAINT pk_id PRIMARY KEY(id); 
    254 CREATE INDEX indexcorrespondance ON bd_map.correspondance 
     250alter table bd_map.bdmap_ccm add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 
     251alter table bd_map.bdmap_ccm add  CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); 
     252alter table bd_map.bdmap_ccm add  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 
     253alter table bd_map.bdmap_ccm ADD CONSTRAINT pk_id PRIMARY KEY(id); 
     254CREATE INDEX indexbdmap_ccm ON bd_map.bdmap_ccm 
    255255  USING GIST ( the_geom GIST_GEOMETRY_OPS ); 
    256256 
     
    259259{{{ 
    260260#!sql 
    261 select count(*) from bd_map.correspondance ;--9272 -- 8884 a 300m 
     261select count(*) from bd_map.bdmap_ccm ;--9272 -- 8884 a 300m 
    262262select count(*) from bd_map.stationsp2 ;--10203 
    263263select 100*9272 /10203::float 
    264264select 100*8884 /10203::float--87.07 
    265 alter table bd_map.correspondance add column id serial; 
    266 }}} 
    267 Below in red old stations not in bd_map.correspondance, green new stations without correspondance, purple correspondance successfull, the map is centered on the Vilaine... 
     265alter table bd_map.bdmap_ccm add column id serial; 
     266}}} 
     267Below in red old stations not in bd_map.bdmap_ccm, green new stations without correspondance, purple correspondance successfull, the map is centered on the Vilaine... 
    268268[[Image(source:data/Docs/trac/jointure_ccm_eda.jpg,600px)]]