# TopoVista Tile Protocol

Version 2.0

This protocol has been deprecated in favor of TVRP.

This is a simple protocol for serving TopoVista tiles in a manner that allows manipulation by a smart router.

All messages are sent via UDP. For now, we will assume that this is reliable; there is no provision for retransmission.

The server listens on a known port, normally 4742. For each request, it returns a sequence of one or more messages terminating in an EOF message. A failed request receives only the EOF response.

A request message is the string `GET hhhhhhhh comment` encased in a UDP datagram. The `hhhhhhhh` field is an 8-digit hexadecimal encoding (using `0123456789ABCDEF`) of a tile ID as specified below. The comment is ignored but is conventionally the human-readable `xxxUyyyk` form of the tile ID.

Each reply message begins with an 14-byte header:

       bytes 0-3	"TVTP"	magic characters allowing router recognition
       byte 4	2	indicating the protocol version number
       byte 5	sequence number of preceding message, or zero if this is first
       byte 6	sequence number of this message, 1 - 62, or 63 for EOF
       byte 7	sequence number of next message, or zero if this is EOF
       bytes 8-11	32-bit tile ID
       bytes 12-13	tile version number

The tile ID is a big-endian integer containing these fields, beginning with the most significant bit:

         3 bits	tile order (k), less 6; allows 64×64 through 8192×8192 tiles
         5 bits	UTM zone, 1 through 26
        10 bits	X coordinate
        14 bits	Y coordinate

The reply header is followed by either a TopoVista record or by a bitmap in the case of an EOF message. The EOF bitmap is an 8-byte big-endian integer indicating the contents of the sequence. The most significant bit corresponds to message zero, and is always unset because there is no zeroth message. The least significant bit corresponds to message 63, the EOF message, and is always set because the EOF message is never omitted.

INDEX