Catalog – Pitney Bowes MapXtreme User Manual

Page 158

Advertising
background image

Chapter 8: Working with Data

Catalog and Tables

MapXtreme v7.1

165

Developer Guide

Table tab = MapInfo.Engine.Session.Current.Catalog.GetTable("MapViewer");

TableInfo ti = TableInfoFactory.CreateTemp("Test",

((MapInfo.Data.GeometryColumn)tab.TableInfo.Columns["Obj"]).CoordSys);

Table tabTemp =

MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);

MIConnection conn = new MIConnection();
conn.Open();
MICommand comm = conn.CreateCommand();
comm.CommandText = "Insert Into " + tabTemp.Alias +

" (Obj, MI_Style) SELECT MI_Point(MI_X(Obj), MI_Y(Obj), '" +
((MapInfo.Data.GeometryColumn)tab.TableInfo.Columns["Obj"]).Coord
Sys.SrsString + "'), MI_Style" + " FROM " + tab.Alias + " WHERE msaname
= 'Minneapolis-St. Paul, MN-WI' AND Not Obj = Null";

MessageBox.Show(comm.CommandText);
int numChanged = comm.ExecuteNonQuery();

mapControl1.Map.Layers.Add(new FeatureLayer(tabTemp));
mapControl1.Map.SetView(mapControl1.Map.Layers["Test"] as FeatureLayer);

Catalog

The Catalog is essentially the manager of the MapXtreme data access model. The Catalog holds a
list of tables that are currently open in the MapXtreme Session. Tables are also opened, created and
closed from the Catalog. The Catalog can be thought of as a single database holding all the tables
opened in it, regardless of their actual data source.

Each MapXtreme Session manages a single Catalog.

Catalog initially contains no tables. When a table is opened, an alias (or name) is assigned to the
table or provided by the caller. The alias is used to identify the table in queries and other operations.

Tables can be mappable (contain a spatial component) or be non-mappable and contain only data
columns. The MapXtreme Catalog can open both types and use either in queries and joins.

Catalog provides facilities for creating new table definitions and enumerating through tables which
are currently opened. Catalog also contains search methods that can be used to access data in
open tables.

The Catalog has an SQL engine that allows you to select, insert, update, and delete tables and data
within tables. The SQL engine allows you to join any tables defined in the catalog (for example,
Native to SQLServer, or SQLServer to Oracle). The Catalog handles the integration from various
sources so you don’t have to. This is a powerful tool when organizing data from various sources.

The MapXtreme Catalog is exposed through the MapInfo ADO.NET Data Provider. Access to tables
and result sets is controlled through this interface. See

MapInfo ADO.NET Data Provider

.

Code Sample

The following example illustrates how to access the Catalog off the MapXtreme Session object,
open some tables and enumerate through all the tables in the Catalog followed by only the editable
tables in the Catalog.

Advertising