pgRouting

Changeset 47

Show
Ignore:
Timestamp:
10/04/07 13:08:19 (1 year ago)
Author:
anton
Message:

PostgreSQL 8.2.5 support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/core/sql/routing_core_wrappers.sql

    r43 r47  
    2929-- BEGIN; 
    3030 
     31CREATE OR REPLACE FUNCTION text(boolean) 
     32       RETURNS text AS 
     33$$ 
     34SELECT CASE WHEN $1 THEN 'true' ELSE 'false' END 
     35$$ 
     36LANGUAGE 'sql'; 
     37 
    3138----------------------------------------------------------------------- 
    3239-- For each vertex in the vertices table, set a point geometry which is 
     
    124131      BEGIN 
    125132                                         
    126           BEGIN 
    127               DROP TABLE vertices_tmp; 
    128               EXCEPTION  
    129                       WHEN UNDEFINED_TABLE THEN 
    130                 END; 
     133--        BEGIN 
     134--            DROP TABLE vertices_tmp; 
     135--            EXCEPTION  
     136--                    WHEN UNDEFINED_TABLE THEN 
     137--                END; 
    131138                                                                     
    132                 CREATE TABLE vertices_tmp ( id serial );       
     139                EXECUTE 'CREATE TABLE vertices_tmp (id serial)';       
    133140                                                                         
    134                  
    135141                FOR i IN EXECUTE 'SELECT srid FROM geometry_columns WHERE f_table_name='''|| quote_ident(geom_table)||'''' LOOP 
    136142                END LOOP; 
     
    141147                                                                                                                          
    142148                CREATE INDEX vertices_tmp_idx ON vertices_tmp USING GIST (the_geom); 
    143                                                                                                                              
     149                 
    144150                pre = ''; 
    145151                post = ''; 
     
    152158                END LOOP; 
    153159                                                                                                                                                                                             
     160--              FOR points IN EXECUTE 'SELECT ' || quote_ident(gid_cname) || ' AS id,' 
     161--                      || ' startPoint(' || pre || quote_ident(geo_cname) || post || ') AS source,' 
     162--                      || ' endPoint(' || pre || quote_ident(geo_cname) || post || ') as target' 
     163--                      || ' FROM ' || quote_ident(geom_table) loop 
     164-- 
    154165                FOR points IN EXECUTE 'SELECT ' || quote_ident(gid_cname) || ' AS id,' 
    155                         || ' startPoint(' || pre || quote_ident(geo_cname) || post || ') AS source,' 
    156                         || ' endPoint(' || pre || quote_ident(geo_cname) || post || ') as target' 
     166                        || ' PointN('|| quote_ident(geo_cname) ||', 1) AS source,' 
     167                        || ' PointN('|| quote_ident(geo_cname) ||', NumPoints('|| quote_ident(geo_cname) ||')) as target' 
    157168                        || ' FROM ' || quote_ident(geom_table) loop 
    158169 
     
    160171                                target_id := point_to_id(setsrid(points.target, srid), tolerance); 
    161172                                                                                                                                                                                                                                         
     173 
    162174                                EXECUTE 'update ' || quote_ident(geom_table) ||  
    163175                                    ' SET source = ' || source_id ||  
     
    274286         
    275287        query := query || 'FROM ' ||  quote_ident(geom_table) || ''', ' || quote_literal(source) ||  
    276           ' , ' || quote_literal(target) || ' , '''||dir||''', '''||rc||'''), ' ||  
     288          ' , ' || quote_literal(target) || ' , '''||text(dir)||''', '''||text(rc)||'''), ' ||  
    277289          quote_ident(geom_table) || ' where edge_id = gid '; 
    278290 
     
    463475          ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' ||  
    464476          quote_literal(sourceid) || ' , ' ||  
    465           quote_literal(targetid) || ' , '''||dir||''', '''||rc||''' ),' ||  
     477          quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' ||  
    466478          quote_ident(geom_table) || ' where edge_id = gid '; 
    467479           
     
    649661          ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' ||  
    650662          quote_literal(sourceid) || ' , ' ||  
    651           quote_literal(targetid) || ' , '''||dir||''', '''||rc||''' ),' ||  
     663          quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' ||  
    652664          quote_ident(geom_table) || ' where edge_id = gid '; 
    653665         
     
    818830          ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' ||  
    819831          quote_literal(sourceid) || ' , ' ||  
    820           quote_literal(targetid) || ' , '''||dir||''', '''||rc||''' ), ' || 
     832          quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ), ' || 
    821833          quote_ident(geom_table) || ' where edge_id = gid '; 
    822834           
     
    933945           ll_y||','||ur_x||' '||ur_y||')''''::BOX3D, ' || srid ||  
    934946           ') && the_geom'', ' || quote_literal(sourceid) || ' , ' ||  
    935            quote_literal(targetid) || ' , '''||dir||''', '''||rc||''' ),'  || 
     947           quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),'  || 
    936948           quote_ident(geom_table) || ' where edge_id = gid '; 
    937949         
     
    10141026        query := query || 'FROM ' || quote_ident(geom_table) || ' '', ' ||  
    10151027           quote_literal(source) || ' , ' ||  
    1016            quote_literal(target) || ' , '''||dir||''', '''||rc||'''), ' || 
     1028           quote_literal(target) || ' , '''||text(dir)||''', '''||text(rc)||'''), ' || 
    10171029           quote_ident(geom_table) || ' where edge_id = gid '; 
    10181030            
     
    11431155          ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' ||  
    11441156          quote_literal(sourceid) || ' , ' ||  
    1145           quote_literal(targetid) || ' , '''||dir||''', '''||rc||''' ),' ||  
     1157          quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' ||  
    11461158          quote_ident(geom_table) || ' where edge_id = gid '; 
    11471159