Changeset 47
- Timestamp:
- 10/04/07 13:08:19 (1 year ago)
- Files:
-
- trunk/core/sql/routing_core_wrappers.sql (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/core/sql/routing_core_wrappers.sql
r43 r47 29 29 -- BEGIN; 30 30 31 CREATE OR REPLACE FUNCTION text(boolean) 32 RETURNS text AS 33 $$ 34 SELECT CASE WHEN $1 THEN 'true' ELSE 'false' END 35 $$ 36 LANGUAGE 'sql'; 37 31 38 ----------------------------------------------------------------------- 32 39 -- For each vertex in the vertices table, set a point geometry which is … … 124 131 BEGIN 125 132 126 BEGIN127 DROP TABLE vertices_tmp;128 EXCEPTION129 WHEN UNDEFINED_TABLE THEN130 END;133 -- BEGIN 134 -- DROP TABLE vertices_tmp; 135 -- EXCEPTION 136 -- WHEN UNDEFINED_TABLE THEN 137 -- END; 131 138 132 CREATE TABLE vertices_tmp ( id serial );139 EXECUTE 'CREATE TABLE vertices_tmp (id serial)'; 133 140 134 135 141 FOR i IN EXECUTE 'SELECT srid FROM geometry_columns WHERE f_table_name='''|| quote_ident(geom_table)||'''' LOOP 136 142 END LOOP; … … 141 147 142 148 CREATE INDEX vertices_tmp_idx ON vertices_tmp USING GIST (the_geom); 143 149 144 150 pre = ''; 145 151 post = ''; … … 152 158 END LOOP; 153 159 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 -- 154 165 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' 157 168 || ' FROM ' || quote_ident(geom_table) loop 158 169 … … 160 171 target_id := point_to_id(setsrid(points.target, srid), tolerance); 161 172 173 162 174 EXECUTE 'update ' || quote_ident(geom_table) || 163 175 ' SET source = ' || source_id || … … 274 286 275 287 query := query || 'FROM ' || quote_ident(geom_table) || ''', ' || quote_literal(source) || 276 ' , ' || quote_literal(target) || ' , '''|| dir||''', '''||rc||'''), ' ||288 ' , ' || quote_literal(target) || ' , '''||text(dir)||''', '''||text(rc)||'''), ' || 277 289 quote_ident(geom_table) || ' where edge_id = gid '; 278 290 … … 463 475 ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' || 464 476 quote_literal(sourceid) || ' , ' || 465 quote_literal(targetid) || ' , '''|| dir||''', '''||rc||''' ),' ||477 quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' || 466 478 quote_ident(geom_table) || ' where edge_id = gid '; 467 479 … … 649 661 ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' || 650 662 quote_literal(sourceid) || ' , ' || 651 quote_literal(targetid) || ' , '''|| dir||''', '''||rc||''' ),' ||663 quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' || 652 664 quote_ident(geom_table) || ' where edge_id = gid '; 653 665 … … 818 830 ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' || 819 831 quote_literal(sourceid) || ' , ' || 820 quote_literal(targetid) || ' , '''|| dir||''', '''||rc||''' ), ' ||832 quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ), ' || 821 833 quote_ident(geom_table) || ' where edge_id = gid '; 822 834 … … 933 945 ll_y||','||ur_x||' '||ur_y||')''''::BOX3D, ' || srid || 934 946 ') && the_geom'', ' || quote_literal(sourceid) || ' , ' || 935 quote_literal(targetid) || ' , '''|| dir||''', '''||rc||''' ),' ||947 quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' || 936 948 quote_ident(geom_table) || ' where edge_id = gid '; 937 949 … … 1014 1026 query := query || 'FROM ' || quote_ident(geom_table) || ' '', ' || 1015 1027 quote_literal(source) || ' , ' || 1016 quote_literal(target) || ' , '''|| dir||''', '''||rc||'''), ' ||1028 quote_literal(target) || ' , '''||text(dir)||''', '''||text(rc)||'''), ' || 1017 1029 quote_ident(geom_table) || ' where edge_id = gid '; 1018 1030 … … 1143 1155 ur_y+delta||')''''::BOX3D, ' || srid || ') && the_geom'', ' || 1144 1156 quote_literal(sourceid) || ' , ' || 1145 quote_literal(targetid) || ' , '''|| dir||''', '''||rc||''' ),' ||1157 quote_literal(targetid) || ' , '''||text(dir)||''', '''||text(rc)||''' ),' || 1146 1158 quote_ident(geom_table) || ' where edge_id = gid '; 1147 1159

