Skip to content

TabFeatureSource

Namespace: ThinkGeo.Core

Provides read and write access to MapInfo TAB datasets through the standard FeatureSource API.

public class TabFeatureSource : FeatureSource

Inheritance object → FeatureSource → TabFeatureSource

Properties

TabPathFilename

Gets or sets the full path to the TAB file that this source opens.

public string TabPathFilename { get; set; }

Property Value

string

ReadWriteMode

Gets or sets the file access mode used when opening the TAB file.

public FileAccess ReadWriteMode { get; set; }

Property Value

FileAccess

Encoding

Gets or sets the encoding used when reading textual data from the TAB dataset.

public Encoding Encoding { get; set; }

Property Value

Encoding

IsEditable

public bool IsEditable { get; }

Property Value

bool

RequireIndex

Gets or sets whether an index file is required when reading TAB data. Defaults to true.

public bool RequireIndex { get; set; }

Property Value

bool

Id

Gets or sets the Id.

public string Id { get; }

Property Value

string

CanExecuteSqlQuery

This property specifies whether the FeatureSource can excute a SQL query or not. If it is false, then it will throw exception when these APIs are calleds: ExecuteScalar, ExecuteNonQuery, ExecuteQuery

public bool CanExecuteSqlQuery { get; }

Property Value

bool

Remarks:

The default implementation is false.

IsOpen

Gets a value indicating whether the feature source is currently open.

public bool IsOpen { get; }

Property Value

bool

Remarks:

Various methods on the FeatureSource require that it be in an open state. If one of those methods is called when the state is not open, then the method will throw an exception. To enter the open state, you must call the FeatureSource's Open method. The method will raise an exception if the current FeatureSource is already open.

Projection

Gets or sets the Projection.

public Projection Projection { get; protected set; }

Property Value

Projection

CanModifyColumnStructure

Gets or sets the CanModifyColumnStructure.

public bool CanModifyColumnStructure { get; }

Property Value

bool

IsInTransaction

Gets a value indicating whether the feature source currently has an active transaction.

public bool IsInTransaction { get; }

Property Value

bool

Remarks:

To enter a transaction, you must first call the BeginTransaction method of the FeatureSource. It is possible that some FeatureSources are read-only and do not allow edits. To end a transaction, you must either call CommitTransaction or RollbackTransaction.

IsTransactionLive

Gets or sets whether uncommitted edits are visible to queries issued against the feature source.

public bool IsTransactionLive { get; set; }

Property Value

bool

Remarks:

The live transaction concept means that all of the modifications you perform during a transaction are live from the standpoint of the querying methods on the object.

As an example, imagine that you have a FeatureSource that has 10 records in it. Next, you begin a transaction and then call GetAllFeatures. The result would be 10 records. After that, you call a delete on one of the records and call the GetAllFeatures again. This time you only get nine records, even though the transaction has not yet been committed. In the same sense, you could have added a new record or modified an existing one and those changes would be considered live, though not committed.
In the case where you modify records -- such as expanding the size of a polygon -- those changes are reflected as well. For example, you expand a polygon by doubling its size and then do a spatial query that would not normally return the smaller record, but instead would return the larger records. In this case, the larger records are returned. You can set this property to be false, as well; in which case, all of the spatially related methods would ignore anything that is currently in the transaction buffer waiting to be committed. In such a case, only after committing the transaction would the FeatureSource reflect the changes.

ProjectionConverter

This property holds the projection object that is used within the FeatureSource to ensure that features inside of the FeatureSource are projected.

public ProjectionConverter ProjectionConverter { get; set; }

Property Value

ProjectionConverter

Remarks:

By default this property is null, meaning that the data being passed back from any methods on the FeatureSource will be in the coordinate system of the raw data. When you specify a projection object in the property, all incoming and outgoing method calls will subject the features to projection.

For example, if the spatial database you are using has all of its data stored in decimal degrees, but you want to see the data in UTM, you would create a projection object that goes from decimal degrees to UTM and set that as the projection. With this one property set, we will ensure that it will seem to you the developer that all of the data in the FeatureSource is in UTM. That means every spatial query will return UTM projected shapes. You can even pass in UTM shapes for the parameters. Internally, we will ensure that the shapes are converted to and from the projection without any intervention on the developer's part.
In fact, even when you override virtual or abstract core methods in the FeatureSource, you will not need to know about projections at all. Simply work with the data in its native coordinate system. We will handle all of the projection at the high level method.

GeoCache

The cache system.

public FeatureCache GeoCache { get; set; }

Property Value

FeatureCache

Remarks:

You must set IsActive to true for the Cache system. The default is not active.

FeatureIdsToExclude

A collection of strings representing record id of features not to get in the Layer.

public Collection<string> FeatureIdsToExclude { get; }

Property Value

Collection<string>

Remarks:

This string collection is a handy place to specify what records not to get from the source. Suppose you have a shape file of roads and you want to hide the roads within a particular rectangle, simply execute GetFeaturesInsideBoundingBox() and add the id of the return features to the collection and forget about them. Since you can set this by Layer it makes is easy to determine what to and what not to.

TransactionBuffer

The TransactionBuffer used in the Transaction System.

public TransactionBuffer TransactionBuffer { get; set; }

Property Value

TransactionBuffer

Remarks:


The Transaction System
The transaction system of a FeatureSource sits on top of the inherited implementation of any specific source, such as Oracle Spatial or Shape files. In this way, it functions the same way for every FeatureSource. You start by calling BeginTransaction. This allocates a collection of in-memory change buffers that are used to store changes until you commit the transaction. So, for example, when you call the Add, Delete or Update method, the changes to the feature are stored in memory only. If for any reason you choose to abandon the transaction, you can call RollbackTransaction at any time and the in-memory buffer will be deleted and the changes will be lost. When you are ready to commit the transaction, you call CommitTransaction and the collections of changes are then passed to the CommitTransactionCore method and the implementer of the specific FeatureSource is responsible for integrating your changes into the underlying FeatureSource. By default the IsLiveTransaction property is set to false, which means that until you commit the changes, the FeatureSource API will not reflect any changes that are in the temporary editing buffer.
In the case where the IsLiveTransaction is set to true, then things function slightly differently. The live transaction concept means that all of the modifications you perform during a transaction are live from the standpoint of the querying methods on the object.
As an example, imagine that you have a FeatureSource that has 10 records in it. Next, you begin a transaction and then call GetAllFeatures. The result would be 10 records. After that, you call a delete on one of the records and call the GetAllFeatures again. This time you only get nine records, even though the transaction has not yet been committed. In the same sense, you could have added a new record or modified an existing one and those changes would be considered live, though not committed.
In the case where you modify records -- such as expanding the size of a polygon -- those changes are reflected as well. For example, you expand a polygon by doubling its size and then do a spatial query that would not normally return the smaller record, but instead would return the larger records. In this case, the larger records are returned. You can set this property to be false, as well; in which case, all of the spatially related methods would ignore anything that is currently in the transaction buffer waiting to be committed. In such a case, only after committing the transaction would the FeatureSource reflect the changes.

MaxRecordsToDraw

Gets or sets the MaxRecordsToDraw.

public int MaxRecordsToDraw { get; set; }

Property Value

int

Constructors

TabFeatureSource()

Initializes a new TabFeatureSource that can be configured before opening.

public TabFeatureSource()

TabFeatureSource(string)

Initializes a new TabFeatureSource targeting the specified TAB path in read-only mode.

public TabFeatureSource(string tabPathFilename)

Parameters

tabPathFilename string
Full path to the .tab file.

TabFeatureSource(string, FileAccess)

Initializes a new TabFeatureSource targeting the specified TAB path.

public TabFeatureSource(string tabPathFilename, FileAccess readWriteMode)

Parameters

tabPathFilename string
Full path to the .tab file.

readWriteMode FileAccess
File access mode used when opening the dataset.

Methods

CanGetCountQuicklyCore()

Provides the overridable implementation that indicates whether the feature count can be obtained efficiently without enumerating all features.

protected bool CanGetCountQuicklyCore()

Returns

bool
True if the condition is met; otherwise, false.

OpenCore()

Provides the overridable implementation that opens the instance and initializes the resources it depends on.

protected void OpenCore()

Returns

void

CloseCore()

Provides the overridable implementation that closes the instance and releases any resources it holds.

protected void CloseCore()

Returns

void

GetCountCore()

Provides the overridable implementation that returns the number of items available in the underlying source.

protected long GetCountCore()

Returns

long
The result of the operation.

GetColumnsCore()

Provides the overridable implementation that returns the set of available columns (attribute schema) from the underlying data source.

protected Collection<FeatureSourceColumn> GetColumnsCore()

Returns

Collection<FeatureSourceColumn>
The result of the operation.

GetBoundingBoxCore()

Provides the overridable implementation that returns the bounding box that encloses the relevant geometry.

protected RectangleShape GetBoundingBoxCore()

Returns

RectangleShape
The result of the operation.

GetFeatureIdsCore()

Provides the overridable implementation that returns the IDs of the features available in the underlying data source.

protected Collection<string> GetFeatureIdsCore()

Returns

Collection<string>
The result of the operation.

GetAllFeaturesCore(IEnumerable<string>, int, int)

Provides the overridable implementation that returns all features from the underlying data source.

protected Collection<Feature> GetAllFeaturesCore(IEnumerable<string> returningColumnNames, int startIndex, int takeCount)

Parameters

returningColumnNames IEnumerable<string>
The collection of column names to include in the result.

startIndex int
The start index.

takeCount int
The take count.

Returns

Collection<Feature>
The result of the operation.

GetAllFeaturesCore(IEnumerable<string>)

Provides the overridable implementation that returns all features from the underlying data source.

protected Collection<Feature> GetAllFeaturesCore(IEnumerable<string> returningColumnNames)

Parameters

returningColumnNames IEnumerable<string>
The collection of column names to include in the result.

Returns

Collection<Feature>
The result of the operation.

GetFeaturesInsideBoundingBoxCore(RectangleShape, IEnumerable<string>)

Provides the overridable implementation that returns the features whose bounding boxes intersect .

protected Collection<Feature> GetFeaturesInsideBoundingBoxCore(RectangleShape boundingBox, IEnumerable<string> returningColumnNames)

Parameters

boundingBox RectangleShape
The bounding box used to constrain the query.

returningColumnNames IEnumerable<string>
The collection of column names to include in the result.

Returns

Collection<Feature>
The result of the operation.

BS0=(Ciw=)

internal void BS0=(Ciw= proj)

Parameters

proj Ciw=

Returns

void

GetFeaturesByColumnValueCore(string, string, IEnumerable<string>)

Provides the overridable implementation that returns features by column value from the underlying data source.

protected Collection<Feature> GetFeaturesByColumnValueCore(string columnName, string columnValue, IEnumerable<string> returningColumnNames)

Parameters

columnName string
The column name.

columnValue string
The column value.

returningColumnNames IEnumerable<string>
The collection of column names to include in the result.

Returns

Collection<Feature>
The result of the operation.

GetFeaturesOutsideBoundingBoxCore(RectangleShape, IEnumerable<string>)

Provides the overridable implementation that returns features outside bounding box from the underlying data source.

protected Collection<Feature> GetFeaturesOutsideBoundingBoxCore(RectangleShape boundingBox, IEnumerable<string> returningColumnNames)

Parameters

boundingBox RectangleShape
The bounding box used to constrain the query.

returningColumnNames IEnumerable<string>
The collection of column names to include in the result.

Returns

Collection<Feature>
The result of the operation.

GetFeaturesByIdsCore(IEnumerable<string>, IEnumerable<string>)

Provides the overridable implementation that returns features by ids from the underlying data source.

protected Collection<Feature> GetFeaturesByIdsCore(IEnumerable<string> ids, IEnumerable<string> returningColumnNames)

Parameters

ids IEnumerable<string>
The ids.

returningColumnNames IEnumerable<string>
The collection of column names to include in the result.

Returns

Collection<Feature>
The result of the operation.

CommitTransactionCore(TransactionBuffer)

Provides the overridable implementation that performs commit transaction.

protected TransactionResult CommitTransactionCore(TransactionBuffer transactions)

Parameters

transactions TransactionBuffer
The transactions.

Returns

TransactionResult
The result of the operation.

BuildIndexFile(string)

Builds the spatial index (.idx) file for the specified TAB dataset if it does not already exist.

public static void BuildIndexFile(string tabPathFilename)

Parameters

tabPathFilename string
Full path to the .tab file.

Returns

void

BuildIndexFile(string, BuildIndexMode)

Builds or rebuilds the spatial index for the specified TAB dataset.

public static void BuildIndexFile(string tabPathFilename, BuildIndexMode buildIndexMode)

Parameters

tabPathFilename string
Full path to the .tab file.

buildIndexMode BuildIndexMode
Determines whether an existing index is reused or rebuilt.

Returns

void

CreateTabFile(string, IEnumerable<TabDbfColumn>, IEnumerable<Feature>)

Creates a TAB dataset populated with the supplied columns and features using the default encoding.

public static void CreateTabFile(string tabPathFilename, IEnumerable<TabDbfColumn> databaseColumns, IEnumerable<Feature> features)

Parameters

tabPathFilename string
Destination TAB path.

databaseColumns IEnumerable<TabDbfColumn>
Column definitions written to the schema.

features IEnumerable<Feature>
Feature collection to persist.

Returns

void

CreateTabFile(string, IEnumerable<TabDbfColumn>, IEnumerable<Feature>, OverwriteMode)

Creates a TAB dataset and controls whether existing files are overwritten.

public static void CreateTabFile(string tabPathFilename, IEnumerable<TabDbfColumn> databaseColumns, IEnumerable<Feature> features, OverwriteMode overwriteMode)

Parameters

tabPathFilename string
Destination TAB path.

databaseColumns IEnumerable<TabDbfColumn>
Column definitions written to the schema.

features IEnumerable<Feature>
Feature collection to persist.

overwriteMode OverwriteMode
Specifies whether existing files can be overwritten.

Returns

void

CreateTabFile(string, IEnumerable<TabDbfColumn>, IEnumerable<Feature>, OverwriteMode, Encoding)

Creates a TAB dataset with full control over overwrite behavior and encoding.

public static void CreateTabFile(string tabPathFilename, IEnumerable<TabDbfColumn> databaseColumns, IEnumerable<Feature> features, OverwriteMode overwriteMode, Encoding encoding)

Parameters

tabPathFilename string
Destination TAB path.

databaseColumns IEnumerable<TabDbfColumn>
Column definitions written to the schema.

features IEnumerable<Feature>
Feature collection to persist.

overwriteMode OverwriteMode
Specifies whether existing files can be overwritten.

encoding Encoding
Encoding applied to textual data.

Returns

void

Dy0=()

internal Ciw= Dy0=()

Returns

Ciw=

BuildRecordIdColumn(string, string, BuildRecordIdMode)

Creates or rebuilds a record-id column using the default start value and encoding.

public static void BuildRecordIdColumn(string tabFileName, string fieldName, BuildRecordIdMode buildRecordIdMode)

Parameters

tabFileName string
TAB dataset that receives the record-id column.

fieldName string
Column name used for the identifiers.

buildRecordIdMode BuildRecordIdMode
Controls whether to rebuild or only create if missing.

Returns

void

BuildRecordIdColumn(string, string, BuildRecordIdMode, int)

Creates or rebuilds a record-id column starting from the supplied seed value.

public static void BuildRecordIdColumn(string tabFileName, string fieldName, BuildRecordIdMode buildRecordIdMode, int startNumber)

Parameters

tabFileName string
TAB dataset that receives the record-id column.

fieldName string
Column name used for the identifiers.

buildRecordIdMode BuildRecordIdMode
Controls whether to rebuild or only create if missing.

startNumber int
Initial value assigned to the first record.

Returns

void

BuildRecordIdColumn(string, string, BuildRecordIdMode, int, Encoding)

Creates or rebuilds a record-id column using a specific start value and encoding.

public static void BuildRecordIdColumn(string tabFileName, string fieldName, BuildRecordIdMode buildRecordIdMode, int startNumber, Encoding encoding)

Parameters

tabFileName string
TAB dataset that receives the record-id column.

fieldName string
Column name used for the identifiers.

buildRecordIdMode BuildRecordIdMode
Controls whether to rebuild or only create if missing.

startNumber int
Initial value assigned to the first record.

encoding Encoding
Encoding applied when writing the column.

Returns

void

Gi0=()

internal Dictionary<Feature, IEnumerable<Style>> Gi0=()

Returns

Dictionary<Feature, IEnumerable<Style>>

Gy0=()

internal void Gy0=()

Returns

void

SetEmbeddedSymbolStyle(Feature, PointStyle)

Applies a point style directly to the supplied feature and persists it to the TAB file.

public void SetEmbeddedSymbolStyle(Feature feature, PointStyle pointStyle)

Parameters

feature Feature
Feature that receives the embedded symbol style.

pointStyle PointStyle
Style whose appearance will be converted to MapInfo symbol metadata.

Returns

void

SetEmbeddedPenStyle(Feature, LineStyle)

Applies a line style directly to the supplied feature and persists it to the TAB file.

public void SetEmbeddedPenStyle(Feature feature, LineStyle lineStyle)

Parameters

feature Feature
Feature that receives the embedded pen style.

lineStyle LineStyle
Style whose appearance will be converted to MapInfo pen metadata.

Returns

void

SetEmbeddedBrushStyle(Feature, AreaStyle)

Applies an area style directly to the supplied feature and persists it to the TAB file.

public void SetEmbeddedBrushStyle(Feature feature, AreaStyle areaStyle)

Parameters

feature Feature
Feature that receives the embedded brush style.

areaStyle AreaStyle
Style whose appearance will be converted to MapInfo brush metadata.

Returns

void

SetEmbeddedTextStyle(Feature, TextStyle)

Applies a text style directly to the supplied feature and persists it to the TAB file.

public void SetEmbeddedTextStyle(Feature feature, TextStyle textStyle)

Parameters

feature Feature
Feature that receives the embedded text style.

textStyle TextStyle
Style whose appearance will be converted to MapInfo text metadata.

Returns

void

Events

DrawingProgressChanged

Occurs when the DrawingProgressChanged event is raised.

public event EventHandler<DrawingProgressChangedEventArgs> DrawingProgressChanged;

GettingColumns

Occurs when the GettingColumns event is raised.

public event EventHandler<GettingColumnsFeatureSourceEventArgs> GettingColumns;

GottenColumns

Occurs when the GottenColumns event is raised.

public event EventHandler<GottenColumnsFeatureSourceEventArgs> GottenColumns;

GettingFeaturesByIds

Occurs when the GettingFeaturesByIds event is raised.

public event EventHandler<GettingFeaturesByIdsFeatureSourceEventArgs> GettingFeaturesByIds;

GettingFeaturesForDrawing

Occurs when the GettingFeaturesForDrawing event is raised.

public event EventHandler<GettingFeaturesForDrawingFeatureSourceEventArgs> GettingFeaturesForDrawing;

CustomColumnFetch

This event is raised when fields are requested in a feature source method that do not exist in the feature source. It allows you to supplement the data from any outside source you have.

public event EventHandler<CustomColumnFetchEventArgs> CustomColumnFetch;

Remarks:

source you have.

It is used primarily when you have data relating to a particular feature or set of features that is not within source of the data. For example, you may have a shape file of the world whose .dbf component describes the area and population of each country. Additionally, in an outside SQL Server table, you may also have data about the countries, and it is this data that you wish to use for determining how you want to color each country.
To integrate this SQL data, you simply create a file name that does not exist in the .dbf file. Whenever Map Suite is queried to return records that specifically require this field, the FeatureSource will raise this event and allow you the developer to supply the data. In this way, you can query the SQL table and store the data in some sort of collection, and then when the event is raised, simply supply that data.
As this is an event, it will raise for each feature and field combination requested. This means that the event can be raised quite often, and we suggest that you cache the data you wish to supply in memory. We recommend against sending out a new SQL query each time this event is raised. Image that you are supplementing two columns and your query returns 2,000 rows. This means that if you requested those fields, the event would be raised 4,000 times.

CommittingTransaction

This event is raised after the CommitTransaction method is called, but before the CommitTransactionCore is called. This allows you access to the TransactionBuffer before the transaction is committed. It also allows you to cancel the pending commit of the transaction.

public event EventHandler<CommittingTransactionEventArgs> CommittingTransaction;

Remarks:

This event is raised before the CommitTransactionCore is called and allows you access to the TransactionBuffer before the transaction is committed. It also allows you to cancel the pending transaction. The TransactionBuffer is the object that stores all of the pending transactions and is accessible through this event to allow you to either add, remove or modify transactions.

In the event that you cancel the CommitTransaction method, the transaction remains intact and you will still be editing. This makes it a nice place to possibly check for connectivity before the TransactionCore code is run, which is where the records are actually committed. Calling the RollBackTransaction method is the only way to permanently cancel a pending transaction without committing it.

CommittedTransaction

This event is raised after the CommitTransaction and the CommitTransactionCore are called and allows you access to the TransactionBuffer and the TransactionResults object before CommitTransaction method is returned.

public event EventHandler<CommittedTransactionEventArgs> CommittedTransaction;

Remarks:

This event is raised after the CommitTransactionCore is called and allows you access to the TransactionBuffer and the TransactionResults object before CommitTransaction method is returned.

With this event, you can analyse the results of the transaction and do any cleanup code necessary. In the event some of the records did not commit, you can handle those items here. The TransactionResults object is passed out of the CommitTransaction method so you could analyze it then; however, this is the only place where you have access to both the TransactionResults object and the TransactionBuffer object at the same time. These are useful together to try and determine what went wrong and possibly try and re-commit them.
At the time of this event you will technically be out of the current transaction.

OpeningFeatureSource

This event is called before the opening of the FeatureSource.

public event EventHandler<OpeningFeatureSourceEventArgs> OpeningFeatureSource;

Remarks:

This event is called before the opening of the FeatureSource. Technically, this event is called after the calling of the Open method on the FeatureSource, but before the protected OpenCore method.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.

OpenedFeatureSource

This event is called after the opening of the FeatureSource.

public event EventHandler<OpenedFeatureSourceEventArgs> OpenedFeatureSource;

Remarks:

This event is called after the opening of the FeatureSource. Technically, this event is called after the calling of the Open method on the FeatureSource and after the protected OpenCore method is called.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.

ClosingFeatureSource

This event is called before the closing of the FeatureSource.

public event EventHandler<ClosingFeatureSourceEventArgs> ClosingFeatureSource;

Remarks:

This event is called before the closing of the FeatureSource. Technically, this event is called after the calling of the Close method on the FeatureSource, but before the protected CloseCore method.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.

ClosedFeatureSource

This event is called after the closing of the FeatureSource.

public event EventHandler<ClosedFeatureSourceEventArgs> ClosedFeatureSource;

Remarks:

This event is called after the closing of the FeatureSource. Technically, this event is called after the calling of the Close method on the FeatureSource and after the protected CloseCore method.

It is typical that the FeatureSource may be opened and closed may times during the life cycle of your application. The type of control the MapEngine is embedded in will dictate how often this happens. For example, in the case of the Web Edition, each time a FeatureSource is in the Ajax or Post Back part of the page cycle, it will close the FeatureSource before returning back to the client. This is to conserve resources, as the web is a connection-less environment. In the case of the Desktop Edition, we can keep the FeaureSources open, knowing that we can maintain a persistent connection.