Adding fanout support to a writer plug-in

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2015.x


Normally, the DEF lines in your mapping file (the destination feature types in your workspace) statically determine the feature types you can write out to. Feature type fanout allows users to dynamically write out feature types based on the value of an attribute.

For example, if the user has data with a TILE_ID attribute, she could write out a different Shapefile for each unique tile instead of creating individual feature types for each possibility. To enable this functionality in FME Workbench:
  1. Open the destination feature type's properties
  2. Enable the 'Fanout By Attribute' checkbox
  3. Select an attribute to fan out on

How it works

Workbench adds an fme_template_feature_type attribute to each outgoing feature. This attribute names a DEF line that will act as a template for each dynamically created feature type.

For example, the following mapping file fragment would result in the DWG writer writing out two feature types, one named 'alpha', and one named 'beta', and both of them would be the same as the toDWG feature type:

FACTORY_DEF * CreationFactory           \
    FACTORY_NAME "creator"              \
    2D_GEOMETRY 0 0 1 1 0 1             \
    OUTPUT FEATURE_TYPE alpha           \
      fme_template_feature_type toDWG   \
    OUTPUT FEATURE_TYPE beta            \
      fme_template_feature_type toDWG
DWG_DEF toDWG                           \
    autocad_entity     autocad_line

Adding support in your plug-in

If your writer is a multiFileWriter (e.g. each output feature type is a new file in a directory, like SHAPE and MIF), this functionality is already included. Otherwise (e.g. each feature type is a different layer in a file, like AutoCAD), the writer will require some additional coding.The writer will be sent a feature with a feature type not listed on any DEF line. Retrieve the fme_template_feature_typeattribute from that feature. The attribute's value will be the DEF line you should retrieve to use as the template for the new feature type being created. In other words, the writer should pretend the feature type was on a DEF line with contents identical to the DEF line given in the fme_template_feature_type attribute. Feature type fanout therefore gives the user the ability to create virtual DEF lines that simply reference existing DEFs in the mapping file. In that manner, the existing DEFs serve as templates, hence the term 'template feature type'.Once you add fanout support, make sure you remove the line:


Disabling feature type fanout

If your format does not support feature type fanout, add the line:


to your format's metafile and fanout will be disabled within your writer.

Was this article helpful?



Please sign in to leave a comment.