ShortestPathFinder
Computes the shortest path of a line or lines containing a source and destination node in a network based on the length of the input or the cost (specified in an attribute) of each of the edges.
Input Ports
Lines defining the network in which to find a path or paths. Input line features must be a topologically noded network with features connecting at line ends only. That is, all features must be split at junctions.
TheFrom-Toline contains vertices that define the source and destination nodes in the network. It can contain intermediate stops before the final destination. For example, aFrom-Toline may be used to find the path from A to B to C to D. This can also be read as “the path from A to D that also passes through B and C.”From-Tolines can be created by connecting points together to form a line, using theLineBuilderorVertexCreatortransformers.
Note:Intermediate stops on aFrom-Toline need to exactly match an existing node in the network features. To help with this you might use theChoppertransformer (to chop the network into 2-point lines) or theAnchoredSnappertransformer (to snap the intermediate points onto the network).
Output Ports
For eachFrom-Toline, if a path is found it will be output as a single feature through thePathport. This output feature contains the attributes and coordinate system of the originalFrom-Toline. The geometry of the output feature is made up of all the parts of network that form the shortest path. Note that ifCost Typeis set toBy One AttributeorBy Two Attributesthen the “shortest path” is the one where the sum of the values of the applicableCost Attributevalues is the least.
If a path is not found for a givenFrom-Toline, then thisFrom-Toline will be output through theNoPathport.
All network features that are not used as part of the shortest path are output through theUnusedport.
InputFrom-Tolines are output through this port. IfReorder From-To LineisIntermediate Points OnlyorAll Points, a _reordered attribute is added indicating whether theFrom-Toline was reordered.
All non-linear features from either input port are output through the
Rejected features will have anfme_rejection_codeattribute with one of the following values:INVALID_DESTINATION_GEOMETRY_TYPE,INVALID_LINE_GEOMETRY_TYPE,INVALID_PARAMETER_WEIGHT.
Parameters
The default behavior is to use the entire set of input features as the group. This option allows you to select attributes that define which groups to form. You can select attributes from bothNetworkandFrom-Toinput features.
Process At End (Blocking): This is the default behavior. Processing will only occur in this transformer once all input is present.
Process When Group Changes (Advanced): This transformer will process input groups in order. Changes of the value of the Group By parameter on the input stream will trigger processing on the currently accumulating group. This may improve overall speed (particularly with multiple, equally-sized groups), but could cause undesired behavior if input groups are not truly ordered.
There are two typical reasons for usingProcess When Group Changes (Advanced). The first is incoming data that is intended to be processed in groups (and is already so ordered). In this case, the structure dictates Group By usage - not performance considerations.
The second possible reason is potential performance gains.
Performance gains are most likely when the data is already sorted (or read using aSQL ORDER BYstatement) since less work is required of FME. If the data needs ordering, it can be sorted in the workspace (though the added processing overhead may negate any gains).
Sorting becomes more difficult according to the number of data streams. Multiple streams of data could be almost impossible to sort into the correct order, since all features matching aGroup Byvalue need to arrive before any features (of any feature type or dataset) belonging to the next group. In this case, usingGroup BywithProcess At End (Blocking)may be the equivalent and simpler approach.
Note:Multiple feature types and features from multiple datasets will not generally naturally occur in the correct order.
As with many scenarios, testing different approaches in your workspace with your data is the only definitive way to identify performance gains.
By Length: The cost of each input line is set to the length of the line. Orientation of the line is not considered.
By Length (Forward Only): The cost of each input line is set to the length of the line. The algorithm considers only the original orientation of the lines when finding the shortest path.
By One Attribute: The cost of each input line is specified byForward Cost Attribute. The algorithm considers only the original orientation of the lines when finding the shortest path.
By Two Attributes:最短路径算法会考虑两个directions of the input lines. The original orientation of the input line has the cost specified byForward Cost Attributeand the reversed orientation of the input line has the cost specified byReverse Cost Attribute.
By Straight Line Distance (No Network): Cost is calculated as the straight line distance between vertices in theFrom-Toline. When using this option, theReorder From-To Lineparameter should be set toIntermediate Points OnlyorAll Points.
The values that result fromCost Typeare summed for all input lines as they relate to theFrom-To线,成为shortest-fo最短的数目und path.
This parameter is used whenCost Typeis set toBy One AttributeorBy Two Attributes.
This parameter is used whenCost Typeis set toBy Two Attributes.
Whether to allow the reverse of a line in the network to be used immediately following that line. IfNo, paths that reverse on each other are not considered when finding a shortest path.
When specified, this attribute list that will hold the attributes for each inputNetworkfeature that make upPathoutput features.
This list also contains a_directionattribute that stores the direction of the segment of the shortest path as compared to its originalNetworkfeature. It will either be “same” or “opposite”, depending if the originalNetworkfeature had to be reversed or not.
Snap Options
SelectYesto snap the points of theFrom-Toline to the closest end points of theNetworklines. The points are only snapped to the network lines if they are within the tolerance specified inSnapping Tolerance.
Note:The shortest distance is calculated based on the specifiedFrom-Toline and is not affected by snapping.
The tolerance used whenFrom-To and Network Snappingis set toYes. Points of theFrom-Toline will be snapped to theNetworklines if they are within this tolerance.
Optimization Options
Specifies whether the points of the inputFrom-Toline should be reordered to find a shorter path. This option is useful when the order of points of theFrom-Toline is not important, such as in travelling salesman problems. A metaheuristic is used to find a low-cost ordering of points.
No: The inputFrom-Toline is used as-is. No optimization occurs.
Intermediate Points Only: The start and end points of the inputFrom-Toline are untouched. Intermediate points are reordered.
All Points: All points of the inputFrom-Toline are reordered.
The number of times to run the optimization algorithm. The greater the number of iterations, the closer the result will be to the optimal solution. Increasing this parameter increases translation time.
This parameter must be set to a positive integer. The default value is 10000.
The number of times the optimization algorithm needs to return the same potential result before it is accepted. Setting this parameter to a high value may result in very long translation time or cause the translation to never complete.
This parameter must be set to a non-negative integer. A value of 0 specifies that no verifications are required. The default value is 1.
The greatest cost that will be accepted as valid. Setting this parameter to a low value may cause the translation to never complete.
This parameter must be set to a non-negative value. A value of 0 specifies that there is no restriction on the cost that will be accepted. The default value is 0.
Usage Notes
If ShortestPathFinder produces unexpected results, consider usingAnchoredSnapperinstead. Input theFrom-To Linethrough theCandidateinput port and use the same value forSnapping Tolerance. SpecifySnapping Type=End Point SnappingandAdd Additional Vertex=NEVER.
Only linear features with non-negative cost attribute values are allowed if theCost Typeis set toBy One AttributeorBy Two Attributes. If a feature does not have the attribute specified in theForward Cost Attributeor theReverse Cost Attribute, a zero cost is used for the line. Any features with a negative cost will be output through the
Editing Transformer Parameters
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, clickbeside the applicable parameter. For more information, seeTransformer Parameter Menu Options.
Transformer Categories
Related Transformers
FME Licensing Level
FME Professional edition and above
FME Community
The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for samples and information about this transformer on theFME Community.