tsmApiTM Library
About
Download
License
What's New
Tutorials
GeoVRML Support
Adding File Filters
API Specification
File Formats
 


tsmApi File Format Filters:


The tsmApi is able to produce TerraVision and GeoVRML datasets from a number of input file formats, such as USGS DEM, NIMA DTED, JPEG, GIF, TIFF, GeoTIFF, and so on. But what can you do if the format you want to use is not supported?

tsmApi is an Open Source distribution and great efforts have been made to produce an easily extensible architecture for supporting different file formats. To this end, it should be relatively easy for you to plug in your own file format reader into the library. You will need to download the tsmApi source code and extend the source in order to do this. Below are the steps you will need to perform to add support for a new file format.


  1. Create your file format reader files and add these to the autoconf build system (i.e. add to Makefile.am, run "automake --foreign" and then "autoconf"), i.e.

    tsmReadRowsFOO.c - your file format reader functions
    tsmReadRowsFOO.h - definitions and prototypes for your reader

    You should create four functions:

    tsmReadRowsFOO_new() - open the file and create a state closure
    tsmReadRowsFOO_read() - read a number of lines from the file
    tsmReadRowsFOO_destroy() - close file and free up the closure
    tsmParseCreateParams_FOO() - parse .foo file for metadata info

  2. In tsmCreate.h:

    • add a define for TSM_IMPORT_FOO to the list

  3. In tsmCreate.c:

    • add a #include "tsmReadRowsFOO.h" to the top of the file

    • add support for the filename extension .foo to tsmFindImportFormat() so that it returns TSM_IMPORT_FOO

    • add code to the switch statement in tsmCreateAllTiles() in order to detect TSM_IMPORT_FOO and call the appropriate downsample function with a callback to your reader function in tsmReadRowsFOO.c

    • add code to the switch statement in tsmParseCreateParams() in order to detect TSM_IMPORT_FOO and parse any header/metadata contained in the file.

    • add code to the switch statement in tsmDescribeImportFormat() in order to give a textual description of the file format FOO.


You can find a number of examples of file format filters developed this way within the tsmApi source code. One of the simplest such examples that serves to illustrate the principles most obviously is the PPM and PGM file format support. These formats are implemented in the tsm/tsmReadRowsPBM.c file, with external definitions in tsm/tsmReadRowsPBM.h.

 

 

Copyright ©2001 SRI International. All rights reserved.

For more information, please contact: digital-earth@ai.sri.com.
Last updated: Thursday, 11-Jan-2001 15:00:37 PST.