Shortest path search
The shortest path problem is the typical routing problem of the road networks. To define the shortest path between to points we will use the shortestPath(long startGfid, long endGfid, OGRLayer *resultLayer) method of the simplenetworkanalysis.h package (which for its turn uses Dijkstra shortest path tree search algorithm). Let's create a new network as at was shown at previous post, defining the Esri Shapfile as the spatial format now. Note: I made some preparations to visualize the results and save them at the QGIS project, which can be also found at my Github. For example, I set the "kolodci" layer's labeling options so the GFIDs of this layer features are displayed (using the joining with network_features layer).
Now let's try another interesting capability of the model - features blocking. We block the 815 feature and that means that it will not be considered in the following graph tracing, like it is now removed from the graph. So the previous path becomes unavailable and the shortest path will lie through 819 and 806.
If we block then 818 feature there will be no path between 807 and 801 and the according error code will be returned.
Resource distribution
In the field of engineering networks the resource can
be anything that spreads over the network (water, gas, electricity)
from the emitter features, along the transmitter features, to the
receiver features. So there is a task to see, which part of network
is covered by resource in different situations, such as blocking
(breaking) of some network elements.
The concept of rules plays the key role in the work
with resource. It is proposed that all features of the class, that
marked as EMITTER will “emit” the resource. Thus the
resourceDestribution() method of the simplenetworkanalysis.h package
can use the connected component search algorithm (the concrete
implementation is a Breadth-first search) to define which (line)
features are connected to these emitters, that means that they have a
resource. Let's open our previous network and make some preparations
before the resource can be collected.
We say that the three features from the layer “tanks”
(marked as stars) will play the role of emitters. We connect them
with the nearest features: 0 with 807, 2 with 721 and 1 with 717. Now
let's create the resulting layer and pass it to the
resourceDestribution(). This layer will be filled with the features,
showing the resource spreading from the multiple emitters.
Let's imagine that some junctions in our water
network are broken. We block 720 and 718 and see that though a small
part of network has no water now, the most part of it still has it.
To resolve this “problem” we can build a
temporary pipe from any place where the water persists. We connect
721 with 719 and see that the void section is now full with water.
No comments:
Post a Comment