@@ -87,143 +87,156 @@ The output table will have for ``edge_table_noded``
8787Examples
8888-------------------------------------------------------------------------------
8989
90- Let's create the topology for the data in :doc: `sampledata `
90+ Create the topology for the data in :doc: `sampledata `
91+
92+ .. literalinclude :: sampledata.queries
93+ :start-after: -- q1
94+ :end-before: -- q1-1
95+
96+ .. literalinclude :: sampledata.queries
97+ :start-after: -- q3
98+ :end-before: -- q4
99+
100+ Analyze the network for intersections.
91101
92102.. literalinclude :: nodeNetwork.queries
93103 :start-after: --q1
94- :end-before: --q1.1
104+ :end-before: --q2
95105
96- Now we can analyze the network.
106+ Analyze the network for gaps .
97107
98108.. literalinclude :: nodeNetwork.queries
99109 :start-after: --q2
100- :end-before: --q2.1
110+ :end-before: --q3
101111
102- The analysis tell us that the network has a gap and an intersection. We try to
103- fix the problem using:
112+ The analysis tell us that the network has a gap and an intersection.
113+
114+ Fixing an intersection
115+ ...............................................................................
116+
117+ Storing the intersections.
104118
105119.. literalinclude :: nodeNetwork.queries
106120 :start-after: --q3
107- :end-before: --q3.1
121+ :end-before: --q4
108122
109- Inspecting the generated table, we can see that edges 13,14 and 18 has been
110- segmented
123+ Calling ``pgr_nodeNetwork ``.
111124
112125.. literalinclude :: nodeNetwork.queries
113126 :start-after: --q4
114- :end-before: --q4.1
127+ :end-before: --q5
115128
116- We can create the topology of the new network
129+ Inspecting the generated table, we can see that edges 13 and 18 has been
130+ segmented
117131
118132.. literalinclude :: nodeNetwork.queries
119133 :start-after: --q5
120- :end-before: --q5.1
134+ :end-before: --q6
135+
136+ .. rubric :: Update the topology
121137
122- Now let's analyze the new topology
138+ Add new segmentes to the edges table.
123139
124140.. literalinclude :: nodeNetwork.queries
125141 :start-after: --q6
126- :end-before: --q6.1
142+ :end-before: --q7
127143
128- Images
129- -------------------------------------------------------------------------------
144+ Insert the intersection as new vertices.
130145
131- .. Rubric :: Before Image
146+ .. literalinclude :: nodeNetwork.queries
147+ :start-after: --q7
148+ :end-before: --q8
132149
133- .. image :: images/before_node_net.png
134- :scale: 60%
135- :alt: Before image
136- :align: left
150+ Update source and target information on the edges table.
137151
152+ .. literalinclude :: nodeNetwork.queries
153+ :start-after: --q8
154+ :end-before: --q9
138155
139- .. Rubric :: After Image
156+ Delete original edge.
140157
141- .. image :: images/after_node_net.png
142- :scale: 60%
143- :alt: After image
144- :align: left
158+ .. literalinclude :: nodeNetwork.queries
159+ :start-after: --q9
160+ :end-before: --q10
145161
162+ Update the vertex topology
146163
147- Comparing the results
148- -------------------------------------------------------------------------------
164+ .. literalinclude :: nodeNetwork.queries
165+ :start-after: --q10
166+ :end-before: --q11
149167
150- Comparing with the Analysis in the original edge_table, we see that.
151-
152- +------------------+-----------------------------------------+--------------------------------------------------------------+
153- | | Before | After |
154- +==================+=========================================+==============================================================+
155- | Table name | edge_table | edge_table_noded |
156- +------------------+-----------------------------------------+--------------------------------------------------------------+
157- | Fields | All original fields | Has only basic fields to do a topology analysis |
158- +------------------+-----------------------------------------+--------------------------------------------------------------+
159- | Dead ends | - Edges with 1 dead end: 1,6,24 | Edges with 1 dead end: 1-1 ,6-1,14-2, 18-1 17-1 18-2 |
160- | | - Edges with 2 dead ends: 17,18 | |
161- | | | |
162- | | Edge 17's right node is a dead end | |
163- | | because there is no other edge sharing | |
164- | | that same node. (cnt=1) | |
165- +------------------+-----------------------------------------+--------------------------------------------------------------+
166- | Isolated segments | two isolated segments: 17 and 18 both | No Isolated segments |
167- | | they have 2 dead ends | - Edge 17 now shares a node with edges 14-1 and 14-2 |
168- | | | - Edges 18-1 and 18-2 share a node with edges 13-1 and 13-2 |
169- +------------------+-----------------------------------------+--------------------------------------------------------------+
170- | Gaps | There is a gap between edge 17 and 14 | Edge 14 was segmented |
171- | | because edge 14 is near to the right | Now edges: 14-1 14-2 17 share the same node |
172- | | node of edge 17 | The tolerance value was taken in account |
173- +------------------+-----------------------------------------+--------------------------------------------------------------+
174- | Intersections | Edges 13 and 18 were intersecting | Edges were segmented, So, now in the interection's |
175- | | | point there is a node and the following edges share it: |
176- | | | 13-1 13-2 18-1 18-2 |
177- +------------------+-----------------------------------------+--------------------------------------------------------------+
178-
179-
180- Now, we are going to include the segments 13-1, 13-2 14-1, 14-2 ,18-1 and 18-2
181- into our edge-table, copying the data for dir,cost,and reverse cost with tho
182- following steps:
183-
184- - Add a column old_id into edge_table, this column is going to keep track the id
185- of the original edge
186- - Insert only the segmented edges, that is, the ones whose max(sub_id) >1
168+ Analyze the network for intersections.
187169
188170.. literalinclude :: nodeNetwork.queries
189- :start-after: --q7
190- :end-before: --q7.1
171+ :start-after: --q11
172+ :end-before: --q12
173+
174+ Fixing an gap
175+ ...............................................................................
191176
192- We recreate the topology:
177+ Store the deadends
193178
194179.. literalinclude :: nodeNetwork.queries
195- :start-after: --q8
196- :end-before: --q8.1
180+ :start-after: --q12
181+ :end-before: --q13
197182
198- To get the same analysis results as the topology of edge_table_noded, we do the
199- following query:
183+ Calling ``pgr_nodeNetwork ``.
200184
201185.. literalinclude :: nodeNetwork.queries
202- :start-after: --q9
203- :end-before: --q9.1
186+ :start-after: --q13
187+ :end-before: --q14
204188
205- To get the same analysis results as the original edge_table, we do the following
206- query:
189+ Inspecting the generated table, we can see that edges 13 and 18 has been
190+ segmented
207191
208192.. literalinclude :: nodeNetwork.queries
209- :start-after: --q10
210- :end-before: --q10.1
193+ :start-after: --q14
194+ :end-before: --q15
195+
196+ .. rubric :: Update the topology
211197
212- Or we can analyze everything because, maybe edge 18 is an overpass, edge 14 is
213- an under pass and there is also a street level juction, and the same happens
214- with edges 17 and 13.
198+ Add new segmentes to the edges table.
215199
216200.. literalinclude :: nodeNetwork.queries
217- :start-after: --q11
218- :end-before: --q11.1
201+ :start-after: --q15
202+ :end-before: --q16
203+
204+ Insert the intersection as new vertices.
205+
206+ .. literalinclude :: nodeNetwork.queries
207+ :start-after: --q16
208+ :end-before: --q17
209+
210+ Update source and target information on the edges table.
211+
212+ .. literalinclude :: nodeNetwork.queries
213+ :start-after: --q17
214+ :end-before: --q18
215+
216+ Delete original edge.
217+
218+ .. literalinclude :: nodeNetwork.queries
219+ :start-after: --q18
220+ :end-before: --q19
221+
222+ Update the vertex topology
223+
224+ .. literalinclude :: nodeNetwork.queries
225+ :start-after: --q19
226+ :end-before: --q20
227+
228+ Analyze the network for gaps.
229+
230+ .. literalinclude :: nodeNetwork.queries
231+ :start-after: --q20
232+ :end-before: --q21
219233
220234See Also
221235-------------------------------------------------------------------------------
222236
223237:doc: `topology-functions ` for an overview of a topology for routing algorithms.
224238:doc: `pgr_analyzeOneWay ` to analyze directionality of the edges.
225239:doc: `pgr_createTopology ` to create a topology based on the geometry.
226- :doc: `pgr_analyzeGraph ` to analyze the edges and vertices of the edge table.
227240
228241.. rubric :: Indices and tables
229242
0 commit comments