Thursday, July 14, 2011

Creating GTViewer Data with Embedded Data Using FME

In my last post, I covered programmatically embedding data into Session Graphics with GTViewer and GTVx. This post will also cover Embedded Data, but it will use FME to create it instead of VB6 or VB.NET.

The GTViewer Writer Plug-In for FME can easily create embedded data in GTViewer Data. You must expose two Format Attributes in the destination GTViewer Writer: gti_embeddedData and gti_embeddedDataType.

There is currently only 1 valid Embedded Data Type for GTViewer data, so you can set gti_embeddedDataType to a Constant 1. The gti_embeddedData attribute is then set to the string you want to embed. The \t\a\v format for embedded data that I described in the previous post, can also be used here to format the embedded data so that the Attribute Info dialog in GTViewer and GTVx will recognize the embedded data as if it came from a database.

For an example, I will take a TIGER street file and convert it to the GTViewer format. Instead of letting FME create tabular data in the GTViewer format and link it to the graphic elements it creates (which is the default and is usually the desired process), I will delete the tabular attributes from the destination and use only embedded data.


The StringConcatenator transformer (shown above) is used to build the \t\a\v string. There are many ways you could go about building this string in FME, but this approach seemed the easiest and my visual for a blog posting. In the screenshot below, I simply build the embedded data string using constants and attribute values from the TIGER data. One item to note is that the backslash (\) is an escape operator in this FME transformer, so you need to use two backslashes to represent one (\\), and \t becomes \\t, and so on.

You can convert the data to the GTViewer format and open it up in GTViewer. Then review one of the streets:

If you look on the Element Tab for the reviewed street, you will see the Embedded Data property is set to the string we created with FME. Also note that the Attribute Info tab has a red drum indicating that it is Embedded Data instead of Linked Data.

This example is somewhat contrived since if you were really converting street data, you would almost definitely be using Linked data (the default that the GTViewer FME Writer Plug-in provides); however, there are other cases where embedded data might be very useful.



No comments: