QUERYING A DATASET CONNECTION
Once you have opened a connection to a dataset, you can ask a number of questions about the dataset and also change a number of the characteristics of the connection itself. All of this functionality is performed through the tsmGet and tsmSet calls; thus providing a neat and extensible way to interact with a connection.
tsmGet takes a connection handle, and a token to describe which
piece of data you want to know about. It then returns the desired
information as an int (you will therefore have to manually cast this
value if the information you requested is not an int). For example,
the following code segment opens a connection and then gets the size
of a single tile (in bytes):
TsmConnection connect;
char *name = "~magic/TileSets/Pyramids/ntc-1-utm-2scene.128.oi";
int tilesize;
connect = tsmConnect( name, "r", NULL );
tilesize = tsmGet( connect, TSM_TILE_SIZE );
tsmDisconnect( connect );
For a list of all of the possible pieces of information that you can
query a connetion on, please refer to the tsmGet manual page (see
below).
One particularly useful piece of information that you can retrieve
is the dataset's "tspec" structure. Tspec stands for Tile Set
Specification and contains all of the details about a dataset,
including its dimensions, georeferencing information, data format,
etc. All of this information is stored in a Pyramid structure. To get
the Pyramid structure for a dataset, you would use a call like:
Pyramid *tspec;
tspec = (Pyramid *) tsmGet( connect, TSM_DATASET_TSPEC );
You can then query the fields of this structure to find out all about
the dataset (see below for the Pyramid manual page which describes all
of this structure's fields). For example:
int x;
tspec = (Pyramid *) tsmGet( connect, TSM_DATASET_TSPEC );
x = tspec->minLevel; /* highest-res pyramid level in dataset */
x = tspec->maxLevel; /* lowest-res pyramid level in dataset */
In addition to asking for information about a dataset, you can change
certain aspects of the connection to that dataset. This is done using
the tsmSet function. For example, if you wanted to test the overhead
of accessing a tile without making any disk/network access, then you
could do the following:
TsmConnection connect;
char *name = "~magic/TileSets/Pyramids/ntc-1-utm-2scene.128.oi";
connect = tsmConnect( name, "r", NULL );
tsmSet( connect, TSM_DONT_READ_TILES, TRUE );
/* try to read some tiles */
tsmDisconnect( connect );
Martin Reddy,
<reddy@ai.sri.com> /
Yvan Leclerc,
<leclerc@ai.sri.com>
Last modified: Wed Aug 23 00:45:30 PDT 2000