Exercise 2 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:\FMEData2017\Workspaces\DesktopBasic\Transformation-Ex2-Begin.fmw
End Workspace C:\FMEData2017\Workspaces\DesktopBasic\Transformation-Ex2-Complete.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:\FMEData2017\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:

In 2017.1 the help contents of the Quick Add window are now simplified, but include a clickable link to the full documentation. It's also labelled 'Browse Additional Help' instead of 'Jump to Configuration'.

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

3) Set Parameters
View the AttributeManager parameters in the Parameter Editor window by clicking on it in the canvas (alternatively click its cogwheel icon to open the parameters dialog). 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.

Most importantly, check that the Action field is set to Rename and click the Apply (OK) button to confirm the action.

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
View the parameters on the Tester transformer by opening the parameters dialog (the Tester has a special dialog that can't be viewed in the Parameter Editor window). Double 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.

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 this data 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
As an advanced task, if you have time, filter the data further to remove parks that do not have a name; i.e. their name attribute is missing or empty. Would you need to place a second Tester transformer, or could you incorporate the test into the existing one?

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

results matching ""

    No results matching ""