|Exercise||Caching and Partial Runs|
|Data||Roads (AutoCAD DWG)
Firehalls and Zones (GML)
|Overall Goal||Create time and distance isolines with the NetworkCostCalculator|
Here we'll continue the exercise from the Caching chapter. Our goal is to assist in planning emergency services by creating a dataset of isochrones - contour lines depicting travel time from each firehall - for medical emergencies.
1) Start Workbench
Start FME Workbench and, if necessary, open the template file for the previous exercise. You can find a copy of it at: C:\FMEData2018\Workspaces\UpgradingTo2018\Bookmarks-Ex1-Begin.fmwt
The workspace works fine, but it needs a couple of adjustments, plus it is in dire need of best practice style.
2) Add Bookmark
The first thing we can do is make the workspace canvas tidier by bookmarking all the road feature types and collapsing it into a smaller space.
So, select all of the feature types for the AutoCAD roads reader. Press Ctrl+B (or select Insert Bookmark from the toolbar). Name the bookmark AutoCAD Roads Reader:
If we collapse the bookmark now (try it and see) we'll still get multiple outputs and connections. We don't really need this. So add a single Junction transformer between all the connections and the ExpressionEvaluator and resize the bookmark (expanding it first if necessary) to fit the Junction:
Collapse the bookmark and now there will be just a single output port. Double-click the port to rename it. Name it Roads:
This has obviously saved quite a lot of space in the canvas.
3) Add Clipper
To return to the task at hand, the current workspace output covers all of the city of Vancouver, whereas we only need it to show contours for the area of responsibility for fire hall number 4.
To clip the data add a Clipper transformer to the workspace. Connect the contours to the Clippee input port and the MedicZone feature type to the Clipper port:
Rearrange the objects/ports to ensure there are no overlapping connections.
4) Duplicate Tester
The MedicZones data covers all of the city too, and we only need fire hall number 4. We can filter this with a Tester; in fact with the same test as the existing Tester.
So, select the existing Tester and press Ctrl+D (Right Click > Duplicate) to duplicate it. Drop the duplicate Tester into the MedicZones-Clipper connection:
But don't run the workspace yet...
5) Add Bookmark
If we run the workspace now there are a number of yellow caches that will be updated and saved. However, we don't really need these. Caches are useful for testing a section of workspace, but we already know the main part of this workspace is correct.
So, add a bookmark around the four main processing transformers (ExpressionEvaluator, Tester, NetworkCostCalculator, ContourGenerator):
Now collapse the bookmark, rename its ports, and rearrange content around it:
Notice that there is now only a single cache for the whole bookmark.
6) Run Workspace
Re-run the workspace by selecting the Clipper transformer and choosing Run To This.
We are now saving cache space because only one cache is created for the bookmarked parts. Expand (and re-collapse) the Isochrone bookmark to prove this. The ContourGenerator has caches because it is the last transformer. The Tester has caches, but only because it already had them:
Notice that as you expand/collapse the bookmark, other objects move in response to keep from overlapping.
Now inspect the Clipper:Inside cache. You should see that the isochrones are clipped to the area of responsibility for fire hall 4.
7) Save Workspace
Re-save the workspace as a template - including caches - so it is ready for further editing if required.
|To see some advanced tasks for this project, check out the GIS Tutorial on the FME Knowledge Centre.|
By completing this exercise you have learned how to: