My Account     Contact Us     Cart

Sorting MAPublisher Layers with FME Auto

In this blog post we’ll look at how you can control the order of layers in MAPublisher when using FME Auto.

FME Auto to MAPublisher

FME currently doesn’t provide a way to explicitly define the output order of Feature Types in a workspace. In the Navigator you can reorder Readers and Writers to control the order in which they are run, but unfortunately you cannot do the same with the Feature Types they read and write respectively.

By default when you write layers to MAPublisher from FME using FME Auto, the layers are arranged first by geometry (text first, then Points, Lines, Polygons and lastly Images), then alphabetically by layer name. This behaviour can be changed by unchecking the FME Auto Parameter “Sort Layers by Geometry”. Once this has been turned off, MAPublisher will display layers in the order they are received from FME. Using this behaviour, some FME transformers and a Feature Type fanout (or new to 2015.1, specifying the Feature Type name) we can control the order of the layers in MAPublisher for optimal cartographic output.

The first thing we want to do is to add some input Feature Types.

Natural Earth Shapefiles
(Click for larger version)

We will then create a template AttributeCreator Transformer to give each layer two attributes: MP_LayerName and MP_Order. MP_LayerName will define the name of the layer in MAPublisher and MP_Order will determine the order the layer is passed to MAPublisher; hence the order in which it is displayed.

AttributeCreator Transformer to add MAPublisher Specific attributes

Each Feature Type will be connected to a copy of the AttributeCreator Transformer and the values will be populated for that layer. The layer with an order of 1 will be on top with larger numbers descending below.

Layer Name Order
Border 1
Graticules 2
Pacific Groupings 3
Tiny Countries 4
Coastline 5
Lakes 6
Countries 7
Rivers 8
Glaciated Areas 9
Land 10
Ocean 11
AttributeCreator Transformers connected to input Feature types
(Click for larger version)

Once this is done, all the inputs can be connected to a Sorter Transformer. The Sorter will be set to numeric and ascending.

Sorter Transformer
(Click for larger version)

Finally, the MAPublisher writer is added. The Sort by Geometry parameter needs to be set to No and the Feature Type name should be set by the MP_LayerName attribute we created earlier. This replaces Feature Type fanouts and has slightly new behaviour at FME 2015.1. It is explained more fully (here).

MAPublisher writer added with Sort by Geometry Set to No
(Click for larger version)
Output Feature Types are defined by the LayerName attribute

Once we run the workspace, we’ll see the layers in the Adobe Illustrator Layers panel in the exact order we specified.

Layers in Adobe Illustrator are in the correct order
The final map after some cartographic styling
(Click for larger version)

News Archive