beautypg.com

Pitney Bowes MapXtreme User Manual

Page 167

background image

Chapter 8: Working with Data

Table Metadata (TableInfo)

MapXtreme v7.1

174

Developer Guide

Note the use of the ColumnFactory class. This is provided to help you know which arguments are
necessary for different data types. For example, a geometry column requires a coordinate system.

VB example:

Public Shared Sub MapInfo_Data_TableInfoNative()

Dim ti As TableInfoNative = New TableInfoNative("NewTable")
ti.TablePath = "c:\data\Capitals.TAB"
ti.Columns.Add(ColumnFactory.CreateIndexedStringColumn("Capital",_

25))

ti.Columns.Add(ColumnFactory.CreateStringColumn("Country", 30))
ti.Columns.Add(ColumnFactory.CreateDoubleColumn("Pop_Grw_Rt"))

' Make the table mappable

ti.Columns.Add(ColumnFactory.CreateStyleColumn())
Dim Robinson As CoordSys = _
Session.Current.CoordSysFactory.CreateFromPrjString("12, _

62, 7, 0")

ti.Columns.Add(ColumnFactory.CreateFeatureGeometryColumn(Robinson))
' Note we do not need to (nor should we) add a column of type Key.
' Every table automatically contains a column named "MI_Key".

Dim table As Table = Session.Current.Catalog.CreateTable(ti)

End Sub

Create a Temporary Native Table

VB example:

Public Shared Sub MapInfo_Data_TableInfo3(ByVal conn As MIConnection)
Dim ti As TableInfoNative = New TableInfoNative("NewTable")
ti.Temporary = True
Dim col As Column

col = New Column
col.Alias = "FString30"
col.DataType = MIDbType.String
col.Indexed = True
col.Width = 30
ti.Columns.Add(col)

col = New Column
col.Alias = "FInt32"
col.DataType = MIDbType.Int
col.Indexed = True
ti.Columns.Add(col)

col = New Column
col.Alias = "FInt16"
col.DataType = MIDbType.SmallInt
col.Indexed = True
ti.Columns.Add(col)