pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

yancho private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Yancho on Sat 15 Mar 10:50
report abuse | download | new post

  1. CREATE OR REPLACE FUNCTION near_accident(text, text)
  2.   RETURNS text AS
  3. $BODY$
  4.  
  5.         DECLARE
  6.                 pojnt ALIAS FOR $1;
  7.                 tejbil ALIAS FOR $2;
  8.                 distances RECORD;
  9.                 hospital RECORD;
  10.                 nearest RECORD;
  11.                 silect TEXT;
  12.                
  13.                 sorc INTEGER;
  14.                 targit INTEGER;
  15.  
  16.         BEGIN
  17.                
  18.                 SELECT 'inf'::float8 AS dist, NULL::text AS gid INTO nearest;
  19.          
  20. raise notice 'Point is %', pojnt;    
  21. SELECT give_target(pojnt,1000,200) INTO targit;
  22. raise notice 'value of target : %',targit;
  23.  
  24. raise notice '-----------------------------------------------';
  25.         -- raise notice 'Entering the FOR IN %', timeofday() ;
  26.  
  27.         silect := ' select astext(h.the_geom) as hospital_location from '|| tejbil ||' h where
  28.                                          (
  29.                                          h.the_geom && expand (pointfromtext('|| quote_literal(pojnt) ||'),100000) and
  30.                                          distance ( h.the_geom , pointfromtext('|| quote_literal(pojnt) ||') ) < 150000
  31.                                          )
  32.                                     order by distance (h.the_geom , pointfromtext('|| quote_literal(pojnt) ||')) ASC
  33.                                     limit 3 ';
  34.        
  35.  
  36.                FOR distances IN
  37.                                         EXECUTE silect
  38.  
  39.  
  40.                
  41.                 LOOP
  42.  
  43. raise notice '=====================================================';   
  44.  raise notice 'point location of hospital : %', distances.hospital_location;   
  45.  
  46.  
  47.  
  48.  -- raise notice 'before give source : %', timeofday();
  49. SELECT give_source(distances.hospital_location,1000,200) INTO sorc;
  50. raise notice 'value of sorc : %', sorc;
  51.  --  raise notice 'after give source : %', timeofday();
  52.   -- raise notice 'before give target : %', timeofday();
  53.  
  54.  --  raise notice 'after give target : %', timeofday();
  55.          --  raise notice 'entering shooting star %', timeofday() ;     
  56.                
  57.                 SELECT gid, the_geom, length(the_geom) AS dist INTO hospital FROM shootingstar_sp
  58.                               ( 'streets',
  59.                                    
  60.                                     (
  61.                                         SELECT s.gid FROM streets s WHERE
  62.                                         source = (sorc)
  63.                                         LIMIT 1
  64.  
  65.  
  66.                                     )
  67.  
  68.                                     ,
  69.  
  70.                                     (
  71.                                         SELECT gid FROM streets WHERE
  72.                                         target = ( targit)
  73.                                         LIMIT 1
  74.  
  75.                                     )
  76.                                    
  77.                                     ,
  78.                                    5000,
  79.                                    'rcost',
  80.                                    true,
  81.                                    true
  82.                               );
  83.          
  84.           raise notice 'Hospital Distance %', hospital.dist ;            
  85.  
  86.                       IF hospital.dist < nearest.dist  THEN
  87.                           nearest.dist := hospital.dist;
  88.          raise notice 'value of nearest.dist is %', nearest.dist;
  89.          raise notice 'value of hospital.gid is %', hospital.gid;
  90.         raise notice 'value of nearest.gid is %', nearest.gid;
  91.                           nearest.gid := distances.hospital_location;
  92.         raise notice 'value of 2ND nearest.gid is %', nearest.gid;
  93.  
  94.                       END IF;
  95.           -- raise notice 'after if %', timeofday() ;
  96.           -- raise notice 'before end of loop %', timeofday() ;
  97.                      
  98.                END LOOP;
  99.  --     raise notice 'after end of loop before returning %', timeofday() ;      
  100.                RETURN nearest.gid;
  101.              
  102.         END;
  103.         $BODY$
  104.   LANGUAGE 'plpgsql' VOLATILE;
  105. ALTER FUNCTION near_accident(text, text) OWNER TO yancho;

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post