| 1 | back to first page[..][[BR]] |
| 2 | back to ["RHT"][[BR]] |
| 3 | |
| 4 | A FINIR |
| 5 | {{{ |
| 6 | -- creation de la table noeudbdcarthage_rht_roe, je rajoute un the_geom a la requete pour pouvoir voir la table dans Qgis |
| 7 | DROP TABLE IF EXISTS rht.noeudbdcarthage_rht_roe; |
| 8 | CREATE TABLE rht.noeudbdcarthage_rht_roe as ( |
| 9 | SELECT distinct on (id_bdcarth) id_bdcarth, id_drain, min(distance) as distance, the_geom FROM ( |
| 10 | SELECT id_bdcarth, s.gid, id_drain ,CAST(distance(r.the_geom, s.the_geom) as decimal(15,1)) as distance,s.the_geom |
| 11 | FROM bd_carthage2011.noeud_hydrographique As s |
| 12 | INNER JOIN rht.rht_roev2 r ON ST_DWithin(r.the_geom, s.the_geom,300) |
| 13 | WHERE s.the_geom IS NOT NULL |
| 14 | ORDER BY id_bdcarth) AS sub |
| 15 | GROUP BY id_bdcarth, distance,id_drain, gid, the_geom |
| 16 | ); |
| 17 | alter table rht.noeudbdcarthage_rht_roe add column id serial; |
| 18 | -- mise à jour de la table geometry_columns |
| 19 | INSERT INTO geometry_columns(f_table_catalog, f_table_schema, f_table_name, f_geometry_column, coord_dimension, srid, "type") |
| 20 | SELECT '', 'rht', 'noeudbdcarthage_rht_roe', 'the_geom', ST_CoordDim(the_geom), ST_SRID(the_geom), GeometryType(the_geom) |
| 21 | FROM rht.noeudbdcarthage_rht_roe LIMIT 1; |
| 22 | |
| 23 | -- creation d'index, clé primaire, et constraintes qui vont bien |
| 24 | alter table rht.noeudbdcarthage_rht_roe add CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2); |
| 25 | alter table rht.noeudbdcarthage_rht_roe add CONSTRAINT enforce_geotype_the_geom CHECK (geometrytype(the_geom) = 'POINT'::text OR the_geom IS NULL); |
| 26 | alter table rht.noeudbdcarthage_rht_roe add CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 3035); |
| 27 | alter table rht.noeudbdcarthage_rht_roe ADD CONSTRAINT pk_id PRIMARY KEY(id); |
| 28 | CREATE INDEX indexbdmap_rht ON rht.bdmap_rht |
| 29 | USING GIST ( the_geom GIST_GEOMETRY_OPS ); |
| 30 | }}} |