Procedure: Convert BT format data to the Planet format, then import the converted data.
Background
Terraformer is the tool you normally use to import your map data for 3D viewing in Terracopter. Ideally, Terraformer would support all conceivable formats. Unfortunately, it doesn't, at least not yet. In fact, the first release of Terraformer supports ONLY the Planet file format. Faced with the task of bundling some sample data with our distribution, we decided to use the public domain data available from the http://vterrain.org web site. This data is in a format called "BT". In order to do this, without having to implement full BT support in Terraformer, a small C++ utility was written for a one-shot conversion from BT format to PLAnet format. The following is a step-by-step description of how this was done, for the benefit of those of you who need to do something similar.
NOTE: The code included is intended to be an illustration ONLY, and it is NOT supported or vouched for in any way whatsoever! You may, therefore, use it in any way you see fit, including redistribution and modification.
Step 1 - Download the data from vterrain.org
Located alongside this README file are the original elevation data files that are available as a zipfile, and the matching satellite photo, available as a jpg file. The zip file contains two files. The first one is a .bt file that contains the elevation data. The second one is a .prj file that contains additional information on the projection used to create the data. This file is not used at all in the conversion described below.
Step 2 - Write the code
See the BT format documentation for a description of the BT file format. Essentially, it consists of a binary header followed by the actual elevation samples. The samples can be 16- or 32-bit integers, or 32-bit floats. In this case, we are dealing with 16-bit data. The Planet format consists of a text file called index.txt that corresponds to the BT header. The elevation data is put in a separate binary file that is referenced from the index file. The transformation of the data is very straightforward, and easiest understood by consulting the source code in bt2planet.cpp , in the same directory as this README.
Step 3 - Run the conversion utility on the source data
The bt2planet utility accepts the name of the BT file to convert as a command-line parameter, and creates a Planet index file (named index.txt) and binary data file (named binarydem.dat) in the current directory. These two files should be moved to a separate directory (referred to below as the "heights" directory), since this is what Terraformer later expects.
Step 4 - Convert and add the JPEG satellite photo
Terraformer doesn't support JPEG images, so we need to convert the satellite photo to TIFF. Any application that is capable of opening JPEG and saving as TIFF can be used. We used the Windows Imaging application included in Windows 2000 (Start Menu | Programs | Accessories | Imaging). Create a new directory (referred to below as the "images" directory) and put the TIFF file there. This file now has to be referenced from a second index file, in the same way that the elevation data is set up. Copy the index file from the "heights" directory to the "images" directory. Edit this new index file copy and change the name of the referenced binary file to that of your new TIFF file. Now you are set to launch Terraformer to attempt a conversion of this data. It will fail, so read on!
Step 5 – Run Terraformer on the Planet data
Launch Terraformer. Create a new project, giving it a suitable name, for example "coiba". In the "Source data format" drop-down list, select "imex_tems". (This name refers to Ericsson TEMS Cellplanner, which for the purpose of this discussion is equivalent to Planet.) Press the button to the right of the "Source height data" field, and select the "heights" directory. Check the "Use image data" box. Select "image" from the drop-down list. Press the button to the right of the "Source image data", and select the "images" directory. Click the "Analyse input data" button. At this point, Terraformer will complain that the dimensions of the image file do not match the dimensions in its index file. Dismiss the error message, but leave Terraformer running.
The TIFF file is 2048x2048 pixels, and the corresponding value calculated from the information in the index file is 2049x2049. The format of the single line in the index file is:
<file> <xmin> <xmax> <ymin> <ymax> <resolution>
To reduce the perceived size of the grid by one pixel, we need to reduce the max values by one resolution unit, i.e. we need to subtract the resolution value 20 from the third and fifth fields, yielding:
coiba_ls7_2048.tif 400777 441737 808217 849177 20
Open the index file in a text editor, make the change and save the file. If you left Terraformer running, just click the "Analyse input data" button again. This time, after processing that may take several minutes, it should work fine.
From now on, no more hacking or data massaging is necessary, so for the final steps through the Terraformer workflow we refer you to the Terraformer User's Guide.
Acknowledgements
We would like to extend our sincere thanks to the people at vterrain.org