Examining tab file metadata, Creating a new table, Examining tab file metadata creating a new table – Pitney Bowes MapXtreme User Manual

Page 166

Advertising
background image

Chapter 8: Working with Data

Table Metadata (TableInfo)

MapXtreme v7.1

173

Developer Guide

Examining TAB File Metadata

TAB file metadata is accessible and editable. The TableInfo class can be obtained from the Table to
get information about the table structure.

The following code demonstrates how to get the metadata for an open table. The code also
demonstrates how the geometry column can be used to determine the coordinate system and
bounds of the table. For a code example that returns M and Z values, see MapInfo.Data.TableInfo in
the Developer Reference.

VB example:

Public Shared Sub MapInfo_Data_TableInfo2()

' Get the metadata for an open table
Dim ti As TableInfo = Session.Current.Catalog("states").TableInfo

' Print out some information to the console
Console.Out.WriteLine("Table Alias={0}, Datasource={1}, _

Description={2}, Type={3}", _

ti.Alias, ti.DataSourceName, ti.Description, ti.TableType)

' Print out some information about each column
Dim col As Column
For Each col In ti.Columns
Console.Out.WriteLine("Column {0} Type={1} Width={2}", _

col.Alias, col.DataType, col.Width)

' If the column is a geometry column, print csys and bounds.
If col.DataType = MIDbType.FeatureGeometry Then
Dim geocol As GeometryColumn = col
Dim csys As MapInfo.GeomeTry.CoordSys = geocol.CoordSys
Console.Out.WriteLine("CSys : {0}", csys.MapBasicString)
Dim dr As MapInfo.GeomeTry.DRect = geocol.Bounds
Console.Out.WriteLine("Bounds=({0},{1}),({2},{3})", dr.x1, _

dr.y1, dr.x2, dr.y2)

End If
Next

End Sub

Creating a New Table

The following sections illustrate how to create a permanent native table, a temporary native table,
and a temporary MemTable.

Create a New Permanent Native Table

The MapInfo.Data.Table.TableInfo property for a MapInfo native table returns an instance of
TableInfoNative. A native table is a MapInfo .TAB file. This class may be used to access properties
that are specific to native table types. New instances of this class may be created and used to
construct new tables. See also

Data Sources

.

Advertising