Map Info Data Access Library Developer Guide
Map Info Data Access Library Developer Guide
Developer Guide
Information in this document is subject to change without notice and does not represent a commitment on the part of the vendor or its
representatives. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including
photocopying, without the written permission of Pitney Bowes Inc., One Global View, Troy, New York 12180-8399.
© 2019 Pitney Bowes Inc. All rights reserved.Pitney Bowes Inc. Pitney Bowes, the Corporate logo, MapInfo, Group 1 Software, and MDAL
are trademarks of Pitney Bowes Inc. or a subsidiary. All other trademarks are the property of their respective owners.
Contact information for all Pitney Bowes Inc. offices is located at:: www.pitneybowes.com
This product contains SpatiaLite v 3.1.0, which is licensed under GNU Lesser General Public License, Version 2.1, February 1999. The
license can be downloaded from: http://www.gnu.org/licenses/lgpl-2.1.html. The source code for this software is available from http://
www.gaia-gis.it/gaia-sins/win-binx86-test/spatialite-3.1.0b-test-win-x86.zip and http://www.gaia-gis.it/gaia-sins/win-bin-amd64-test/spatialite-
3.1.0b-test-win-amd64.zip.
This product contains Feature Data Objects v 3.6.0, which is licensed under GNU Lesser General Public License, Version 2.1, February
1999. The license can be downloaded from: http://fdo.osgeo.org/lgpl.html. The source code for this software is available from http://
fdo.osgeo.org/content/fdo-360-downloads.
This product contains HelpLibraryManagerLauncher.exe v 1.0.0.1, which is licensed under Microsoft Public License. The license can be
downloaded from: http://shfb.codeplex.com/license. The source code for this software is available from http://shfb.codeplex.com.
Table of Contents
In this chapter:
Overview of MapInfo Data Access Library (MDAL) . . . . . . . . . . . . . . 6
Table Properties and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Samples and Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
MapInfo Data Access Library 1.0 Developer Guide
Currently the MapInfo Data Access Library is only available for use with MapInfo
Pro add-ins.
Technical Support
Pitney Bowes offers unparalleled technical support for users of MapInfo software
products. Our Technical Support department provides technical assistance to registered
users of MapInfo software – so you don't need to be an expert in all aspects of our
products in order to get results. See the Pitney Bowes Web site at www.pb.com/software
for information on the tech support offerings.
In this chapter:
Overview of MapInfo.Data Namespace . . . . . . . . . . . . . . . . . . . . . . . 9
Catalog and Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Supported Table Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Working with Catalog and Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table Metadata (TableInfo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
MapInfo ADO.NET Data Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Features and Feature Collections. . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Analyzing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Improving Data Access Performance . . . . . . . . . . . . . . . . . . . . . . . . 52
2 – Working with Data
This chapter is organized to follow the MapInfo Data Access Library (MDAL) Data Access
Model diagram above, and includes these topics:
• Catalog and Tables
• Supported Table Types
• Table Metadata (TableInfo)
• MapInfo ADO.NET Data Provider
• Features and Feature Collections
Data access is central to any MDAL application, and covers a wide variety of topics.
Within the topics listed above are other important topics of information that should not be
overlooked.
Following this chapter are two additional chapters related to data access: Chapter 4
Creating Expressions, and Chapter 5 Accessing Data from a DBMS.
Tables
The Table class is the basic unit of all data access. Table, Column, and all TAB file
metadata information is accessible from a MapInfo Table. Tables may be mappable
(contain a column of type FeatureGeometry) or non-mappable.
Table Aliases
When tables are opened, they can be assigned a name (or alias) which is used while the
table is open for referencing the table. For example, the table may be referred to by its
alias in SQL statements. A table that is opened from a TAB file is assigned a default alias
if no alias is specified. The default alias is based upon the name of the TAB file. This
property is optional and may be set to null. However, it is good practice to assign an alias.
Columns
A Column object identifies the properties of a column in a table, feature, or feature
collection and specifies the column's name (alias), data type, width (for string and decimal
columns), and other properties of the column.
Supported data types include:
Double A floating point number within the range of -1.79E +308 through
1.79E +308. This maps to Double.
DateTime * ‡ Provides a combined date and time value. The DateTime type
is mapped to System.DateTime.
Key Provides a key from a table. This is the data type of the Key
pseudo column on a Table.
CoordSys Provides a coordinate system. This type exists only for the
purposes of binding a coordinate system object to an
MICommand for functions which require the specification of a
coordinate system.
Grid A GridInfo from table's grid column. This is the data type of the
GridInfo object stored in grid column on a Table.
Wms Provides a WmsClient from the table's Wms column. This is the
data type of the WmsClient object stored in the Wms column on
a Table.
† The Time and DateTime types are not supported for MapInfo SQL functions. However, in MapInfo
SQL functions that call/use a DateTime type, the function will return the date portion of the DateTime
value. Please see the MapInfo SQL Reference for more information.
‡ The Time and DateTime types are not supported for MapInfo SQL functions. However, in MapInfo
SQL functions that call/use a DateTime type, the function will return the date portion of the DateTime
value. Please see the MapInfo SQL Reference for more information.
Native(X) MS SQL
MDAL TAB Files ADO.NET Oracle (OCI) Server GeoPackage
Time Time
The following sections provide you with MI_Key, MI_Geometry, and MI_Style column
information.
MI_Key
All tables have a pseudo column named MI_Key which returns instances of Key. The
MI_Key pseudo column is similar in concept to the rowid pseudo column in MapInfo
Professional and MapBasic. Unlike rowid, this column is not a numeric column. A Key
instance may be converted to or from a string literal.
MI_Geometry
MI_Style
Tables with a Geometry column also have a column with the name “MI_Style”, or if not
found, from the first column with type MIDbType.Style. This column is used to hold the
style information for Geometry objects such as line width for polygons and symbol size for
points. This column cannot be updated independently. The Style and Geometry columns
must be updated at the same time.
The MI_Style column is created automatically when you are opening a table in MapInfo
native format (.TAB). For all other table types, you must specifically create the column. If
you use MapInfo.Data.ColumnFactory.CreateStyleColumn it will create a column with the
name (alias) of "MI_Style" and a data type of MIDbType.Style.
When using MISQL to insert rows into a table, be sure to include the MI_Style column in
the insert statement. See the code example below:
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);
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 MapInfo Data Access Library (MDAL) data
access model. The Catalog holds a list of tables that are currently open in the MDAL
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 MDAL 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 MapInfo Data Access Library (MDAL) 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 MDAL 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 through the MDAL Session
object, open some tables and enumerate through all the tables in the Catalog followed by
only the editable tables in the Catalog.
VB example:
Public Shared Sub MapInfo_Data_Catalog()
’ Catalog is accessible off the Session object
’ Now enumerate through only tables that are editable (not ReadOnly)
Dim tEnum As ITableEnumerator = _
catalog.EnumerateTables(TableFilterFactory.FilterEditableTables())
While tEnum.MoveNext()
Console.Out.WriteLine("Table: {0}", tEnum.Current.Alias)
End While
Session.Current.Catalog.CloseAll()
End Sub
Catalog.GetTable
The MapInfo.Data.Catalog.GetTable method returns the Table object referenced by the
TableAlias parameter. This must be a table which has already been opened. If no such
table is found (or the table has subsequently been closed), then the method returns null.
Catalog.Item (Indexer)
MapInfo.Data.Catalog.Item property can be used as an indexer for locating a Table by its
Alias. This is functionally equivalent to using the Catalog.GetTable method but generates
code that is easier to read. The Alias must specify a table which has already been
opened.
VB example:
End Sub
TableEnumerators
Table enumerators may be obtained through the various overloaded EnumerateTables
methods. A table enumerator may be created with a filter. The filter determines which
tables are actually included in the enumeration while the enumerator simply provides the
mechanics of enumeration. You can create your own table filters to use in the
TableEnumerator. You can also create your own table enumerator by implementing the
ITableEnumerator interface.
VB example:
Public Shared Sub MapInfo_Data_Catalog3(ByVal catalog As Catalog)
Dim te As ITableEnumerator = _
catalog.EnumerateTables(TableFilterFactory.FilterEditableTables())
While te.MoveNext()
Dim tbl As Table = te.Current
End While
End Sub
Closing a Table
Three methods are available to close tables. MapInfo.Data.Catalog.CloseAll closes all
open tables while Catalog.CloseTable closes a single, open table. The Table class also
has a Close method.
Packing a Table
The MapInfo.Data.Table.Pack method removes records from the table that were
previously marked for deletion. When the table is packed, the table's TablePacked event
is raised. The arguments for the event indicate whether or not the table's keys changed
as a result of the pack (which would be caused by removing deleted records). Keys only
change if the PackType includes RemoveDeletedRecords and if there actually were
deleted records in the middle of the table. If the only deleted records in the table are at the
end of the table, then no keys are changed. The event does not indicate that keys were
changed.
Since ResultSet tables hold collections of keys, these are vulnerable to pack
operations on the table from which they were derived. The ResultSet is no longer
valid if the keys have changed.
TableInfo is used to open tables and create new tables. It is also used for retrieving
information about the open table.
Classes that derive from TableInfo include provider-specific metadata. There is a
TableInfo implementation for every MapInfo Data Access Library (MDAL) supported table
type. See Data Sources.
TableInfo instances may be constructed manually, or from a .TAB file definition (without
opening the table), as shown below.
TableInfo.CreateFromFile(…)
TableInfo contains properties for enabling Table Services, including caching and making a
table mappable via a spatial schema. See Working with the Cache and Making Tables
Mappable.
MapInfo Data Access Library (MDAL) provides table column metadata support for M and
Z values. This feature is useful when you want to know whether geometries of a particular
data provider can support 3D and Measured values without evaluating its individual
geometries.
Metadata for a table can be accessed from the table's TableInfo property. From the table
metadata you can access the GeometryColumn to interrogate if the table supports M or Z
values and what the range of values for that table is if the range is known. For more
information on support for M and Z values, see Support for M and Z Values.
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
End Sub
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"))
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
col.Indexed = True
ti.Columns.Add(col)
ti.Columns.Add(ColumnFactory.CreateIndexedStringColumn("Capital",_
25))
ti.Columns.Add(ColumnFactory.CreateStringColumn("Country", 30))
ti.Columns.Add(ColumnFactory.CreateDoubleColumn("Pop_Grw_Rt"))
TableAddColumns is not supported for the following table types: Server, View,
Seamless, AdoNet, ResultSet, or Drilldown. MapInfo Data Access Library (MDAL)
checks for the table and throws an exception if it encounters one of these table
types.
VB example:
Public Shared Sub MapInfo_Data_TableAddColumns(ByVal miTable As Table)
Dim NewCols As Columns = New Columns
NewCols.Add(New Column("PopDensity1990", "Pop_1990 / _
MI_Area(Obj, 'sq mi', 'Spherical')"))
NewCols.Add(New Column("PopDensity2000", "Pop_2000 / _
MI_Area(Obj, 'sq mi', 'Spherical')"))
miTable.AddColumns(NewCols)
End Sub
The expression string “Pop_1990 / MI_Area(Obj, 'sq mi', 'Spherical')” represents derived
information that will be placed in the temporary column. It says ‘For each record divide
population by area in square miles to yield the population density.’ The SQL function
MI_Area () in the expression will derive the area from the geometry of the record.
Using the AddColumns method may offer performance improvements in desktop
applications where the join can be performed once, rather than on each subsequent
access (as in the case of a view).
For more information and code examples, see the MapInfo.Data.Table.AddColumns class
in the Developer Reference Help system.
For more information on creating expressions, see Chapter 4 Creating Expressions.
Data Sources
The following table lists the data sources supported by MapInfo Data Access Library
(MDAL). Each type of data source is accessed by a specific data provider called TableInfo
class, that is derived from MapInfo.Data.TableInfo. For a short summary of each data type
see Supported Table Types.
dBase TableInfodBase
MS Access TableInfoMSAccess
ASCII TableInfoAscii
Seamless TableInfoSeamless
Raster TableInfoRaster
Grid TableInfoGrid
WMS TableInfoWMS
ADONET TableInfoAdoNet
MemTable TableInfoMemTable
View TableInfoView
ResultSet TableInfoResultSet
TileServer TableInfoTileServer
GeoPackage TableInfoGeoPackage
NativeX TableInfoNativeX
TableInfoServer will open a connection to the server, query the table's metadata, and
create the appropriate table definition with any spatial characteristics that are defined on
the remote server. This tends to be the best performing method with remote data.
Internally, MDAL can access only the data necessary to perform the current operation.
During a map draw, MapInfo Data Access Library (MDAL) will construct a query that
returns only the geometry column, and not the data columns. This minimizes the network
traffic. If caching is on, then this is only an issue for the first access, since all subsequent
requests will come from the cache. See Chapter 5 Accessing Data from a DBMS.
pointer back to the original table. These are useful for temporary layers for maps and
containers for return values of processes such as a geocoding or routing result.
MemTable access and map rendering performance is equivalent to native tables.
Result sets are a great tool when you need access to a defined set of rows and when you
need to get data from the source. If the source data may change during your session then
this method allows you to see the results if the data source supports concurrent access.
Since MemTables are copies of data they are a static set of data rows and will not reflect
changes from the original data sources.
VB example:
Public Shared Sub MapInfo_Data_TableInfoAdoNet(ByVal connection As _
MIConnection)
' Create a new DataTable.
Dim dt As DataTable = New DataTable("CityData")
Dim dc As DataColumn
dc = dt.Columns.Add("City", Type.GetType("string"))
dc.MaxLength = 30
dc = dt.Columns.Add("Country", Type.GetType("string"))
dc.MaxLength = 30
dc = dt.Columns.Add("Continent", Type.GetType("string"))
dc.MaxLength = 30
dc = dt.Columns.Add("Population", Type.GetType("string"))
value. For this type of table, it is required to tell the table which column(s) constitute the
key. This is accomplished by specifying the KeyType as Explicit and setting the
KeyColumns property.
There are many operations inside the MapInfo Data Provider which require the retrieval of
a specific record by key (also referred to as a key fetch). Select statements with a where
clause of the form MI_Key = '5' is a simple example in which we need to retrieve the
record whose MI_Key column can be represented by the string literal '5'. Key retrievals
are very common in mapping selections, labeling, and scrolling in a MIScrollableReader
(in which case the reader may be scrolling through a list of key values). MapInfo tables
are dependent upon the ability to efficiently fetch records by key value. Just as the
Command-based form of the ADO.NET table does not read, parse, or modify the
CommandText of the IDbCommand object that defines the table (the “Sequential”
IDbCommand), it has no ability to modify the IDbCommand object to fetch a specific
record. Thus, a second IDbCommand object must be supplied for this purpose. The
“FetchByKey” IDbCommand object must meet the following requirements:
• When ExecuteReader is called on this command object, it must produce a data reader
that has the same columns as the sequential command object and in the same order.
• The FetchByKeyCommand must contain a Parameters collection and must contain
one parameter for each member of the key. For example, if the TableInfo.KeyColumns
specifies a key as consisting of the “city” and “state” columns, then the
FetchByKeyCommand must contain two parameter objects. The first parameter object
is assigned a value representing the first column specified in the
TableInfo.KeyColumns collection (e.g., a value for “city”), the second parameter object
is assigned a value representing the second column specified in the
TableInfo.KeyColumns collection (e.g., a value for “state”), and so on. When
ExecuteReader is called on the FetchByKeyCommand, the reader must return the
record which represent s the specified key.
This example illustrates how to create a MapInfo Table that accesses data through the
ADO.NET connected command objects.
VB example:
Public Shared Sub MapInfo_Data_TableInfoAdoNet2(ByVal connection _
As MIConnection)
Dim ti As TableInfoAdoNet = New TableInfoAdoNet("EuropeanCities")
Dim _conn As OleDbConnection = New _
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data _
Source=C:\Data\EuropeCities.mdb")
Dim selectQuery As String = "SELECT City, Country, Continent, _
Pop_1994 FROM EuropeCities"
Dim _OleDbCommand As OleDbCommand = New OleDbCommand(selectQuery)
_OleDbCommand.Connection = _conn
' Tell the table which column(s) constitute a key - for this table
' it is acompound key consisting of values from the City and County
' columns.
Dim sc As StringCollection = New StringCollection
sc.Add("City")
sc.Add("Country")
ti.KeyColumns = sc
ti.KeyType = KeyType.Explicit
' Now the MICommand object may be used to select data from the table
' (by the name EuropeanCities since that is the alias we assigned to
' it). The data in thistable may be joined with any other table and
' it may be used as source data in a call to AddColumns to populate
' temporary columns with data from this table.
End Sub
Data Binding
Data binding is the process of bringing data from a data source into MapInfo Data Access
Library (MDAL). Data binding of external data (ADO.NET and other legacy sources) to
MapInfo.Data.Table is accomplished by opening an ADO.NET DataTable as a Table using
TableInfoAdoNet. The table can then be joined with another table, joined to itself or use
Table.AddColumns to bind columns to a second table.
To join a table to itself, following this example:
Select ... From T as A, T as B Where A.X = B.Y
For example, if the data is stored in a dBase file, Microsoft Access table, or is accessible
through ODBC or Oracle's OCI interface, it is recommended that those TableInfo types be
used to access the data. Data which cannot be accessed through one of these types of
tables, but that can be loaded into a DataTable or is accessible through some ADO.NET
Data Provider that implements the Command, Parameter and DataReader object types
can still be accessed by the Catalog.
An application may need to make data available as a MapInfo native table so that queries
can be executed to join the data with other MapInfo table data. It may also need to be
made available to the Catalog so it can be used as the source data in a call to the
Table.AddColumns.
View Tables
A view is a way to relate information from one or more tables based on a named select
statement. The Catalog allows you to create views based on any table definition. View
tables have the following characteristics:
• The data is not copied.
• Access to views always accesses its base tables.
• View is an MapInfo SQL Select Statement with a name (Alias).
• Queries may be joins (forms composite keys).
• Membership in the View is live.
• Exception: Views that aggregate cache the data. Data changed events trigger
recomputation.
For more information and code examples, see the MapInfo.Data.TableInfoView class in
the Developer Reference Help system.
Result Sets
ResultSets are similar to view tables in that both are defined using a MapInfo SQL select
statement and have an associated name (Alias). ResultSets, however, have a fixed
membership of records based on the evaluation of the where clause (if any) at the time
the result set is created. Any access to the data in a ResultSet always reflects the data in
the source table. However changes to the source data will not cause the ResultSet to
add/remove a record based on the original where clause. ResultSets manage a set of
keys internally.
In general ResultSets are lightweight and temporary. Some of the characteristics of result
sets are:
• The data is not copied.
Source Rows
Source rows represent a match between the table records involved in Table.AddColumns.
When adding temporary columns to a table, multiple records from the data source may be
aggregated together to compute a value for each record in the destination table (also
referred to as the bind table). The MapInfo.Data.SourceRows class is a collection of
SourceRows that identify the records from the data source that were aggregated
together,
SourceRows only exist if the BindType property is DynamicCopy, which indicates that
changes to the source data are propagated to the temporary column automatically.
Table.AddColumns is not supported for the following table types: Server, View,
Seamless, AdoNet, ResultSet, or Drilldown.
The GeoDictionary
The GeoDictionary maintains information about which map entities can be matched to
which information. The GeoDictionaries class is a collection of GeoDictionary objects.
The MapInfo.Data.GeoDictionary namespace provides support for data autobinding by
being a programmatic representation of the GeoDictionary file. The GeoDictionary file
contains information about tables (TAB files only). The GeoDictionary is used to
automatically determine the table to which application data should be bound. The
GeoDictionary is persisted in a file (typically GeoDict.DCT) and is maintained using the
GeoDictionaryManager utility application.
SpatialSchemaXY
SpatialSchemaXY uses the X and Y values of each record in the table to construct point
objects and store them in a temporary column known as MI_Geometry. This spatial
schema may be applied to tables of any data source except Seamless, View, and
ResultSet.
By having a GeometryColumn, the table can now be displayed as a layer in a Map and
used for spatial analysis.
SpatialSchemaXY has the following characteristics:
• The Geometry column is editable.
SpatialSchemaPointRef
This spatial schema uses a value in the table's data to create a Point geometry object by
matching the value against an equivalent value in a mappable table.
For example, if your table of customers contains addresses with postal codes, the
customer records can be tied to the spatial points in a postal code reference table.
SpatialSchemaPointRef is actually a join between two tables, one containing data and the
other containing a join column and an object column. The join column contains the same
values as the data column in the non-mappable table, such as postal codes. The result of
' the column in RefTable which will match the MatchColumn in my data
pr.RefColumn = "zipcode"
' Now set the spatial schema information before opening the table.
ti.SpatialSchema = pr
Dim table As Table = Session.Current.Catalog.OpenTable(ti)
End Sub
The following sections present the key interfaces and classes for accessing data via the
MapInfo ADO.NET Data Provider.
• MIConnection
• MICommand
• MIDataReader
• MapInfo SQL
MIConnection
An MIConnection represents a connection to the Catalog. The connection provides a
starting point for issuing SQL commands and obtaining results. Whereas most data
provider connections allow the user to immediately begin issuing queries or other
commands against existing tables (or schema objects), the MapInfo ADO.NET Data
Provider initially has no tables available. Tables need to be opened or created before they
can be accessed. When opened, a name (alias) can be associated with the table which is
used when resolving identifiers in the query engine.
Connections are not pooled in the MapInfo Data Provider and there is no connection
string required to create a new connection.
The MapInfo.Engine.Session class creates and initializes the Catalog which may be
accessed through the Session.Current.Catalog property. The MIConnection.Open
method obtains a reference to the Catalog using the Session.Current.Catalog property
and the MIConnection.Close method sets the internal reference to the Catalog to null.
VB example:
Public Shared Sub MapInfo_Data_MIConnection()
Dim connection As MIConnection = New MIConnection
Dim command As MICommand = connection.CreateCommand()
command.CommandText = "Select * From States Where Pop > 1000000"
connection.Open()
Dim reader As MIDataReader = command.ExecuteReader()
Dim i As Integer, n As Integer = reader.FieldCount
For i = 0 To n - 1 Step i + 1
Console.Out.Write("{0}\t", reader.GetName(i))
Next
Console.Out.WriteLine()
While reader.Read()
For i = 0 To n - 1 Step i + 1
Dim o As Object = reader.GetValue(i)
If o Is DBNull.Value Then
Console.Write("null\t")
Else
Console.Write("{0}\t", o.ToString())
End If
Next
Console.Out.WriteLine()
End While
reader.Close()
command.Dispose()
connection.Close()
End Sub
MICommand
MICommand provides the necessary interface for executing SQL commands against the
MapInfo Data Provider. MICommand creates MIDataReader and MIScrollableReader
instances for obtaining data via the ExecuteReader and ExecuteScrollableReader
methods, respectively.
Supported Commands
The commands that are understood by the MICommand are:
Select
SELECT < select_list >
FROM { < table_source > } [ ,...n ]
Insert
INSERT [INTO] { table_name } [ ( column_list ) ]
{ VALUES ({expression | NULL}[, ...n]) | query_specification
Update
UPDATE { table_name }
SET {{ column_name } = { expression | NULL }} [, ...n]
[WHERE < search_condition > ]
Delete
DELETE [FROM] { table_name } [ WHERE < search_condition > ]
expression
Is a column name, pseudo column, column alias, constant, function, or any combination
of column names, column aliases, constants, and functions connected by an operator(s).
Column names and pseudo columns may be prefixed with a table name or a table alias
followed by the dot (“.”) character.
group_by_expression
Is a reference to a column in the select list - either an exact copy of the select list
expression, the alias, a 1-based number indicating the position of the column, or coln
where n is a number representing a column.
order_by_expression
Is a reference to a column in the select list - either an exact copy of the select list
expression, the alias, a 1-based number indicating the position of the column, or coln
where n is a number representing a column.
For more information on expressions, where they are used and how to create them, see
Features and Feature Collections.
ExecuteFeatureCollection
The ExecuteFeatureCollection method in the MICommand class is the bridge between
the MapInfo ADO.NET Data Provider and the Feature object model. This method
executes command text (SQL statements) against the data source connection, and builds
an IResultSetFeatureCollection. The Feature model is discussed in Features and Feature
Collections.
MIDataReader
The MIDataReader provides forward-only, read-only access to the data returned from
executing a SQL Select statement. To create a MIDataReader, you must call the
ExecuteReader method of the MICommand object, rather than directly using a
constructor.
The MapInfo Data Provider allows multiple MIDataReader instances to be in use on the
same connection. However, if the Table being accessed resides on a Microsoft SQL
Server database, only one MIDataReader may be open at a time.
IsClosed and RecordsAffected are the only properties that you can call after the
MIDataReader is closed.Although the RecordsAffected property may be accessed while
the MIDataReader exists, always call Close before returning the value of
RecordsAffected to ensure an accurate return value.
You must explicitly call the Close method when you are through using the MIDataReader.
When accessing the DataReader through the IEnumerator or IFeatureEnumerator
interface, Close() is automatically called when MoveNext() returns false. Only one
enumerator can be used on a DataReader.
The MIDataReader provides a means of reading a forward-only stream of rows from the
MapInfo data provider. This cursor type is the best performing for accessing a selection of
rows since there is little setup or overhead.
MapInfo SQL
The MapInfo SQL Language allows you to add powerful analytical processing to your
MapInfo Data Access Library (MDAL) application. MapInfo Data Access Library (MDAL)
exposes SQL processing to users via the MapInfo ADO.NET Data Provider for accessing
data (specifically the MICommand object). Expressions are also used for labeling,
thematics, legends, AddColumns, Feature searching, and Selection processing.
MapInfo SQL is standardized based on SQL-3 Specification. For example, you will find
that:
• String constants are enclosed in single quotation marks
• Identifiers may be enclosed in double quotation marks
• Select has no relationship to the Selection
A complete reference including code examples for the MapInfo SQL language is provided
in the MapInfo SQL Reference, which you can view directly from Visual Studio’s Help
system.
Feature
Features are described by their geometry, style, data source, key and attributes. Typically
a feature is a row in a table. A feature’s geometry is a FeatureGeometry object.
FeatureGeometries can cover a given area (MultiPolygon), a location (Points,
MultiPoints); and distance (MultiCurves, LegacyArcs). Additional Geometry classes that
derive from FeatureGeometry and are used for map features are
FeatureGeometryCollection and LegacyText. (Rectangle, rounded rectangle and ellipse
objects also derive from FeatureGeometry, but are used primarily for cosmetic display
purposes.)
One of the main uses of computerized maps is to gather information about the features.
In MapInfo Data Access Library (MDAL) features are returned in FeatureCollections by
any of several methods, either created from scratch using a schema, selected using
selection tools or methods or by searching the Catalog for those that meet a specific set
of criteria.
You can force a Load using the Load method. Changes made to the Feature are not
reflected in the underlying table (if there is one) until the Feature is saved back to the
table. This is done using the Update method, or UpdateFeature or InsertFeature. You can
throw away any edits done to the Feature object before it is saved using the DiscardEdits
method.
A Feature has a schema that describes the attributes of the Feature. The Columns
property describes the schema.
The default feature enumerator for a table uses an MIDataReader internally with the
following command:
command.CommandText = "Select MI_Key, * From \"" + table.Alias + "\"";
To retrieve a subset of the features in a table, use one of the Catalog.Search methods or
use one of the MICommand.ExecuteFeatureCollection methods.
Feature Collections
Feature collections are a group of Feature objects. All Features in a collection share the
same Schema (columns). The Feature collection has a schema which is the schema of all
of its member feature instances. Some Feature collections own their Features while other
Feature collections maintain references to Features.
The following code sample shows two ways to search for the same thing, in this case,
cities in New York.
// Using SQL
command.CommandText = "Select Obj From States Where state = ‘NY’;
FeatureGeometry nyGeom = command.ExecuteScalar() as FeatureGeometry;
command.CommandText =
"SELECT * FROM Cities WHERE Obj within @newyork";
command.Parameters.Add("@newyork", nyGeom);
MIDataReader reader = command.ExecuteReader();
// or… to get a FeatureCollection
IFeatureCollection fc = command.ExecuteFeatureCollection();
// Using Features
Feature fNY = catalog.SearchForFeature("States", _
SearchInfoFactory.SearchWhere("state='NY'"));
SearchInfo si = SearchInfoFactory.SearchWithinFeature(fNY, _
ContainsFilter.ContainsType.Centroid);
IDynamicFeatureCollection dfc = _
catalog.Search("Cities", si) as IDynamicFeatureCollection;
Console.Out.WriteLine( _
"There are {0} cities whose centroid is within NewYork." _
dfc.Count);
SQL searches are more fully discussed in MapInfo ADO.NET Data Provider. The
following sections focus on searches using the Catalog and SearchInfo.
SearchInfoFactory
Methods Behavior
SearchNearest Returns the rows with table geometries that are closest
to the given search point.
SearchInfoFactory
Methods Behavior
Analyzing Data
Once your data is available in the Catalog, you will want to analyze it to meet your
business objectives. The Catalog has an SQL processor that allows you parse and
aggregate your data. Here you have two options:
• OGC object-based query interface
• ADO.NET SQL-based interface
The diagram below shows the relationship between the two.
Group 1 shows the OGC query interface. Use these objects to construct a query. The
interface allows you to create queries to filter columns and rows, as well as add spatial
and non-spatial conditions. The queries interact through the Search methods off those
query objects to return data readers and result sets. Use these objects if you are more
comfortable with object-oriented programming and less so with SQL syntax. See
SearchInfo and SearchInfoFactory.
The ADO.NET interfaces, shown in group 2, use the defined ADO.NET model to allow
access via the MapInfo SQL language. The ADO.NET interfaces use SQL syntax to
interact with the Catalog. In this instance you need to generate the SQL statement and
assign it to the MICommand object. These objects use the Execute command to return a
data reader or result set. See MapInfo ADO.NET Data Provider.
Both the OGC query-based and ADO.NET command-based approaches use the Catalog
(group 3) to organize the data sources as a response to the object or SQL query. The
object-based query API will generate SQL and pass this to the Catalog for processing. In
some instances you may be able to generate more efficient SQL by hand, but the objects
are well defined and the interfaces restrict how you interact so the SQL tends to be
optimal. If you are comfortable with the SQL language using the ADO.NET method may
be more comfortable. But if you are inexperienced with SQL then the OGC object based
query will work just as well.
The MapInfo SQL syntax is defined in the SQL Reference which ships with MDAL. The
language is based on SQL3 and has special MapInfo operators defined for spatial
analysis. These operators begin with the MI_ prefix.
A MemTable also allows you to store data from various sources into one table. This table
type stores data in a combination of memory arrays and temporary disk storage. When
data is added, the MemTable makes a copy of the data and does not have a key or
pointer back to the original table. These are useful for temporary layers for maps and
containers for return values of processes such as a geocoding or routing result.
MemTable access and map rendering performance is equivalent to native tables.
Result sets are a great tool when you need access to a defined set of rows and when you
need to get data from the source. If the source data may change during your session then
this method allows you to see the results if the data source supports concurrent access.
Since MemTables are copies of data they are a static set of data rows and will not reflect
changes from the original data sources.
• Use result sets for intermediate results or operations where you manage keys. These
are very light weight and afford quick direct access back to the original data.
In this chapter:
Session Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Selection Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Selection Code Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Event Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
3 – Working with Core MDAL Classes
Session Interface
The ISession interface is the starting point for all applications integrating MDAL. It
manages the initialization of resources needed for a MDAL application.
An instance of ISession holds components of the object model such as the DataAccess
engine, MapFactory, CoordSysFactory so that the application can do work. The following
diagram illustrates the classes that implement ISession interface.
For an ASP.NET application each client request has its own ISession instance. This
instance resides in the calling context and is available throughout the lifetime of the
client's request.
For a single-threaded desktop application there is only one instance. On a multi-threaded
desktop application there is one instance per thread.
The MapInfo.Engine.Session class provides access to the ISession object. To get the
current ISession instance, access the MapInfo.Engine.Session.Current property.
Session.Dispose()
Session.Dispose() disposes the ISession instance that is accessible through the
Session.Current property. This method is used only for multi-threaded desktop
applications.
Do not use this for single-threaded desktop applications. For single-threaded desktop
application, Dispose is called automatically when the application is shutdown or when the
AppDomain using MDAL is unloaded.
Selection Class
A Selection is a collection of IResultSetFeatureCollection objects that holds lists of
features. These features are a subset of rows in a table. They could be property
boundaries, street networks, cell tower locations, or natural features such as rivers. They
are typically drawn with special highlighting when they display in a Map. There can only
be one IResultSetFeatureCollection for a given table in a Selection.
There can be more than one Selection in a ISession. The Selections collection contains
all of the selections in the application. There is always at least one selection, known as
the DefaultSelection.
Each Selection must have a name and unique alias. By default, map selection tools
modify the Selection when used. Each tool can be set to use any particular Selection.
A selection in MDAL is not a copy; it is a reference to an IResultSetFeatureCollection for
a given table in a Selection. If you attempt to modify a Selection after you have closed the
table that you are working with, the reference to the IResultSetFeatureCollection will be
invalid, causing an exception.
Features can also be selected through search methods from the MapInfo.Data.Catalog
class which returns IResultSetFeatureCollection collections. A Selection object can be
passed into a search, which can be used to populate or change a Selection.
Features can also be selected via the ExecuteFeatureCollection method from the
Data.MICommand class. In this case, you would execute SQL commands against the
MapInfo Data Provider.
For more information on features, tables, the Catalog, and the MICommand see Working
with Data.
SelectionChangedEvent
A delegate method is attached to the SelectionChangedEvent in order to receive
notification that this selection has changed. For example, if a record is added, the
SelectionChangedEvent is fired.
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear()
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Add(irfc)
irfc.Close()
nCount = fc.Count
End If
End Sub
You can also perform selection operations using MapInfo SQL queries and with the
ADO.NET data provider. See Chapter 2 Working with Data.
Event Arguments
The MapInfo.Engine namespace contains various event argument classes that provide
data for events. Refer to the online help for more information. Some of the event
argument classes include:
• CollectionCancelableEventArgs – Provides data for a collection event that can be
cancelled.
• CollectionEventArgs – Provides data for a collection event.
• NodeSelectionChangedEventArgs – Fires these event arguments when the node
selection changes.
• SelectionChangedEventArgs – Other objects can attach delegates to this event to get
notified when a selection changes.
Exceptions
The Engine namespace contains various exception classes. Refer to the online help for
more information. Some of the exception classes include:
• ResourceNotFoundException – Throws this type of exception when the requested
object is not found in the Resource table.
• ResourceTypeMismatchException – The exception that is thrown when the object
read from Resources was not of the expected type.
• TimeoutException – The exception is thrown on Current timeout while waiting for a
pooled ISession to become available.
In this chapter:
Expressions Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Creating Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Where Clause – Boolean Expressions . . . . . . . . . . . . . . . . . . . . . . . 62
Functions In Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Expression Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
4 – Creating Expressions
Expressions Overview
Expressions are statements that are used to describe and format data. For example, in
English, an expression might read like “a median income of more than $50,000, or
“female percent of population.”
Expressions are formed using column names, constants (i.e., specific data values), along
with functions and operators that act upon the columns and constants. The operators and
functions are defined in the MapInfo SQL Language, developed to support MapInfo .NET
supported products. For details, see the MapInfo SQL Reference via the Help Viewer in
Visual Studio.
Use expressions to make the most of your data. By using expressions you can:
• Show only the columns and rows of data that interest you.
• Derive new columns by calculating new values based on the contents of your existing
columns.
• Aggregate data to work with subtotals instead of the entire table.
• Combine data from two or more tables into one results table.
Many of the data sets you will use include more objects and information than necessary
for your projects. In many cases it is easier to work with a subset of the complete data
product. For example, if you were tracking crime statistics for a certain county by census
tract, you would not need the census tracts for the entire state. You would use an
expression to extract just the census tracts for the county.
Expressions are used throughout MDAL, in the following areas:
• SQL statements (select, insert, update, delete, group by, order by)
• SQL functions that take expressions as an arguments (e.g., the geometry argument in
MI_Area() is an expression that returns a geometry object.)
• Adding columns (MapInfo.Data.Table.AddColumn creates a temporary column based
on an expression.)
• Feature searches (SearchInfo and SearchInfoFactory)
Creating Expressions
The simplest possible expression consists of a constant, such as “2” (numeric example)
or “Friday” (text example).
Other simple expressions consist of a column name, for example:
POP_2000
STATE
When you request specific multiple columns in a select statement, for example, these
columns together are known as an expression list.
Select colA, colB, colC from Table1, Table2
Select colA/2, ColB/ColC from Table1
You can also write expressions that perform mathematical operations on your data.
For example, RENT + UTILITIES is an expression that adds two columns together. This
expression could be used in a SQL statement to find all apartments that have a total cost
of less than $800 per month.
Supported operators in MapInfo SQL are defined in the MapInfo SQL Reference.
Boolean expressions are used in the “where clause” of an SQL statement. The where
clause is the expression that controls the rows that are returned (the rows that result in
True).
For example, the boolean expression in this statement follows WHERE. Only objects in
the Europe table that fall within the boundary of France will be returned as True.
"SELECT * FROM Europe WHERE MI_Geometry within @France";
Functions In Expressions
Functions in MapInfo SQL are used to create even more complex expressions to retrieve
data that meets specific criteria. For example, MapInfo SQL supports many of the usual
database functions that work with strings, dates/time, and numbers,
The most powerful functions in MapInfo SQL are those that take advantage of the spatial
nature of mapping data. These geographic functions are used to create new geometries,
measure area and length, return spatial information, validate spatial relationships among
geometries, and others. Supported functions are defined in the MapInfo SQL reference.
An example of using a function in an expression might be when you wish to look at the
area of a table of boundaries, such as school districts. Use the function MI_Area() to
return the area of each record in the table.
Additional examples of functions in expressions are found in the Expressions Examples
section below.
Expression Examples
The following highlights some uses of expressions.
The following examples make selections based on Time and Date columns in the table.
This example will select all crime records from a "CrimeActivity" table where the crime
occurred between 12:00:00 AM and 6:00:00 AM:
SELECT * FROM CrimeActivity WHERE CrimeTime BETWEEN '12:00:00 AM' AND '6:00:00
AM'
Where CrimeTime is a Time column that stores the time at which the crime occurred.
This example will select employee Names from an "Employee" table who were born
before December 31, 1970.
SELECT Names FROM Employee WHERE BirthDay < '12/31/1970 12:00:00 AM'
This expression uses a MapInfo SQL special keyword reserved for geographic objects
called ‘Obj’. This keyword describes the geometry of the object such as its coordinate
system and bounds. This keyword is compatible with previous versions of MapX and
MapInfo Professional. It is equivalent to the column name MI_Geometry.
Note that km and Spherical are enclosed in single quotes. In MapInfo SQL, string literals
must be enclosed in single quotation marks while identifiers such as column names, table
names, aliases, etc.) should be enclosed in double quotation marks, but only needed if
the parsing logic is unable to correctly parse the identifier. This would include identifiers
that have spaces in their names or other special characters.
To find features that fall outside the buffer, the expression would look like:
NOT Obj CentroidWithin MI_Buffer(Obj, 5, ‘km’, ‘Spherical’, 24)
For more information on adding columns, see Adding Expression Columns to a Table.
MapInfo.Engine.Session.Current.MapFactory(0).SetView(fc.Envelope)
' Set the view of the first map.
For more information on the Feature class and search methods, see Features and
Feature Collections.
In this chapter:
Accessing Remote Spatial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Accessing Remote Tables Through a .TAB File . . . . . . . . . . . . . . . . 67
Accessing Remote Tables Without a .TAB File. . . . . . . . . . . . . . . . . 67
Mapping DBMS Data with X/Y Columns. . . . . . . . . . . . . . . . . . . . . . 68
Accessing Data from Oracle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Accessing Data from MS SQL Server . . . . . . . . . . . . . . . . . . . . . . . 72
DBMS Connection String Format . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Defining Mappable Tables in Server Table Queries . . . . . . . . . . . . . 77
Accessing Attribute Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Performance Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Working with the Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
The MapInfo_MapCatalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Adding Rows to the MapInfo_MapCatalog . . . . . . . . . . . . . . . . . . . . 86
Per-Record Styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
5 – Accessing Data from a DBMS
End Sub
Geometry Conversion
The table below shows the translation from MDAL objects to Oracle Spatial
(SDO_GEOMETRY).
Point 1 POINT
MultiPoint 5 MULTIPOINT
Ellipse NULL
LegacyArc NULL
Rectangle NULL
LegacyText NULL
RoundedRectangle NULL
The table below describes the translation from Oracle (GTYPES) to MapInfo Spatial
objects.
*Some data loss may occur when translating to or from MapInfo object format.
They are interpreted (when possible) as single point SDO_POINTTYPE values if
not already NULL. They “grab” the first point in the ordered array which would be
interpreted as a NULL geometry.
Centroid Support
An MDAL application uses the SDO_POINT as the centroid value for polygons. This
centroid feature is used to position labels, and also affects the tool selection of the object.
The Oracle SDO_GEOMETRY.SDO_POINT_TYPE field (if not NULL) is interpreted as
the feature centroid if the point exists inside the region. If the point exists outside of the
region, its centroid is calculated as always.
There is currently no method or tool in MDAL to set the centroid of a region feature,
but one may read and use a stored centroid.
are not supported in Oracle Spatial and may cause problems. You can check your data
using MapInfo Professional before loading, or use the Oracle Spatial
SDO_GEOM.VALIDATE_LAYER() function on the table after loading it to Oracle Spatial.
Point Point
LineString MultiCurve
Polygon Multipolygon
MultiPoint MultiPoint
MultiLineString MultiCurve
MultiPolygon MultiPolygon
1.
GeometryCollection FeatureGeometryCollection
An EMPTY NULL
GEOMETRY/GEOGRAPHY, e.g.,
Point empty
This table shows how an MDAL FeatureGeometry is written back to SQL Server 2008
Point Point
MultiPoint MultiPoint
MultiCurve MultiLineString
Multipolygon MultiPolygon
FeatureGeometryCollection GeometryCollection *
Rectangle NULL
RoundedRectangle NULL
Ellipse NULL
LegacyArc NULL
LegacyText NULL
* This GeometryCollection may contain any or all of the following types: MultiPoint,
MultiLineString, and MultiPolygon.
SQL Server 2008 provides new types for date and time information. The following table
shows how date and time types are mapped to MDAL date and time types.
Date Date
Time Time
DateTime DateTime
SmallDateTime DateTime
DateTime2 DateTime
DateTimeOffset No support
Spatial tables from SQL Server 2008 must be registered in the MapInfo_MapCatalog so
that MDAL understands what it reads.
The MapCatalog provides four new spatialcolumn values to represent SQL Server 2008
tables:
17.x for GEOMETRY without M and Z values
18.x for GEOGRAPHY without M and Z values
20.x for GEOMETRY with M and Z values
21.x for GEOGRAPHY with M and Z values.
Data can be uploaded using MapInfo Professional or EasyLoader or you can use MapInfo
Professional to make existing data mappable, which will create the entry in the
MapCatalog. See The MapInfo_MapCatalog for more information on the MapCatalog.
Keyword Description
DRIVER= Specifies the exact driver name of the installed driver. Used instead
of the DSN= syntax key.
Example:
DRIVER={SQL Server}
UID= Specifies the desired UserId for the data source, if required.
PWD= Specifies the user’s password for the data source, if required.
Passwords do not need to be in the connection string for the two
strings to match. If two tables are in the same database, the
connection string is the same.
Keyword Description
SRVR= Reflects the service name for the server set in the Oracle Net8
EasyConfig utility. This is required for Oracle connectivity, but does
not apply to ODBC connections.
UID= Specifies the desired UserId for the data source, if required.
PWD= Specifies the user’s password for the data source, if required.
where <driver> for SQL Server Spatial should be the most current available, SQL Server
Native Client 10.0 or higher version.
In order for a query to define a mappable table, the query must contain both a geometry
column and a key column. Sometimes for more complex queries on small sets of data
(where the spatial indexing or spatial predicate cause the query to fail), you can specify
TableInfoServer.MbrSearch=false to enable the results to be mapped.
Example
Select Obj from rdbsdata
Select sw_geometry from rdbsdata
select sw_member, ST_Buffer(geometry, 66.0, 0.1) from rdbsdata
// a geometry function
Select st_geometry(st_point(72.5, 42.5) from rdbsdata
// a geometry constructor
The key column does not need to be specified in the query in most cases.
Your MDAL application can look up and determine the best key column(s) to use in order
to uniquely reference a row in the result set, and then add them to the query if they are
not present. In most cases, this is the primary key/unique index.
For Oracle Spatial tables, the MI_PRINX may be used.
For some queries, it is not possible for your MDAL application to identify the key. This is
the case in a query on a view or a synonym. The view or synonym must appear in the
MapInfo MapCatalog. They also must be registered as required with the underlying
Spatial index system in most cases. Since MDAL cannot determine the key on these, a
mechanism is provided to allow the application developer/query writer to identify the key
column in the result set. The key must be a single column and must be a distinct value in
the result set. To identify the column that is to be used as the key column, you can specify
column alias of prinx or mi_prinx, (e.g., select custid mi_prinx, custname, Obj from
mycust).
Example
Select customer_id mi_prinx, obj from customer_view
The column alias “mi_prinx” is used to identify and use the customer_id column as the
key column for the table. You can alternately alias the desired key column in the create
view statement to identify the key column automatically for any query on that view.
Example
Create view customer_view as select customer_id mi_prinx, geoloc from customer
In general, if a column name or column alias of prinx, or mi_prinx is found in the result set,
that column is used as the key column for the table. This enables the application/query
writer to specify the key column they desire.
for any mappable table to refer to the column(s) containing the spatial data. This is
required for a table using the MapMarker MDIGEOADDRESS column on a table with an
X/Y column.
You can use any server side expression/function to specify a column. Also, avoid select *
from tab in a real application.
The following code example defines a server table using a TableInfoServer.
VB example:
Public Shared Sub MapInfo_Data_TableInfoServer(ByVal connection As _
MIConnection)
' Note: Do not specify any columns. These are determined
' dynamically from the query
Performance Issues
Establishing a connection with the database server may take several seconds. This is a
one-time cost, incurred when the table is first opened.
The retrieval speed depends on how much data is retrieved from the server. In some
cases, working with data from a server is noticeably slower than displaying a map from a
local file. Speed also depends on whether your MDAL application has already cached the
map features that are being fetched.
In place of local files, applications can access MDAL table features from a remote
database. In place of reading these records from the database each time the map needs
to be acted upon, your application can temporarily store these records in the cache. This
limits the number of calls between the application and the remote database. Records in a
server table can be cached to improve the performance of your application. Server table
data is cached internally as it is read. All subsequent redraws read from this cache
instead of going to the server database for the same data. The cache is able to offer
significant redraw performance improvement.
There are several settings that developers can use to customize cache usage. The cache
can be enabled (or disabled) when the server table is added by specifying the values for
the CacheSettings property of the TableInfoServer object and is On by default.
Parameter Description
OFF A value of 'Off' means that the table will not use the cache at all. All
data operations will go directly to the database server.
Parameter Description
USER A value of USER for the LayerInfo CACHE parameter means that
your application creates a cache, but the only records that are
placed in the cache are those specified by the application
developer. The mechanisms available for specifying which records
are placed in the cache are BoundConstraint, FeaturesConstraint,
and AllFeaturesConstraint objects. The word constraint implies that
these objects are constraining the cache to include the specified
records. The BoundsConstraint object can be used to place all
records into the cache for which the MBR of the feature intersects
the MBR of the constraint.
A FeaturesConstraint object can be used to add specific records to
the cache. For example, if an analysis is going to be performed that
involves multiple steps and/or reads of the Feature or RowValues of
the feature, possibly on a set of features returned from a
Layer.Search, Layer.SearchWithinDistance, etc., it may be
advantageous to place these records into the local cache for the
duration of the analysis and remove them when finished. The
FeaturesConstraint provides this capability. If an application is
going to perform an analytically intensive operation that may hit
every record, it may be desirable to temporarily cache the entire set
of data for the layer. This is accomplished by using the
AllFeaturesConstraint. These cache constraint objects can also be
used when the cache is set to ON. In this case, they may add
records to the cache but have no effect on the cache's history of
previous map window views. The constraint objects can also be
used when the cache is set to OFF or ALL in which case they have
no effect.
ALL The entire table is cached. With this option, the table's data is
retrieved from the server once and accessed locally from that point
forward. To refresh the data in the cache, use the Refresh method
on the table.
If you try to cache too much data or too many tables, virtual memory usage may be
forced, and performance gain could be lost.
The MapInfo_MapCatalog
In order to display data on a map, your MDAL application needs to access a special table,
known as the MapInfo_MapCatalog. One catalog must be created per database before
any tables in that database can be viewed as a map layer in an MDAL application. The
MapCatalog must contain information about the spatial columns in each of the mappable
tables you want to access from the database. The MapInfo EasyLoader utility
automatically inserts the appropriate row into the MapInfo_MapCatalog when the table is
uploaded into the database.
Your application can use a MapInfo_MapCatalog that already exists on the server. (This
same catalog is shared by various MapInfo client applications). If there is no
MapInfo_MapCatalog on the server, you need to create one. MDAL supports the storage
of style information for individual features in remote databases.
VIEW_Y_UR Float,
COORDINATESYSTEM Char(254),
SYMBOL Char(254),
XCOLUMNNAME Char(32),
YCOLUMNNAME Char(32),
RENDITIONTYPE INTEGER,
RENDITIONCOLUMN CHAR(32),
RENDITIONTABLE CHAR(32)
NUMBER_ROWS INTEGER
)
It is important that the structure of the table looks exactly like this statement. The
only substitution that can be made is for databases that support varchar or text
data types; these data types can be substituted for the Char data type.
3. Create a unique index on the TABLENAME and the OWNERNAME, so only one table
for each owner can be made mappable.
create unique index mapcat_i1
on mapinfo.mapinfo_mapcatalog (OwnerName,TableName)
Maps to
MapInfo.GeometryColumn.PredominantGe-
ometry Type, and
Has<Line/Point/Region/Text>Geometries
Per-Record Styles
Per-record style support brings a feature to spatial database implementations that has
long been available in MapInfo TAB files. Specifically, it allows each geometry in a single
table to have its own style. For example, a single 'public institution' table in Oracle Spatial
can have schools, town halls, libraries, and police departments and each point type would
be represented with its own symbol (i.e., a school symbol for all the schools). Similarly, a
single road table in SpatialWare SQL Server may have different road types such that
streets are shown as a single pixel black line, secondary roads as a double pixel red line
and interstates as parallel red lines.
To use per-record styles, your table must be represented with an entry in the MapCatalog
with appropriate settings for RENDITIONTYPE, RENDITIONCOLUMN, and
RENDITIONTABLE.
If these columns are not present, the table’s default style will be applied to all
objects.
Troubleshooting
If you encounter problems with your SpatialWare or Oracle applications, use the following
table to help analyze and solve the problem.
No object was found A query was made Check that the table name
using the index that you against a table that does is correct and in the proper
specified. not exist. case. Also, the table may
need to be mappable.
Map appears to have The MBR for a DBMS Edit the extents
incorrect zoom level. layer is determined by (DB_X_LL, DB_X_UR,
For example, the map the MapInfo_MapCatalog DB_Y_LL, DB_Y_UR) in
may be zoomed out too table. The table extents the MapInfo_MapCatalog
far to identify any in the MapCatalog result using the MapInfo
geography. in a different zoom level Professional MBX tool,
than the one you desire MISETMBR.MBX.
for your output.
In this chapter:
Introduction to MapInfo.Geometry Namespace . . . . . . . . . . . . . . . . 95
Geometries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Checking for Points in Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Checking for Points in Polygons . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6 – Spatial Objects and Coordinate Systems
Geometries
The Geometry class allows for the creation, editing, and other manipulation of geometry
objects. Classes which inherit from the Geometry class and represent types of Geometry
objects include Point, MultiPoint, Polygon, MultiPolygon, Curve, CurveSegment,
LineString, and Ring. The following legacy classes are also inherited from the Geometry
class: Rectangle, RoundedRectangle, Ellipse, LegacyArc, and LegacyText.
The Geometry class represents the topmost level of the MapInfo Geometry object model.
This class is abstract, and cannot be instantiated. All classes that derive from this class
contain knowledge concerning their coordinate system. All classes are able to make
copies of themselves, and compare themselves to other Geometry objects for equality.
The diagram below shows a representation of the Geometry model.
Geometry Objects
All geometry objects in MDAL are created with a specific coordinate system that cannot
be changed. If you need to alter the coordinate system of an object you can make a copy
of that object in the new coordinate system.
FeatureGeometry Objects
The FeatureGeometry class is specifically designed to contain classes that can be placed
in tables and that can be parts of Features and FeatureCollections. In order for something
to be displayed in a map, it needs to be in a table. FeatureGeometry objects are by
definition included in tables. Any object that is a subclass of Geometry and not a subclass
of FeatureGeometry cannot be saved to a table or included as part of a Feature or
FeatureCollection. An exception is thrown, or the program will not compile, if such an
operation is attempted. The FeatureGeometry class, like the Geometry class is abstract
and cannot be instantiated.
Point
Points are derived from the FeatureGeometry class and represent a single point on a
map. Points can be contained within a MultiPoint collection and then operated upon
collectively.
Use the following example code to model the creation of a Point:
using MapInfo.Geometry;
CoordSys longLatNad83;
CoordSysFactory coordSysFactory = new CoordSysFactory();
longLatNad83 = coordSysFactory.CreateLongLat
(MapInfo.Geometry.DatumID.NAD83);
DPoint point = new DPoint(0.0, 0.0);
MultiPoint
A MultiPoint contains an unordered, disconnected set of Points and is useful for
performing multiple operations on multiple points.
Use the following example code to model the creation of a MultiPoint object:
using MapInfo.Geometry;
CoordSys longLatNad83;
CoordSysFactory coordSysFactory = new CoordSysFactory();
longLatNad83=coordSysFactory.CreateLongLat
(MapInfo.Geometry.DatumID.NAD83);
MultiPoint multiPointGeometry = new MultiPoint
(longLatNad83, pointArray);
MultiCurve
The MultiCurve class is derived from the FeatureGeometry class, and contains a possibly
disconnected set of Curves. These Curves may interact in many ways; they can be
connected or disconnected, and can intersect or overlap each other.
Although the Geometry object model supports multiple CurveSegments for each Curve,
the current version of the MapInfo engine is limited to having one CurveSegment per
Curve that is part of a FeatureGeometry (i.e., MultiCurve). This limitation derives from the
current TAB file format, which remains largely unchanged for this version of MapInfo.
Hence, the limitation concerns FeatureGeometry objects only.
Upon construction of a MultiCurve where the constructor takes a Curve or Curves which
may contain multiple CurveSegments per Curve, the actual Curves contained in the
constructed MultiCurve are altered to always contain only one CurveSegment per Curve.
Currently, the only types of CurveSegments that exist are LineStrings. Curves containing
multiple LineString CurveSegments have the LineStrings combined to form one large
LineString.
Upon completion of editing (signified by calling EditingComplete(), any Curve which was
added to the MultiCurve and contained multiple CurveSegments is altered in a similar
manner as noted above to produce Curves containing single CurveSegments.This
limitation, of Curves contained in MultiCurves always containing only a single
CurveSegment, should be removed in future versions of MapInfo as new types of
CurveSegments are introduced (e.g., EllipticalArcs, CircularArcs, and Splines), and the
TAB file format is altered. Also, during construction and on completion of editing, any
empty Curves are automatically removed from the MultiCurve.
Line objects made up of two points that exist in MapInfo TAB files become MultiCurve
FeatureGeometry objects. They can be detected as two-point Lines by using the
IsLegacyLine property of the MultiCurve:
See the Developer Reference for a code example of creating and editing a MultiCurve
object.
The order of the Curves in a MultiCurve may be altered during construction, as compared
to the array of Curves passed to the constructor, and upon completion of editing. Due to
this, plus the removal of empty Curves, and limitations in the current implementation, any
references to Curves contained in a MultiCurve prior to and during editing may no longer
be valid after editing is completed (i.e., after EditingComplete() is called). If these objects
are referenced, they throw an ObjectDisposedException. After editing, the parts of a
FeatureGeometry should be reacquired to obtain a valid reference.
LineStrings
A LineString is a directed collection of sequential points that are connected in a linear
manner. Any two consecutive points in the LineString are connected by a straight line.
LineStrings can be part of Curves or Rings, or they can exist as a stand-alone Geometry.
LineStrings that are part of Curves or Rings inherit the coordinate system of their
container. Stand-alone LineStrings can be empty. A LineString that is contained in a
Curve or Ring that is not in Edit Mode cannot be empty, and must contain at least two
points.
See the Developer Reference for a code example.
Rectangle
A Rectangle Geometry contains two points representing the lower left hand and upper
right hand corners of the Rectangle. The other two points are implied. Rectangles are
always axis aligned, and always appear to be rectangular in shape, regardless of the
coordinate system, and are not projected. They do not contain any warping that may be
represented by the coordinate system.
RoundedRectangle
A Rounded Rectangle behaves exactly like a Rectangle but is displayed with the corners
appearing rounded as a display-time only feature. The corners display as quarter circles
and the radius of the circle is controlled by the CornerRadius parameter.
Because RoundedRectangle objects, like rectangle objects, are defined by two points and
always display axis-aligned and unprojected, they are designed to be used primarily for
cosmetic display purposes. While many operations are available using Rectangle objects
(e.g., Combine), internally, a MultiPolygon copy of the Rectangle is used for these
operations. The resulting MultiPolygon contains 5 points (with the first and last points
being identical), and are effected by the coordinate system. In some instances, the
converted Rectangle may no longer appear rectangular. Use the CreateMultiPolygon
method to convert a RoundedRectangle to a FeatureGeometry object.
See the Developer Reference for a code example.
Ellipse
The Ellipse is inscribed in an axis-aligned rectangle defined by a DRect. The DRect is
defined by two points, the opposite corners of a rectangle, with the other two corners of
the rectangle implied. The Ellipse displays as if it were unprojected, regardless of the
coordinate system, and any skew that may be represented by the coordinate system.
Because Ellipse objects are defined by two points and always display axis-aligned and
unprojected, they are designed to be used primarily for cosmetic display purposes. While
many operations are available using Ellipse objects, internally, a MultiPolygon copy of the
Ellipse is used for these operations. The resulting MultiPolygon is effected by the
coordinate system and in some cases may no longer appear as a perfect ellipse.
See the Developer Reference for a code example.
LegacyArc
The LegacyArc object is a portion of an Ellipse and is defined by a DRect, a start angle,
and an end angle. The Ellipse is constructed to be inscribed in the rectangle defined by
the DRect. The rectangle, in which the Ellipse is inscribed, is axis-aligned and is always
rectangular regardless of the coordinate system used. The angles are measured in
degrees with zero being along the positive X-axis and positive angles being in the
counterclockwise direction. The angles are only stored to a tenth of a degree resolution
with values between 0.0 and 360.0.
Because LegacyArc objects are defined by two points (for the DRect) and angles, and are
always displayed axis aligned, they are designed to be used primarily for cosmetic display
purposes. While many operations are available using LegacyArc objects, internally, a
MultiCurve copy of the LegacyArc is used for these operations. This can sometimes lead
to unexpected results.
See the Developer Reference for a code example.
LegacyText
The LegacyText object is the MapInfo Professional equivalent of a text object. If a given
database does not support Text the LegacyText object can be lost when using that format.
LegacyText objects are placed within a geographically-sized rectangle with a lower-left
anchor point specified. The point-size of the text is based upon what fits best within the
rectangle.
LegacyText objects do not fit nicely into the Geometry model. Several methods available
on the Geometry FeatureGeometry classes, such as Combine, make no sense for
LegacyText and will throw a NotSupportedException. Text objects do exist in MapInfo
native TAB files in the Geometry column. The LegacyText class provides a way to access
these objects. Refer to online reference for specific behaviors of LegacyText objects.
Geometry Objects
Geometry objects that are not also FeatureGeometry objects need to be converted to a
suitable FeatureGeometry object to be displayed on a map. Most FeatureGeometry
classes contain constructors that take appropriate Geometry objects and create new
FeatureGeometry objects:
using MapInfo.Geometry;
The code above creates the Curve using parameters defined elsewhere in the code of a
CoordSys (csys) and a LineString (lineString). A new MultiCurve is then created using
the CoordSys property of the Curve and the Curve itself.
In the example above, as in all FeatureGeometries created from objects, a copy of the
original object is created because the reference cannot be shared.
Curve
The Curve class inherits from the CurveSegmentList class, and represents a contiguous
linear Geometry. Curves contain a collection of CurveSegments that must remain
contiguous. This class is included in the model to allow for future expansion and is part of
the OGC standards.
Use the following example code to model the creation of a Curve:
using MapInfo.Geometry;
CurveSegments
At present a CurveSegment can only be a LineString. The class is designed to expand in
future iterations of the product to include Spline, CircularArc, and EllipticalArc
CurveSegments. Curves and Rings are comprised of CurveSegments.
Rings
A Ring is a collection of CurveSegments which must remain contiguous and closed.
Use the following example code to model the creation of a Ring:
using MapInfo.Geometry;
Polygon
A Polygon is an object made up of Rings. A polygon must have at least a single Ring
which defines the exterior boundary of the Polygon. Other Rings can be included inside
which then define holes in the Polygon. Once a Ring is placed inside of another Ring the
object becomes a MultiPolygon.
Use the following example code to model the creation of a Polygon.
using MapInfo.Geometry;
If multiPolygon.ContainsPoint(insidePoint) Then _
Console.WriteLine("Points inside area inclosed by closed _
(GeometryDimension 2) objects are contained")
End If
If Not multiCurve.ContainsPoint(insidePoint) Then _
Console.WriteLine("But this is not true for linear _
(GeometryDimension 1) objects")
End If
If multiPolygon.ContainsPoint(boundaryPoint) Then _
Console.WriteLine("Points on the boundary of closed objects _
are contained")
End If
If multiCurve.ContainsPoint(boundaryPoint) Then _
Console.WriteLine("Points lying on linear objects are contained")
End If
Coordinate Systems
Coordinate systems describe the domain in which a particular object or set of objects
reside. The coordinate system allows for the delineation, in specific terms, of the object or
objects being described. The CoordSys classes contain methods, properties and
interfaces that allow for the creation, manipulation, and editing of coordinate systems.
When Geometries are created, they are created in a particular coordinate system
specified in the creation of the object. Objects cannot change the coordinate system in
which they were created. They can only be copied into another coordinate system.
The CoordSys class facilitates the creation and manipulation of coordinate systems. The
Coordsys class uses an XML version of the projection file (C:\Program
Files\MapInfo\Professional).
The CoordSysFactory object contains registered coordinate systems. CoordSys
definitions can be registered by loading one or more XML projection files or by using the
RegisterCoordSys, or RegisterCoordSysInfo methods. Create CoordSys objects from the
factory, or code-codespace (EPSG, SRID), PRJ string, MapBasic string, and other
Factory creation methods. There are also Military Grid Reference System conversion
methods in the CoordSys class.
The following example demonstrates registering a fictional code with the Long/Lat NAD83
coordinate system.
VB example:
Public Shared Sub MapInfo_Geometry_RegisterEPSGCode()
Dim factory As CoordSysFactory = Session.Current.CoordSysFactory
' create CoordSys objects from srsName
Dim csysNAD83 As CoordSys = _
factory.CreateCoordSys("mapinfo:coordsys 1,74")
' 9998 is a fictional code for demonstration purposes
Try
factory.RegisterEPSGCode(9998, csysNAD83)
Catch ae As ApplicationException
'code already exists. Codes cannot be duplicated
End Try
End Sub
If the EPSG or SRID code already exists, an exception will be thrown indicating this
fact.
To determine if a coordinate system for the MapInfo, EPSG or SRID codespace is already
supported, call this method:
• MapInfo.Geometry.CoordSys.Code(codespace).
This method returns the first (or only) occurrence of the codespace that matches or null, if
it does not exist.
Similarly, to return the first SRSName in the list that matches the input codespace, call
this method:
• MapInfo.Geometry.CoordSys.SRSName(codespace).
An SRSName (Spatial Reference System) represents the name of a coordinate reference
system written in GML (Geography Markup Language). This is typically, a friendly name
for the coordinate system, not a list of parameter values.
To get a list of all the codes and coordinate systems that are mapped to a particular
coordinate system, MDAL provides the following methods:
• MapInfo.Geometry.CoordSys.Codes(codeSpace)
• MapInfo.Geometry.CoordSys.SrsNames(codeSpace)
Keep in mind that the coordinate system information you added programmatically, will
only be maintained during the lifetime of the MDAL Session.
1. If your desktop application does not have an app.config file, you can create one by adding it to your project from
the Visual Studio Application Configuration File template.
</SRID_Code_Mapping>
</SRID_Code_Mappings>
</MapInfo.CoreEngine>
</configuration>
The code above shows that there are two sections of information to add. One is to identify
the correct CoreEngine dll and version number1, the second is to add elements for EPSG
and SRID code mappings.
An EPSG code mapping consists of an SRSName, SRS ID, and EPSG code(s). The
SRSID is further defined by the parameters and codespace for the coordinate system.
An SRID code mapping is similar to the EPSG code mapping, except it refers to the
Oracle Spatial identification number.
1. To determine the correct version number for the MapInfo.DataAccess assembly, examine the properties of the
installed MapInfo.DataAccess.dll (e.g., "C:\Program Files\MapInfo\Professional\MapInfo.DataAccess.dll")
In this chapter:
Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
Opening a GeoPackage file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .111
Opening a GeoPackage Tab file . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Enable GeoPackage as cache for RDB (SQL/Oracle) tables. . . . . 112
Create and Save GeoPackage file programmatically . . . . . . . . . . . 113
7 – Working with GeoPackage
Overview
GeoPackage is an open format for Geospatial Information defined by OGC
(http://www.geopackage.org). It is a SQLite-based extension defined by the OGC to
promote portability of data across platforms and products.
According to OGC definition for GeoPackage:
“A GeoPackage is a platform-independent SQLite database file that may contain:
• vector geospatial features
• tile matrix sets of imagery and raster maps at various scales
• metadata
Since a GeoPackage is a database, it supports direct use, meaning that its data can
be accessed and updated in a "native" storage format without intermediate format
translations. GeoPackages are interoperable across all enterprise and personal
computing environments, and are particularly useful on mobile devices like cell phones
and tablets in communications environments with limited connectivity and bandwidth.
This OGC® Encoding Standard defines the schema for a GeoPackage, including table
definitions, integrity assertions, format limitations, and content constraints. The
allowable content of a GeoPackage is entirely defined in this specification."
If the GeoPackage table being opened have a Coordinate System which is not
supported by MapInfo Pro then that table will not be opened.
A GeoPackage database may contain multiple tables so the database table name is
required.
The following code sample illustrates getting the list of tables in the GeoPackage database:
GeopackageDataSourceDefinition gpkgDSDef = new
GeopackageDataSourceDefinition(“c:\data\test.gpkg”); //path to gpkg file
GeopackageDataSource gpkgDS =
GeopackageDataProvider.Instance.OpenDataSource(gpkgDSDef, null) as
GeopackageDataSource;
List<IDataSourceNamedTable> tablesList = gpkgDS.GetSchemaNamedTables("main",
new string[] { "" }) as List<IDataSourceNamedTable>; //Get the list of tables
in database.
A GeoPackage tab file created using MapInfo Pro can be opened in MDAL and vice
versa.
tis.Toolkit = ServerToolkit.Odbc;
CacheParameters cp = new CacheParameters(CacheOption.All);
cp.StorageType = CacheStorageType.Geopackage; //Cache Type as Geoackage.
tis.CacheSettings = cp;
Multiple RDB tables are cached in the same GeoPackage Cache database. The benefit
for using the GeoPackage for the cache is that MDAL will use fewer temporary files which
is important for environments where the number of available file handles becomes
limiting.
Note: When using GeoPackage as a cache format, MDAL will store information that
is not supported by the standard (such as coordinate system information and styles
information). It is advisable not to use Cache file directly.
The above code will create a GPKG database along with its TAB file and will save that file
at TablePath. If GPKG database already exists then the table will be added to the existing
Database.
Once the table gets created Features can be inserted, updated and deleted from the
table. MDAL can only create GeoPackage tables for which EPSG code and OGC “Well
Known Text” description is available for the Coordinate System. The list of supported
Coordinate Systems in MDAL can be found in “MapInfoCoordinateSystemSet.xml” at
installation path “C:\Program Files\MapInfo\Professional”.
Due to the rule above when a new GeoPackage Table is created, an ID column is added
to the column list by default. So the column order of the newly created table may differ
from the order supplied.
The GeoPackage standard does not support capture of styling information with the data.
As a result, MDAL will apply a default styling to the data. Users should prefer to use layer
style overrides and/or themes on their GeoPackage feature layers to display the data in
the desired way.
MapInfo Pro will store default styling in the .TAB file which MDAL will recognize and apply
it on the GeoPackage table.