Guest User

Untitled

a guest
Jul 2nd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.98 KB | None | 0 0
  1. #IMPORT DES SHAPES:
  2. ogr2ogr -f "PostgreSQL" C:\lupsig\ptut\DATA\ign\CHEMIN\CHEMIN.shp PG:"host=localhost user=postgres dbname=postgis password=tintin17" "CHEMIN"
  3. shp2pgsql.exe -s 2154 -D -c C:\lupsig\ptut\canton\canton.shp canton| psql postgis
  4.  
  5. shp2pgsql -s 4326 -D -c C:\lupsig\ptut\DATA\osm\aquitaine.shapefiles\HIGHWAY\aquitaine_highway.shp highway| psql routing
  6.  
  7. #CONFIG POSTGRE:
  8. psql -d routing -f postgis.SQL
  9. psql -d routing -f C:\tmp\spatial_ref_sys.SQL
  10. psql -d routing -f C:\tmp\routing.SQL
  11. psql -d routing -f C:\tmp\routing_postgis.SQL
  12.  
  13.  
  14. /* modifier un jeu de donnees vite fai pour utiliser l'algo dijkstra */
  15.  
  16. /*création topologie réseau*/
  17. ALTER TABLE troncon_route ADD COLUMN SOURCE INTEGER;
  18. ALTER TABLE troncon_route ADD COLUMN target INTEGER;
  19. ALTER TABLE  troncon_route ADD COLUMN cost DOUBLE PRECISION;
  20. UPDATE troncon_route SET cost=LENGTH(geom);
  21.  
  22. SELECT assign_vertex_id('troncon_route', 0.00001, 'geom', 'gid');
  23.  
  24. /*création des index*/
  25. CREATE INDEX source_idx ON troncon_route(SOURCE);
  26. CREATE INDEX target_idx ON troncon_route(target);
  27. CREATE INDEX geom_idx ON troncon_route USING GIST(geom GIST_GEOMETRY_OPS);
  28.  
  29. /*requete de recherche du + court chemin  avec la core function*/
  30. SELECT * FROM shortest_path('SELECT source, gid as id, target, cost FROM troncon_route;',1,13,FALSE,FALSE);
  31.  
  32. /*la meme fct mais en utilisant la core function */
  33. SELECT * FROM shortest_path('SELECT gid as id,
  34. source::integer,
  35. target::integer,
  36. cost::double precision
  37. FROM troncon_route',
  38. 2, 10, FALSE, FALSE);
  39.  
  40. /* avec un wrapper  => DIJKRRA SSANS BOITE ENGLOBANTE (attention jai change le nom de qlq colonnes ) */
  41. SELECT gid,AsText(the_geom) AS the_geom
  42. FROM dijkstra_sp('troncon_route', 1, 13);
  43.  
  44. /* avec un wrapper ET une boite englobante */
  45. /*Note: The projection of OSM data is “degree”, so we set a bounding box containing start and end vertex plus a
  46. 0.1 degree buffer for example.*/
  47. SELECT gid, AsText(the_geom) AS the_geom
  48. FROM dijkstra_sp_delta('troncon_route', 1,13, 0.1);
Add Comment
Please, Sign In to add comment