Changes between Version 98 and Version 99 of CookBook join BDMAP_CCM
- Timestamp:
- May 24, 2010 10:07:24 PM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBook join BDMAP_CCM
v98 v99 230 230 {{{ 231 231 #!sql 232 -- creation de la table correspondance, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis233 DROP TABLE IF EXISTS bd_map. correspondance;234 CREATE TABLE bd_map. correspondanceas (232 -- creation de la table bdmap_ccm, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis 233 DROP TABLE IF EXISTS bd_map.bdmap_ccm; 234 CREATE TABLE bd_map.bdmap_ccm as ( 235 235 SELECT distinct on (st_codecsp) st_codecsp, gid, min(distance) as distance, the_geom FROM ( 236 236 SELECT st_codecsp, gid ,CAST(distance(r.the_geom, s.the_geom) as decimal(15,1)) as distance,s.the_geom … … 241 241 GROUP BY st_codecsp, distance,gid, the_geom 242 242 ); 243 alter table bd_map. correspondanceadd column id serial;243 alter table bd_map.bdmap_ccm add column id serial; 244 244 -- mise à jour de la table geometry_columns 245 245 INSERT 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. correspondanceLIMIT 1;246 SELECT '', 'bd_map', 'bdmap_ccm', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) 247 FROM bd_map.bdmap_ccm LIMIT 1; 248 248 249 249 -- creation d'index, clé primaire, et constraintes qui vont bien 250 alter table bd_map. correspondanceadd CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2);251 alter table bd_map. correspondanceadd CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL);252 alter table bd_map. correspondanceadd CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035);253 alter table bd_map. correspondanceADD CONSTRAINT pk_id PRIMARY KEY(id);254 CREATE INDEX index correspondance ON bd_map.correspondance250 alter table bd_map.bdmap_ccm add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); 251 alter table bd_map.bdmap_ccm add CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); 252 alter table bd_map.bdmap_ccm add CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); 253 alter table bd_map.bdmap_ccm ADD CONSTRAINT pk_id PRIMARY KEY(id); 254 CREATE INDEX indexbdmap_ccm ON bd_map.bdmap_ccm 255 255 USING GIST ( the_geom GIST_GEOMETRY_OPS ); 256 256 … … 259 259 {{{ 260 260 #!sql 261 select count(*) from bd_map. correspondance;--9272 -- 8884 a 300m261 select count(*) from bd_map.bdmap_ccm ;--9272 -- 8884 a 300m 262 262 select count(*) from bd_map.stationsp2 ;--10203 263 263 select 100*9272 /10203::float 264 264 select 100*8884 /10203::float--87.07 265 alter table bd_map. correspondanceadd 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...265 alter table bd_map.bdmap_ccm add column id serial; 266 }}} 267 Below 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... 268 268 [[Image(source:data/Docs/trac/jointure_ccm_eda.jpg,600px)]]