Skip to content

Commit 43aa2ec

Browse files
authored
Merge pull request #91 from omshinde/fix-issue-87-51
Fixes issue #87
2 parents 4512d1b + fdf94b4 commit 43aa2ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1482
-728
lines changed

REQUIREMENTS.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
Sphinx==1.6.5
2-
sphinx-intl==0.9.11
3-
transifex-client==0.13.4
4-
#twitter==1.10.2
5-
sphinxcontrib-images==0.7.0
6-
sphinx_bootstrap_theme==0.4
2+
sphinx-intl>=0.9.11
3+
sphinx_bootstrap_theme>=0.4
4+
wheel>=0.33.6

Readme.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
# pgRouting Workshop
2+
## Requirements
23

3-
## Install
4+
* python
45

5-
For building HTML documentation you need the following packages:
6+
## Working virtual environment
67

7-
```bash
8-
sudo apt update
9-
sudo apt install cmake python-pip
10-
sudo pip install -r REQUIREMENTS.txt
11-
```
12-
13-
For building the documentation as PDF the following packages need to be installed:
14-
15-
```bash
16-
sudo apt install texlive-latex-extra
17-
```
8+
```
9+
python3 -m venv py-env
10+
source py-env/bin/activate
11+
pip install -r REQUIREMENTS.txt
12+
```
13+
* If you are using Python 3, then you should already have the venv module from the standard library installed. If you don't have it then do:
1814

19-
For translations (needs to be confirmed):
20-
21-
```bash
22-
sudo apt install texinfo
23-
```
15+
``` sudo apt-get install python3-venv ```
2416

2517
## Build
2618

27-
To build the workshop documentation with all further steps, go into `docs` directory and run::
19+
### Build the workshop:
2820

2921
```bash
3022
cd docs
3123
make html
3224
```
25+
### Building PDF
26+
27+
Install prerequisite:
28+
```bash
29+
sudo apt-get install texlive-latex-extra
30+
```
3331

3432
To build the documentation as PDF:
3533

@@ -48,3 +46,4 @@ This workshop is licensed under a [Creative Commons Attribution-Share Alike 3.0
4846

4947
* [Georepublic](https://georepublic.info)
5048
* [iMaptools](http://imaptools.com)
49+
* [Paragon Corporation](https://www.paragoncorporation.com)

boost_example.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
..
2+
****************************************************************************
3+
pgRouting Workshop Manual
4+
Copyright(c) pgRouting Contributors
5+
6+
This documentation is licensed under a Creative Commons Attribution-Share
7+
Alike 3.0 License: http://creativecommons.org/licenses/by-sa/3.0/
8+
****************************************************************************
9+
10+
Boost Dijkstra Example
11+
===============================================================================
12+
13+
Using, pgRouting you can translate `C++ dijkstra code <http://www.boost.org/doc/libs/1_59_0/libs/graph/example/dijkstra-example.cpp>`_ into SQL commands.
14+
15+
.. rubric:: Boost Code
16+
17+
.. code-block:: cpp
18+
19+
const int num_nodes = 5;
20+
enum nodes { A, B, C, D, E }; = 1
21+
char name[] = "ABCDE";
22+
Edge edge_array[] = { Edge(A, C), Edge(B, B), Edge(B, D), Edge(B, E),
23+
Edge(C, B), Edge(C, D), Edge(D, E), Edge(E, A), Edge(E, B)
24+
};
25+
int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 };
26+
27+
Here is the tranlasted SQL commands.
28+
29+
.. rubric:: Translated Code
30+
31+
.. code-block:: sql
32+
33+
DROP TABLE IF EXISTS table1;
34+
CREATE TABLE table1 (
35+
id SERIAL,
36+
source INTEGER,
37+
target INTEGER,
38+
source_name TEXT,
39+
target_name TEXT,
40+
cost FLOAT
41+
);
42+
DROP TABLE IF EXISTS table1_vertices;
43+
CREATE TABLE table1_vertices (
44+
vid SERIAL,
45+
name TEXT
46+
);
47+
48+
INSERT INTO table1_vertices (name) VALUES ('A');
49+
INSERT INTO table1_vertices (name) VALUES ('B');
50+
INSERT INTO table1_vertices (name) VALUES ('C');
51+
INSERT INTO table1_vertices (name) VALUES ('D');
52+
INSERT INTO table1_vertices (name) VALUES ('E');
53+
54+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('A', 'C', 1);
55+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('B', 'B', 2);
56+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('B', 'D', 1);
57+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('B', 'E', 2);
58+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('C', 'B', 7);
59+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('C', 'D', 3);
60+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('D', 'E', 1);
61+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('E', 'A', 1);
62+
INSERT INTO table1 (source_name, target_name, cost) VALUES ('E', 'B', 1);
63+
64+
UPDATE table1
65+
SET source = table1_vertices.vid
66+
FROM table1_vertices
67+
WHERE source_name = name;
68+
69+
UPDATE table1 SET target = table1_vertices.vid
70+
FROM table1_vertices
71+
WHERE target_name = name;
72+
73+
-- Their output starts with 0 so we subtract 1 to the vid
74+
-- pgrouting: no paths or 0 length (aka I am there, so no path) are not included
75+
SELECT end_vid-1, agg_cost FROM pgr_dijkstra(
76+
'SELECT id, source, target, cost FROM table1',
77+
1, ARRAY[1, 2, 3, 4, 5], true) where edge < 0 order by end_vid;
78+
79+
Output from running the following SQL command:
80+
81+
.. rubric:: Output
82+
83+
.. code-block:: sql
84+
85+
?column? | agg_cost
86+
----------+----------
87+
1 | 6
88+
2 | 1
89+
3 | 4
90+
4 | 5
91+
(4 rows)

0 commit comments

Comments
 (0)