Thursday, July 21, 2005

The Roundtrip with GTFormatInfo

Today, there are many different ways to get data collected by GTViewer, GTVx, or Pocket GTViewer back to your GIS. The approach that probably comes to most users’ minds is Safe Software’s FME using the GTViewer Reader. This approach is easy to use and is the most flexible in supporting graphic and tabular information. However, it is not the only solution. GTRead and GTVx can also read collected data and provide a flexible mechanism for processing the information; however, this blog entry is going to be on a tool provided by GTData called GTFormatInfo which requires no programming or additional software.

First, how do you collect data with GTViewer or Pocket GTViewer? This job usually requires an external application like the demo Pole Test/Inspection app delivered with Pocket GTViewer or the Pole and Valve Inspection demos available for GTViewer and GTVx. These data collection apps are easy to implement and are generally just a variation of the templates GTI provides.

The data collections apps generally result in session graphics (redlines) that include embedded tabular data. Let’s say for example, you are using the Pole Inspection app and visit 50 poles. The external app stores the collected data on the redline marks used to indicate that a pole has been visited. These redlines are part of a .GTX extract file or they can be exported as a .GTG file (from a .GTM, GTS, or .GTX file). Either a .GTG or .GTX file is the input file to either FME or GTFormatInfo.

The GTFormatInfo utility is used to extract tabular data embedded on session graphics data in a .GTG file or a .GTX file. The embedded tabular data is applied to user provided templates converting a graphical .GTG or .GTX file into an ASCII file such as an SQL script containing update or insert statements. The GTFormatInfo utility could also be used to create reports or format input for a custom application. The point is, you do not have to be a programmer to access the data contained in the redline elements.

The GTFormatInfo utility is really just a text replacement tool, but it has the ability to select items from the embedded tabular data in the redline graphics to replace tokens with in a template file. You can provide 3 template files: Header File, Entry File, and a Footer File. The Header File is prepended to the output file, and the Footer File is appended to the output file. The Entry File will be written once for each element containing session graphics with embedded data. In the Entry File, you can place special tokens that will be replaced with attributes from data embedded on the session graphics. A token is specified in the following format:

<%ATTR:table.attribute%>

Where table is a table in the embedded data and attribute is an attribute within that table.

If you wanted to create SQL insert statements, an Entry File template might look like the following:

INSERT
INTO COLLECTED_DATA( IPID, DATE, TYPE )
VALUES (<%ATTR:EDIT.IPID%>,'<%ATTR:EDIT.DATE%>',

'<%ATTR:EDIT.TYPE%>');

So if you had 3 session graphics each with embedded data containing a table called Edit with attributes IPID, DATE, and Type, then you would get three records in the output file like this:

INSERT
INTO COLLECTED_DATA( IPID, DATE, TYPE )
VALUES (10023,'7/21/2005',

'PRIVATE');

INSERT
INTO COLLECTED_DATA( IPID, DATE, TYPE )
VALUES (10025,'7/21/2005',

'PUBLIC');

INSERT
INTO COLLECTED_DATA( IPID, DATE, TYPE )
VALUES (10037,'7/21/2005',

'PRIVATE');

The Header and Footer Files are optional but they could be added to make the data more easily work with another application. For example, you might add a Footer File that contains:

commit;
exit;


How you collect and get data back to your GIS will undoubtedly be depended on many different things. There are many tools available to help with this process. GTFormatInfo is a simplistic approach to the problem, but it may be quite usable in many situations.

No comments: