Changes between Version 9 and Version 10 of Parcours source RHT


Ignore:
Timestamp:
Oct 26, 2011 12:15:20 PM (14 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Parcours source RHT

    v9 v10  
    1616VACUUM ANALYSE rht.rht_topology; 
    1717CREATE INDEX chemin_gist_index ON rht.rht_topology USING GIST (chemin); -- fait planter mon serveur.... 
    18 SELECT chemin from rht.rht_topology where chemin <@ '212340'; -- tronçon source de la Vilaine -- 2360 
     18SELECT * from rht.rht_topology where chemin <@ '212340'; -- tronçon source de la Vilaine -- 2360 
     19SELECT chemin from rht.rht_topology where chemin <@ '212340' limit 1 
     20-- La distance source est la distance mer maximale de tous les chemins possibles en ne prenant que le dernier tronçon du chemin. 
     21Select max(dmer) from rht.rht_topology where id_drain in ( 
     22Select cast(ltree2text(subpath(chemin, -1, 1))as integer) as chenin_id_drain from rht.rht_topology where chemin <@ '212340'); 
     23 
     24--  fonction pour renvoyer les distances source 
     25DROP FUNCTION IF EXISTS rht.distance_source(); 
     26CREATE OR REPLACE FUNCTION rht.distance_source() RETURNS integer AS $$ 
     27DECLARE 
     28    id_drains RECORD; 
     29    nbligne integer; 
     30BEGIN 
     31          nbligne:=1; 
     32          DROP TABLE IF EXISTS rht.distance_mer; 
     33          CREATE TABLE rht.distance_mer (id_drain integer,distance_mer  numeric); 
     34          FOR id_drains IN SELECT id_drain FROM rht.rht_topology ORDER BY id_drain LOOP 
     35                  -- pour vérification décommenter ensuite 
     36                  RAISE NOTICE 'distance_source for %', quote_ident(CAST(id_drains.id_drain as text)); 
     37                  EXECUTE 'INSERT INTO rht.distance_mer SELECT MAX(dmer) FROM rht.rht_topology WHERE id_drain IN ( 
     38                        SELECT CAST(ltree2text(subpath(chemin, -1, 1))as integer) FROM rht.rht_topology where chemin <@  text2ltree(cast ('|| 
     39                        id_drains.id_drain 
     40                        || 'as text)) )';   
     41                nbligne=nbligne+1;       
     42        END LOOP; 
     43    RETURN nbligne; 
     44END; 
     45$$ LANGUAGE plpgsql; 
     46 
     47select rht.distance_source(); 
    1948}}} 
    2049== utilisation des donnees de parcours ==