Exercise 5 Grounds Maintenance Project - Structural Transformation
Data City Parks (MapInfo TAB)
Overall Goal Calculate the size and average size of each park in the city, to use in Grounds Maintenance estimates for grass cutting, hedge trimming, etc.
Demonstrates Structural Transformation with Transformers
Start Workspace C:\FMEData2018\Workspaces\DesktopBasic\Transformation-Ex2-Begin.fmw
End Workspace C:\FMEData2018\Workspaces\DesktopBasic\Transformation-Ex2-Complete.fmw
C:\FMEData2018\Workspaces\DesktopBasic\Transformation-Ex2-Complete-Advanced.fmw

Let's continue your work on the grounds maintenance project.

In case you forgot, the team responsible for maintaining parks and other grassed areas needs to know the area and facilities of each park in order to plan their budget for the upcoming year.

In this part of the project we’ll filter out dog parks from the source data (as these have a different scale of maintenance costs) and write them to the log window. We'll also handle the renamed attribute NeighborhoodName.


1) Start FME Workbench
Start FME Workbench and open the workspace from the previous exercise. Alternatively you can open C:\FMEData2018\Workspaces\DesktopBasic\Transformation-Ex2-Begin.fmw.


2) Add Transformer
Let's first handle the source attribute NeighborhoodName, which was renamed Neighborhood on the writer but not yet connected.

We could do this by simply drawing a connection, but it's generally better to use a transformer. There are two transformers we could use. One is called the AttributeRenamer and the other - which we shall use here - is the AttributeManager.

Therefore click on the feature connection from reader to writer feature type:

Start to type the phrase "AttributeManager". This is how we can place a transformer in the workspace. As you type, FME searches for a matching transformer. When the list is short enough for you to see the AttributeManager, select it from the dialog (double-click on it):

This will place an AttributeManager transformer like so:


TIP
For a great tip on adding transformers see #5 in our list of The Top Ten FME Tips of All Time!


3) Set Parameters
View the AttributeManager parameters (either its dialog or in the Parameter Editor window). It will look like this:

Notice that all of the attributes on the stream in which it is connected will automatically appear in the dialog.

Where the Input Attribute field is set to NeighborhoodName, click in the Output Attribute field. Click on the button for the drop-down list and in there choose Neighborhood as the new attribute name to use:

In response the Action field will change to read Rename.


TIP
Neighborhood only appears in the list because it already exists on the writer schema. If we had done this step before editing the writer schema, we would have had to manually enter the new attribute name in this dialog.

Click OK to close the dialog. Now in the Workbench canvas window you will see the Neighborhood attribute is flagged with a green arrow, to confirm that a value is being provided to that attribute.


4) Add Transformer
Now we should remove dog parks from the data, because these have their own set of costs.

This can be done with a Tester transformer. Click on the connection from the AttributeManager output port to the ParksMaintenanceData feature type on the Writer.

Start typing the word Tester. When you spot the Tester transformer double-click on it to add one to the workspace. After tidying up the layout of the canvas, the workspace will now look like this:

Notice that the Passed output port is the one connected by default.


5) Set Parameters
Inspect the parameters for the Tester transformer. Click in the Left Value field and from there click the down arrow and choose Attribute Value > DogPark:

For the Right Value click into the field and type the value N. The operator field should be filled in automatically as the equals sign (=), which is what we want in this case.

Click OK to accept the values and close the dialog.


TIP
The test is for DogParks=N because we want to keep those features, and it is the Passed port that is connected. If the test was DogParks=Y then the Failed port would be the one to connect.


6) Add Transformer
We are now filtering out dog parks from our data, using a test on an attribute value. The question is, what should we do with the features we have filtered out? There are many things we could do, but for now we'll simply log the information to the FME log window.

To do this, right-click on the Tester Failed port and choose the option Connect Logger:

A Logger transformer will be added to the workspace. This will record all incoming features to the log window:

Loggers inserted by this method are named after – and reported in the log with – the output port they are connected to, here Tester_Failed.


7) Run Workspace
Save and run the workspace. It is not yet complete but running it will prove that everything is working correctly up to this point.


Advanced Exercise
Readers and writers on the canvas had a bookmark object added around them automatically. You can do the same to the transformers by selecting them all and either clicking Bookmark on the toolbar or pressing the Ctrl+B keys. Give the bookmark a name of your choice that describes the actions being carried out.

A bookmark is an example of what we call Best Practice in FME.

CONGRATULATIONS
By completing this exercise you have learned how to:
  • Add transformers to a workspace
  • Carry out schema mapping with the AttributeManager transformer
  • Filter data using the Tester transformer
  • Record data using the Logger transformer
  • Add bookmarks to a workspace

results matching ""

    No results matching ""