斯潘8
span4
This article is also part of the tutorialHow Do I Do That in FMEγNext: Defining a Drive-Time Zone
Shortest route calculations are done in FME using the ShortestPathFinder transformer.This transformer calculates the shortest path from a source node to a destination node on a given network.
Here,例如,a user is finding the shortest path between the start/end points of a given route,使用线网络:
“从到”行定义路线的起点和终点。任何数量的“从到”行都可以传递到shortestpathfinder,以便在同一网络上进行多个计算。
有一些简单的变化和问题需要注意。
以下步骤是如何计算网络中最短路线的示例。
1。Start FME Workbench.添加一个读卡器(读卡器>在菜单栏上添加读卡器)以读取“从到”行的附加形状数据集。
2.添加第二个读卡器以读取附加的包含道路网络的AutoCAD DWG数据集。In the Add Reader dialog click the option for "Single Merged Feature Type".This will ensure all data is added as a single layer:
三。添加一个shortestpathfinder变压器,并将道路网络和从到线路连接到正确的输入端口。添加Inspector Transformer以可视化输出:
4.打开shortestpathfinder的参数对话框。Because the from-to end points may not sit exactly on the network,将参数从更改为,网络捕捉更改为是。Set a tolerance of 200:
5.Run the workspace.输出如下:
Travelling the wrong way along a one-way street is avoided by using costs instead of distance.It is necessary for the one-way streets to be tagged (usually with an attribute) and for their direction (from the first coordinate to the last) to match the permitted direction of travel.
Follow these steps as an example of how to calculate the shortest route in a network and avoid travelling the wrong way along a one-way street.
1。Start FME Workbench.Open the attached workspace (or continue from example 1).
2.将测试仪转换器添加到工作区,between the streets feature type and the ShortestPathFinder transformer:
三。打开“检测仪参数”对话框。Set up a test for where the attribute OneWay equals Y
4.Add two AttributeManager transformers,一个连接到每个测试仪输出端口。These will be used to set the travel cost:
5.打开第一个属性管理器的参数对话框(连接到测试仪的参数对话框:通过端口)。Add two new attributes,正向成本和反向成本。将ForwardCost设置为1(表示单向街道上的正确方向),将ReverseCost设置为9999(表示单向街道上的错误方向)
6。Open the parameters dialog for the second AttributeManager (the one connected to the Tester:Failed port).Add two new attributes,正向成本和反向成本。将这两个属性的值都设置为1。这是双向街道,两个方向的成本相等。
7。打开shortestpathfinder变压器的参数对话框。将成本类型参数从“按长度”更改为“按两个属性”。Set ForwardCost as the Forward Cost Attribute and ReverseCost as the Reverse Cost Attribute
8。Run the workspace.输出如下:
注意这个输出和示例1之间的区别。例1错误地使用了单行道,然而,示例2避免这样做。
Using only cost attributes to determine a route means that distance is no longer considered.例如,在示例2中,100米和100公里的道路没有区别,如果不是单行道。要解决这一问题,需要同时使用长度和成本。
Follow these steps as an example of how to calculate the shortest route in a network,同时考虑成本和长度。
1。Start FME Workbench.打开附加的工作区(或从示例2中继续)。
2.打开第一个属性管理器转换器的参数对话框。在ForwardCost属性的值旁边,单击下拉箭头并选择“打开算术编辑器”
三。In the arithmetic editor,添加一个乘法符号,然后在名为length的fme功能函数中拖动
对ReverseCost属性重复此步骤,对第二个attributeManager中的两个成本属性再次重复。
4.Run the workspace.输出如下:
再次注意示例1和2的结果的差异。
NB:The method of multiplying cost by distance is only one example of what might be used.你可以,for instance,通过将成本乘以距离的一半(成本*(距离/2)),对成本进行加权。
Example 2 (Complete) - Workspace as Template
© 2019 亚搏在线Safe Software Inc |法律