Thursday, December 18, 2008

Create Framme Linkages with FME

FME can be used to write Intergraph Framme linkages. The tricky part is not actually writing the linkages to the graphic DGN elements but figuring out what values to write to the Framme linkages. If you somehow have the correct values from somewhere, then you can use either the FME Workbench or write a FME mapping file to create the linkages.

In this example below, I created an FME mapping file to create DGN line elements with Framme linkages from geometries in a PostGis database table named pipeline. The work is done at the Transformation section of the mapping file as shown in bold below. I am assuming that I have the proper values already calculated and stored as attributes in the PostGis table.

#========================================================================
# Transformation section #======================================================================== POSTGIS pipeline \
postgis_type postgis_line \
i_level %igds_level \
i_color %igds_color \

i_style %igds_style \

i_weight %igds_weight \

i_group %igds_graphic_group \

i_class %igds_class \
ufid %ufid \

feat_num %feat_num \
state_num %state_num \
comp_num %comp_num \
comp_count %comp_count \
dgnfile %dgnfile \
the_geom %geom

IGDS level \
igds_type igds_line \

igds_level %igds_level \

igds_color %igds_color \

igds_style %igds_style \

igds_weight %igds_weight \

igds_graphic_group %igds_graphic_group \
igds_class %igds_class \
geom %geom \
igds_linkage{0}.type framme \

igds_linkage{0}.ufid %ufid \

igds_linkage{0}.feature_num %feat_num \

igds_linkage{0}.state_num %state_num \

igds_linkage{0}.component_num %comp_num \
igds_linkage{0}.comp_count %comp_count \

igds_linkage{0}.design_file %dgnfile

Create DGN Elements on Correct Levels with FME

By default, if you use the FME Workbench or the FME Universal Translator to create a DGN file, the geometries will be created as DGN graphic elements on level 1 and above incrementally for each feature type. For example as shown in the workbench figure below, the destination of my source feature is set to level 1, as indicated with the text "1" in the title bar.


Most times, users will want to control and define the output levels of the output DGN graphic elements since levels is a useful way to organize the graphical data e.g. level 1 for vegetation land use, level 2 for park land use, etc.

In this posting, I describe a way using FME mapping file to define and control the destination level. I am assuming that I have an attribute in the source feature that stores the level number.
  1. Use the FME Universal Translator to generate a mapping file from your source format e.g. ESRI Shape to the destination MicroStation Design format.



  2. Use a text editor to open up the resultant mapping file e.g. mapping.fme.

    The mapping file may look like this.

    # ============================================================================
    # Source feature type definition section
    # ============================================================================

    SHAPE_DEF LAND_USE \
    SHAPE_GEOMETRY shape_polygon \
    USE_TYPE char(50) \
    IGDS_LEVEL number(10,0) \
    ID number(10,0)

    # ============================================================================
    # Transformation section
    # ============================================================================

    SHAPE LAND_USE \
    USE_TYPE %USE_TYPE \
    ID %ID

    IGDS 1 \
    igds_type igds_solid \
    USE_TYPE %USE_TYPE \
    ID %ID


  3. In the Transformation section for the source format, add in the following line in bold.

    SHAPE LAND_USE \
    USE_TYPE %USE_TYPE \
    IGDS_LEVEL %IGDS_LEVEL \
    ID %ID


  4. In the Transformation section for the destination IGDS format, replace the number "1" with the text "level" and add in the following line in bold.

    Note:
    igds_level must be in lower case.

    IGDS level \
    igds_type igds_solid \
    USE_TYPE %USE_TYPE \
    igds_level %IGDS_LEVEL \
    ID %ID


  5. Save the changes and close the mapping file. Now when you run the translation, the DGN graphic elements will be created in the level defined in the IGDS_LEVEL attribute of the source feature.