Mapping File Examples

The following mapping file example shows how the Multi-Writer is used to separate features into GIF and PNG files. This example illustrates how to use generic and specific keywords to configure the individual writers used by the Multi-Writer. In particular, notice how the BLACK writer is specifically configured to create a 250x250 pixel image while the GREEN and BRICK writers use the default 500x500 setting. Also, the GREEN and BLACK writers create GIF datasets while the BRICK writer creates a PNG dataset.

When used in this mode the Multi-Writer must be configured such that it is ready for every possible value of multi_writer_id that can be passed to it by the FME, otherwise it will reject features it is not prepared for. To illustrate, if a feature with a multi_writer_id of 3 were created in the TeeFactory of this example, it would be rejected by the Multi-Writer because its destination would be unknown.

#-------------------------------------------------------------------------
# Specify a Null Reader (CreationFactory is used to create test features)
READER_TYPE NULL
NULL_DATASET NULL

#-------------------------------------------------------------------------
# Set up the Multi-Writer to explicitly open two GIF writers
WRITER_TYPE MULTI_WRITER
MULTI_WRITER_TYPE{0} GIF
MULTI_WRITER_KEYWORD{0} GREEN
MULTI_WRITER_TYPE{1} GIF
MULTI_WRITER_KEYWORD{1} BRICK
MULTI_WRITER_TYPE{2} GIF
MULTI_WRITER_KEYWORD{2} BLACK

#-------------------------------------------------------------------------
# Generic configuration for all GIF writers
GIF_DEF BrightGreen GIF_RED 0 GIF_GREEN 255 GIF_BLUE 0
GIF_DEF BrickRed GIF_RED 160 GIF_GREEN 64 GIF_BLUE 64
GIF_DEF Black GIF_RED 0 GIF_GREEN 0 GIF_BLUE 0
GIF_DEF White GIF_RED 255 GIF_GREEN 255 GIF_BLUE 255
GIF_HEIGHT 500
GIF_WIDTH 500

#-------------------------------------------------------------------------
# Specific configuration for first GIF writer
GREEN_DATASET "C:/GIF/image_0.gif"

#-------------------------------------------------------------------------
# Specific configuration for second GIF writer
BRICK_DATASET "C:/GIF/image_1.png"

#-------------------------------------------------------------------------
# Specific configuration for third GIF writer
BLACK_DATASET "C:/GIF/image_2.gif"
BLACK_HEIGHT 250
BLACK_WIDTH 250

#-------------------------------------------------------------------------
# Create one feature and make a copy of it for each individual writer
FACTORY_DEF * CreationFactory \
2D_GEOMETRY 0 0 0 1 1 1 1 0 0 0 \
OUTPUT FEATURE_TYPE square

FACTORY_DEF * TeeFactory \
INPUT FEATURE_TYPE * \
@SupplyAttributes(gif_type, gif_polygon) \
@SupplyAttributes(gif_fill_color, White) \
OUTPUT FEATURE_TYPE * \
multi_writer_id 0 \
@FeatureType(BrickRed) \
OUTPUT FEATURE_TYPE * \
multi_writer_id 1 \
@FeatureType(BrightGreen) \
OUTPUT FEATURE_TYPE * \
multi_writer_id 2 \
@FeatureType(Black)

#-------------------------------------------------------------------------
# Correlate everything from the input to the output
NULL *
MULTI_WRITER *

The following mapping file example shows how the Multi-Writer is used to write features into datasets of different types. It uses the Multi-Writer to create one Design dataset and two AutoCAD datasets in a single FME run. Notice how a writer-specific keyword is needed to individually configure each of the AutoCAD writers, but none is needed to configure the single Design writer.

#-------------------------------------------------------------------------
# Use a Null Reader
READER_TYPE NULL
NULL_DATASET NULL

#-------------------------------------------------------------------------
# Set up the Multi-Writer to explicitly open a Design writer and two
# AutoCAD writers
WRITER_TYPE MULTI_WRITER
MULTI_WRITER_TYPE{0} IGDS
MULTI_WRITER_TYPE{1} DWG
MULTI_WRITER_KEYWORD{1} DWG_1
MULTI_WRITER_TYPE{2} DWG
MULTI_WRITER_KEYWORD{2} DWG_2

#-------------------------------------------------------------------------
# Specific configuration for Design writer
IGDS_DATASET "C:/Design/output.dgn"
IGDS_SEED_FILE "$(FME_HOME)/Design/seed2d_m.dgn"
IGDS_UNITS IGDS_MASTER_UNITS

#-------------------------------------------------------------------------
# Specific configuration for first AutoCAD writer
DWG_1_DATASET "C:/AutoCAD/Box/output.dwg"
DWG_1_VERSION Release2000
DWG_1_DEF BOX \
autocad_color 2 \
autocad_linetype CONTINUOUS

#-------------------------------------------------------------------------
# Specific configuration for second AutoCAD writer
DWG_2_DATASET "C:/AutoCAD/Square/output.dwg"
DWG_2_VERSION Release14
DWG_2_DEF SQUARE \
autocad_color 6 \
autocad_linetype CONTINUOUS

#-------------------------------------------------------------------------
# Create one feature and make a copy of it for each individual writer
FACTORY_DEF * CreationFactory \
2D_GEOMETRY 0 0 0 1 1 1 1 0 0 0 \
OUTPUT FEATURE_TYPE square

FACTORY_DEF * TeeFactory \
INPUT FEATURE_TYPE * \
OUTPUT FEATURE_TYPE * \
multi_writer_id 0 \
@FeatureType(2) \
igds_type igds_shape \
igds_style 3 \
fme_fill_color 0.5,1,0 \
OUTPUT FEATURE_TYPE * \
multi_writer_id 1 \
@FeatureType(BOX) \
fme_color 0,1,0 \
autocad_entity autocad_polygon \
OUTPUT FEATURE_TYPE * \
multi_writer_id 2 \
@FeatureType(SQUARE) \
fme_color 0,1,1 \
autocad_entity autocad_polygon

#-------------------------------------------------------------------------
# Correlate everything from the input to the output
NULL *
MULTI_WRITER *

The following mapping file example shows how the Multi-Writer is used to write features into multiple datasets of the same type. It uses the Multi-Writer to create many Shape datasets in a single FME run, where all the datasets have the same schema. Notice how no specific configuration is provided for any of the Shape writers.

#-------------------------------------------------------------------------
# Specify a Null Reader (CreationFactory is used to create test features)
READER_TYPE NULL
NULL_DATASET NULL

#-------------------------------------------------------------------------
# Set up the Multi-Writer to open a Shape writer for each
# data set specified in the feature pipeline
WRITER_TYPE MULTI_WRITER
MULTI_WRITER_TYPE{*} SHAPE
MULTI_WRITER_DATASET{*} "C:/Shape/dset_<multi_writer_id>"

#-------------------------------------------------------------------------
# Generic configuration for all Shape writers
SHAPE_DEF square \
SHAPE_GEOMETRY shape_polyline \
SOMEATTR char(20)

#-------------------------------------------------------------------------
# Create one feature and make a copy of it for each individual writer
FACTORY_DEF * CreationFactory \
2D_GEOMETRY 0 0 0 1 1 1 1 0 0 0 \
OUTPUT FEATURE_TYPE square

FACTORY_DEF * TeeFactory \
INPUT FEATURE_TYPE * \
OUTPUT FEATURE_TYPE * \
multi_writer_id 0 \
SOMEATTR zero \
OUTPUT FEATURE_TYPE * \
multi_writer_id 1 \
SOMEATTR one \
OUTPUT FEATURE_TYPE * \
multi_writer_id 2 \
SOMEATTR two

#-------------------------------------------------------------------------
# Correlate everything from the input to the output
NULL *
MULTI_WRITER *

The following mapping file example shows how the Multi-Writer is used to write features into many datasets of the same type. It uses the Multi-Writer to create multiple GIF files in a single FME run. It illustrates how the multi_writer_id becomes the reader keyword when MULTI_WRITER_TYPE{*} is used. This example makes use of that knowledge to control the dataset configuration for the COLOR_3 writer.

#-------------------------------------------------------------------------
# Specify a Null Reader (CreationFactory is used to create test features)
READER_TYPE NULL
NULL_DATASET NULL

#-------------------------------------------------------------------------
# Set up the Multi-Writer to open a GIF writer for each
# data set specified in the feature pipeline
WRITER_TYPE MULTI_WRITER
MULTI_WRITER_TYPE{*} GIF
MULTI_WRITER_DATASET{*} "C:/GIF/image_<multi_writer_id>.gif"

#-------------------------------------------------------------------------
# Generic configuration for all GIF writers
GIF_DEF BrightGreen GIF_RED 0 GIF_GREEN 255 GIF_BLUE 0
GIF_DEF BrickRed GIF_RED 160 GIF_GREEN 64 GIF_BLUE 64
GIF_DEF Black GIF_RED 0 GIF_GREEN 0 GIF_BLUE 0
GIF_DEF White GIF_RED 255 GIF_GREEN 255 GIF_BLUE 255
GIF_HEIGHT 100
GIF_WIDTH 100
#-------------------------------------------------------------------------
# Specific configuration for COLOR_3 writer
COLOR_3_DATASET "C:/GIF/image_3.gif"

#-------------------------------------------------------------------------
# Create one feature and make a copy of it for each individual writer
FACTORY_DEF * CreationFactory \
2D_GEOMETRY 0 0 0 1 1 1 1 0 0 0 \
OUTPUT FEATURE_TYPE square

FACTORY_DEF * TeeFactory \
INPUT FEATURE_TYPE * \
@SupplyAttributes(gif_type, gif_polygon) \
@SupplyAttributes(gif_fill_color, White) \
OUTPUT FEATURE_TYPE * \
multi_writer_id color_1 \
@FeatureType(BrickRed) \
OUTPUT FEATURE_TYPE * \
multi_writer_id color_2 \
@FeatureType(BrightGreen) \
OUTPUT FEATURE_TYPE * \
multi_writer_id color_3 \
@FeatureType(Black)
#-------------------------------------------------------------------------
# Correlate everything from the input to the output
NULL *
MULTI_WRITER *

The following mapping file example shows how the Multi-Writer is used to write features into many datasets of the same type but with different projections. It uses the Multi-Writer to create multiple MapInfo datasets in a single FME run, where each dataset has a different projection. This example illustrates how to change the Multi-Writer keyword to OUTPUT, which is then used in the for the Multi-Writer configuration and correlation line.

#-------------------------------------------------------------------------
# Specify a Null Reader (CreationFactory is used to create test features)
READER_TYPE NULL
NULL_DATASET NULL

#-------------------------------------------------------------------------
# Set up the Multi-Writer to open a MapInfo writer for each
# data set specified in the feature pipeline
WRITER_TYPE MULTI_WRITER
WRITER_KEYWORD OUTPUT
OUTPUT_TYPE{*} MAPINFO
OUTPUT_DATASET{*} "C:/MapInfo/dset_<multi_writer_id>"

#-------------------------------------------------------------------------
# Generic configuration for all MapInfo writers
MAPINFO_DEF square \
SOMEATTR char(20)

#-------------------------------------------------------------------------
# Create one feature
FACTORY_DEF * CreationFactory \
2D_GEOMETRY 0 0 0 1 1 1 1 0 0 0 \
OUTPUT FEATURE_TYPE square

#-------------------------------------------------------------------------
# Copy the feature and set one copy to go to multi-writer 0 and the other
# to go multi-writer 1. Also, reproject the first feature to UTM10-83 and
# the other to LL-83.
FACTORY_DEF * TeeFactory \
INPUT FEATURE_TYPE * \
@SupplyAttributes(mapinfo_type, mapinfo_polyline) \
OUTPUT FEATURE_TYPE * \
multi_writer_id 0 \
SOMEATTR zero \
fme_color 0,1,0 \
@Reproject(LL-83,UTM10-83) \
OUTPUT FEATURE_TYPE * \
multi_writer_id 1 \
SOMEATTR one \
fme_color 0,1,1 \
@Reproject(LL-83,LL-83)

#-------------------------------------------------------------------------
# Correlate everything from the input to the output
NULL *
OUTPUT *

The following mapping file example shows how the Multi-Writer is used to segment a feature into a set of adjacent tiles. It uses the Multi-Writer to create multiple Shape datasets in a single FME run, where each data has represents an adjacent tile.

#-------------------------------------------------------------------------
# Specify a Null Reader (CreationFactory is used to create test features)
READER_TYPE NULL
NULL_DATASET NULL

#-------------------------------------------------------------------------
# Set up the Multi-Writer to open a Shape writer for each
# data set specified in the feature pipeline
WRITER_TYPE MULTI_WRITER
MULTI_WRITER_TYPE{*} SHAPE
MULTI_WRITER_DATASET{*} "C:/Shape/t<multi_writer_row><multi_writer_column>"

#-------------------------------------------------------------------------
# Set up the Shape writers
SHAPE_DEF linework \
SHAPE_GEOMETRY shape_polyline \
SOMEATTR char(20)

#-------------------------------------------------------------------------
# Create four tile boundaries
FACTORY_DEF * CreationFactory \
2D_GEOMETRY 0 0 0 1 1 1 1 0 0 0 \
OUTPUT FEATURE_TYPE tileBoundary \
multi_writer_row 0 \
multi_writer_column 0

FACTORY_DEF * CreationFactory \
2D_GEOMETRY 0 1 0 2 1 2 1 1 0 1 \
OUTPUT FEATURE_TYPE tileBoundary \
multi_writer_row 1 \
multi_writer_column 0

FACTORY_DEF * CreationFactory \
2D_GEOMETRY 1 1 1 2 2 2 2 1 1 1 \
OUTPUT FEATURE_TYPE tileBoundary \
multi_writer_row 1 \
multi_writer_column 1

FACTORY_DEF * CreationFactory \
2D_GEOMETRY 1 0 1 1 2 1 2 0 1 0 \
OUTPUT FEATURE_TYPE tileBoundary \
multi_writer_row 0 \
multi_writer_column 1

#-------------------------------------------------------------------------
# Create a circular line segment that spans the four tiles
FACTORY_DEF * CreationFactory \
2D_GEOMETRY 1 1 \
OUTPUT FEATURE_TYPE linework \
@Arc(1, 1, 50, 0, 0, 359)

#-------------------------------------------------------------------------
# Break the line work into segments according to tile boundaries
FACTORY_DEF * OverlayFactory \
INPUT POLYGON FEATURE_TYPE tileBoundary \
INPUT LINE FEATURE_TYPE linework \
OUTPUT LINE FEATURE_TYPE *

#-------------------------------------------------------------------------
# Correlate everything from the input to the output
NULL *
MULTI_WRITER *