File Organization
The file contains binary data consisting of a file header, a number of point records and a number of triangle records. The header must appear first in the file. It is recommended that point records start immediately after the header and triangle records immediately after point records.
Triangle records are optional. The file format may be used to store surface model points only with the intention of triangulating those when actively used.
Data Types
The format definition used the following data types:
C Type |
Size |
Alias |
---|---|---|
char |
1 byte |
|
unsigned char |
1 byte |
BYTE |
long |
4 bytes |
|
unsigned long |
4 bytes |
UINT |
unsigned __int64 |
8 bytes |
UINT64 |
double |
8 bytes IEEE floating point |
|
All data is in big-endian format. For example, the long integer value of 16909060 (or 0x01020304 in hexadecimal) is stored in a way that the first byte has value 4, the second byte value 3, the third byte value 2, and the fourth byte value 1.
All strings must be null-terminated (have value zero to mark end of string).
File Header
The file header is at the beginning of the file and contains 160 bytes. The header fields which are not required and not used must be filled with zero.
Data Type |
Item |
Size |
Required |
char[4] |
Format Recognition String |
4 bytes |
Yes |
UINT |
Format Recognition Value |
4 bytes |
Yes |
UINT |
Version |
4 bytes |
Yes |
UINT |
Header Size |
4 bytes |
Yes |
UINT |
Number of Points |
4 bytes |
Yes |
UINT |
Point Size |
4 bytes |
Yes |
UINT |
Number of Triangles |
4 bytes |
Yes |
UINT |
Triangle Size |
4 bytes |
Yes |
char[40] |
Surface Name |
40 bytes |
No |
char[40] |
Software |
40 bytes |
No |
UINT |
Surface Type |
4 bytes |
No |
UINT |
Coordinate Resolution |
4 bytes |
Yes |
double |
X Origin |
8 bytes |
Yes |
double |
Y Origin |
8 bytes |
Yes |
double |
Z Origin |
8 bytes |
Yes |
UINT64 |
Point Data Position |
8 bytes |
Yes |
UINT64 |
Triangle Data Position |
8 bytes |
Yes |
Header fields:
•Format Recognition String - must contain “TTIN”. Used for file recognition.
•Format Recognition Value - must contain value 20101221. Used for file recognition.
•Version - must contain value 1.
•Header Size - normally set to value 160.
•Number of Points - total number of point records in the file.
•Point Size - size of each point record. Normally set to value 14.
•Number of Triangles - total number of triangle records in the file.
•Triangle Size - size of each triangle record. Normally set to value 26.
•Surface Name - descriptive name for the surface such as “Ground”.
•Software - software which generated the file. For example “TerraModeler”.
•Surface Type - surface type which may be used to categorize models of sub soil layers or other types of terrain surfaces. This is most often zero (= ground).
•Coordinate Resolution - number of integer steps in a real world unit. If the real world unit is meter and the coordinate resolution is 100, each integer step in point record x, y, and z fields corresponds to one centimeter.
•X, Y and Z Origin - center of the coordinate system in real world units.
•Point Data Position - file position where the point records start. File position is relative to the beginning of the file. This should normally be 160.
•Triangle Data Position - file position where triangle records start.
Point Record
Point records store information about the points from which the model is built.
Data Type |
Item |
Size |
long |
X |
4 bytes |
long |
Y |
4 bytes |
long |
Z |
4 bytes |
BYTE |
Break |
1 byte |
BYTE |
Type |
1 byte |
Point record fields:
•X - X coordinate of the point.
•Y - Y coordinate of the point.
•Z - Z coordinate of the point.
•Break - 0 if the point is a random point or the first point in a breakline sequence. 1 if point is meant to be connected by a breakline edge with the previous point record.
•Type - point type. See Point Types for more information.
Each linear breakline feature appears as consecutive point records. The first point of a breakline should have Break = 0 and Type should be non-zero. All additional points of the same breakline should have Break = 1 and Type should be the same as for the first point.
Triangle Record
Triangle records store the actual triangulation and the neighbor relation of the triangles.
Data Type |
Item |
Size |
UINT[3] |
Vertex |
12 bytes |
UINT[3] |
Neighbor |
12 bytes |
BYTE |
Flags |
1 byte |
BYTE |
Domain |
1 byte |
Triangle record fields:
•Vertex - three points in clockwise order. Value 0 refers to the first point record.
•Neighbor - neighboring triangles in clockwise order. Value 0 means no neighboring triangle. Value 1 refers to first triangle record. Neighbor[0] is the triangle on the other side of edge Vertex[0] - Vertex[1]. Neighbor[1] is the triangle on the other side of edge Vertex[1] - Vertex[2]. Neighbor[2] is the triangle on the other side of edge Vertex[2] - Vertex[0].
•Flags - active/excluded/deleted state of the triangle and edge types.
•Domain - region or land type. 0 for undefined or default value.
The different bits in the Flags field have the following meaning:
•Bits 0-1 - triangle state: 0 = active, 1 = auto excluded, 2 = user excluded, 3 = deleted
•Bits 2-3 - type of edge 0: 0 = normal, 1 = soft break, 2 = hard break, 3 = other break
•Bits 4-5 - type of edge 1
•Bits 6-7 - type of edge 2
Coordinate Values
The X coordinate value is normally the same as easting.
The Y coordinate value is normally the same as northing.
The Z coordinate value is normally the same as elevation.
Point records store coordinate values as 32 bit integers to save disc space. To translate integer values into normal projection system coordinate values in meters or feet, the following equations have to be used:
WorldX = XOrigin + X / CoordinateResolution
WorldY = YOrigin + Y / CoordinateResolution
WorldZ = ZOrigin + Z / CoordinateResolution
The Type field in the point record indicates the point type. Valid point types are:
•0 - random point.
•1 - point is part of a soft breakline element.
•2 - point is part of a hard breakline element.
•3 - point is part of a contour line.
•4 - point is an inferred point at the top of a hill or at the bottom of a depression. These points may be automatically generated for hills and depressions when generating a surface from contours.
•5 - point is part of an outer boundary. An outer boundary is defined by a clockwise polygon where the area outside the polygon is invalid. The last point record in the sequence has the same coordinates as the first point record in order to close the polygon. A surface model should not have more than one outer boundary.
•6 - point is part of an inner boundary. An inner boundary is defined by a clockwise polygon where the area inside the polygon is invalid (“hole”). The last point record in the sequence has the same coordinates as the first point record in order to close the polygon.